chronoshift
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -1,2 +0,1 @@ | ||
/// <reference path="../typings/immutable-class.d.ts" /> | ||
declare module Chronoshift { | ||
@@ -77,4 +76,4 @@ interface WallTime { | ||
class Duration implements Instance<DurationValue, string> { | ||
private singleSpan; | ||
private spans; | ||
singleSpan: string; | ||
spans: DurationValue; | ||
static fromJS(durationStr: string): Duration; | ||
@@ -101,2 +100,4 @@ static fromCanonicalLength(length: number): Duration; | ||
getDescription(capitalize?: boolean): string; | ||
getSingleSpan(): string; | ||
getSingleSpanValue(): number; | ||
} | ||
@@ -103,0 +104,0 @@ } |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var Chronoshift; | ||
@@ -569,2 +568,10 @@ (function (Chronoshift) { | ||
}; | ||
Duration.prototype.getSingleSpan = function () { | ||
return this.singleSpan || null; | ||
}; | ||
Duration.prototype.getSingleSpanValue = function () { | ||
if (!this.singleSpan) | ||
return null; | ||
return this.spans[this.singleSpan]; | ||
}; | ||
return Duration; | ||
@@ -571,0 +578,0 @@ }()); |
{ | ||
"name": "chronoshift", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "A tiny library for shifting time with timezones", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -104,4 +104,4 @@ module Chronoshift { | ||
export class Duration implements Instance<DurationValue, string> { | ||
private singleSpan: string; | ||
private spans: DurationValue; | ||
public singleSpan: string; | ||
public spans: DurationValue; | ||
@@ -320,4 +320,14 @@ static fromJS(durationStr: string): Duration { | ||
} | ||
public getSingleSpan(): string { | ||
return this.singleSpan || null; | ||
} | ||
public getSingleSpanValue(): number { | ||
if (!this.singleSpan) return null; | ||
return this.spans[this.singleSpan]; | ||
} | ||
} | ||
check = Duration; | ||
} |
@@ -1,4 +0,1 @@ | ||
/// <reference path="../typings/immutable-class.d.ts" /> | ||
"use strict"; | ||
declare function require(file: string): any; | ||
@@ -5,0 +2,0 @@ declare var module: { exports: any; }; |
@@ -255,2 +255,36 @@ /// <reference path="../typings/mocha/mocha.d.ts" /> | ||
}); | ||
describe("#getSingleSpan()", function () { | ||
it("gives back the correct span", function () { | ||
var durationStr; | ||
durationStr = "P1D"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('day'); | ||
durationStr = "P3Y"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('year'); | ||
durationStr = "P2W"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('week'); | ||
durationStr = "PT5H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('hour'); | ||
durationStr = "P3DT15H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal(null); | ||
durationStr = "P3DT15H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal(null); | ||
}); | ||
}); | ||
describe("#getSingleSpanValue()", function () { | ||
it("gives back the correct span value", function () { | ||
var durationStr; | ||
durationStr = "P1D"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(1); | ||
durationStr = "P3Y"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(3); | ||
durationStr = "P2W"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(2); | ||
durationStr = "PT5H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(5); | ||
durationStr = "P3DT15H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(null); | ||
durationStr = "P3DT15H"; | ||
chai_1.expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(null); | ||
}); | ||
}); | ||
}); |
@@ -345,2 +345,49 @@ /// <reference path="../typings/mocha/mocha.d.ts" /> | ||
}); | ||
describe("#getSingleSpan()", () => { | ||
it("gives back the correct span", () => { | ||
var durationStr; | ||
durationStr = "P1D"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('day'); | ||
durationStr = "P3Y"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('year'); | ||
durationStr = "P2W"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('week'); | ||
durationStr = "PT5H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal('hour'); | ||
durationStr = "P3DT15H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal(null); | ||
durationStr = "P3DT15H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpan()).to.equal(null); | ||
}); | ||
}); | ||
describe("#getSingleSpanValue()", () => { | ||
it("gives back the correct span value", () => { | ||
var durationStr; | ||
durationStr = "P1D"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(1); | ||
durationStr = "P3Y"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(3); | ||
durationStr = "P2W"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(2); | ||
durationStr = "PT5H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(5); | ||
durationStr = "P3DT15H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(null); | ||
durationStr = "P3DT15H"; | ||
expect(Duration.fromJS(durationStr).getSingleSpanValue()).to.equal(null); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
880849
9495