Comparing version 0.2.1 to 0.2.2
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="0.2.2"></a> | ||
## [0.2.2](https://github.com/medikoo/duration/compare/v0.2.1...v0.2.2) (2018-10-31) | ||
### Bug Fixes | ||
* fix duration.day calculation for uneven months ([c63bcfa](https://github.com/medikoo/duration/commit/c63bcfa)) | ||
<a name="0.2.1"></a> | ||
@@ -10,4 +20,7 @@ | ||
- Fix spelling LICENCE - LICENSE (Addresses https://github.com/medikoo/duration/issues/5) | ||
- Reconfigure to use eslint | ||
## Old changelog | ||
See `CHANGES` |
58
index.js
@@ -51,3 +51,3 @@ "use strict"; | ||
Duration.prototype = Object.create(Object.prototype, { | ||
valueOf: d(toPrimitive = function () { return this.to - this.from; }), | ||
valueOf: d((toPrimitive = function () { return this.to - this.from; })), | ||
millisecond: d.gs(function () { return this.milliseconds % 1000; }), | ||
@@ -58,11 +58,19 @@ second: d.gs(function () { return this.seconds % 60; }), | ||
day: d.gs(function () { | ||
var data = getCalcData(this), x = copy.call(data.to); | ||
x.setMonth(x.getMonth() - 1); | ||
x = daysInMonth.call(x); | ||
return ( | ||
data.sign * | ||
(((x - data.from.getDate() + data.to.getDate()) % x) - | ||
(data.from - dfloor.call(copy.call(data.from)) > | ||
data.to - dfloor.call(copy.call(data.to)))) | ||
); | ||
var data = getCalcData(this); | ||
var toDays = data.to.getDate(), fromDays = data.from.getDate(); | ||
var isToLater = | ||
data.to - dfloor.call(copy.call(data.to)) >= | ||
data.from - dfloor.call(copy.call(data.from)); | ||
var result; | ||
if (toDays > fromDays) { | ||
result = toDays - fromDays; | ||
if (!isToLater) --result; | ||
return data.sign * result; | ||
} | ||
if (toDays === fromDays && isToLater) { | ||
return 0; | ||
} | ||
result = isToLater ? toDays : toDays - 1; | ||
result += daysInMonth.call(data.from) - data.from.getDate(); | ||
return data.sign * result; | ||
}), | ||
@@ -79,3 +87,3 @@ month: d.gs(function () { | ||
year: d.gs( | ||
getYear = function () { | ||
(getYear = function () { | ||
var data = getCalcData(this); | ||
@@ -89,3 +97,3 @@ return ( | ||
); | ||
} | ||
}) | ||
), | ||
@@ -117,6 +125,8 @@ | ||
if (!this.days && threshold < 0) return this._resolveSign(isNonZero) + s; | ||
if (threshold-- <= 0) s = abs(isNonZero = this.day) + "d" + (s ? " " : "") + s; | ||
if (threshold-- <= 0) s = abs((isNonZero = this.day)) + "d" + (s ? " " : "") + s; | ||
if (!this.months && threshold < 0) return this._resolveSign(isNonZero) + s; | ||
if (threshold-- <= 0) s = abs(isNonZero = this.month) + "m" + (s ? " " : "") + s; | ||
if (this.years || threshold >= 0) s = abs(isNonZero = this.year) + "y" + (s ? " " : "") + s; | ||
if (threshold-- <= 0) s = abs((isNonZero = this.month)) + "m" + (s ? " " : "") + s; | ||
if (this.years || threshold >= 0) { | ||
s = abs((isNonZero = this.year)) + "y" + (s ? " " : "") + s; | ||
} | ||
return this._resolveSign(isNonZero) + s; | ||
@@ -126,3 +136,3 @@ }), | ||
var s = "", isNonZero; | ||
if (threshold-- <= 0) s += "." + pad.call(abs(isNonZero = this.millisecond), 3); | ||
if (threshold-- <= 0) s += "." + pad.call(abs((isNonZero = this.millisecond)), 3); | ||
if (!this.seconds && threshold < 0) return this._resolveSign(isNonZero) + s; | ||
@@ -142,3 +152,3 @@ if (threshold-- <= 0) { | ||
if (!this.hours && threshold < 0) return this._resolveSign(isNonZero) + s; | ||
if (threshold-- <= 0) s = pad.call(abs(isNonZero = this.hour), 2) + (s ? ":" : "") + s; | ||
if (threshold-- <= 0) s = pad.call(abs((isNonZero = this.hour)), 2) + (s ? ":" : "") + s; | ||
return this._toStringDefaultDate(threshold, s, isNonZero); | ||
@@ -148,15 +158,15 @@ }), | ||
var tokens = [], isNonZero; | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.millisecond) + "ms"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.millisecond)) + "ms"); | ||
if (!this.seconds && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.second) + "s"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.second)) + "s"); | ||
if (!this.minutes && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.minute) + "m"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.minute)) + "m"); | ||
if (!this.hours && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.hour) + "h"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.hour)) + "h"); | ||
if (!this.days && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.day) + "d"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.day)) + "d"); | ||
if (!this.months && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
if (threshold-- <= 0) tokens.unshift(abs(isNonZero = this.month) + "m"); | ||
if (threshold-- <= 0) tokens.unshift(abs((isNonZero = this.month)) + "m"); | ||
if (!this.years && threshold < 0) return this._resolveSign(isNonZero) + tokens.join(" "); | ||
tokens.unshift(abs(isNonZero = this.year) + "y"); | ||
tokens.unshift(abs((isNonZero = this.year)) + "y"); | ||
return this._resolveSign(isNonZero) + tokens.join(" "); | ||
@@ -163,0 +173,0 @@ }), |
{ | ||
"name": "duration", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Time duration utilities", | ||
@@ -17,8 +17,8 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"d": "1", | ||
"es5-ext": "~0.10.23" | ||
"es5-ext": "~0.10.46" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.4", | ||
"eslint-config-medikoo-es5": "^1.6.1", | ||
"tad": "~0.2.7" | ||
"eslint": "^5.8", | ||
"eslint-config-medikoo-es5": "^1.7.2", | ||
"tad": "~0.2.8" | ||
}, | ||
@@ -25,0 +25,0 @@ "eslintConfig": { |
@@ -14,4 +14,3 @@ "use strict"; | ||
d3 = new Date(); | ||
a.ok(((m = d.milliseconds) >= t(d1, d2).milliseconds) && | ||
(m <= t(d1, d3).milliseconds)); | ||
a.ok((m = d.milliseconds) >= t(d1, d2).milliseconds && m <= t(d1, d3).milliseconds); | ||
}, | ||
@@ -59,4 +58,6 @@ "Milliseconds": function (a) { | ||
a(d.toString(1, 7), "0y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .011.11.00.0.00.0.00.0.00.0.00.0.0 ", "String presentation (custom)"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .011.11.00.0.00.0.00.0.00.0.00.0.0 ", "String presentation (custom)" | ||
); | ||
@@ -82,4 +83,3 @@ d = t(d2, d1); | ||
a(d.toString(), "-.011", "String presentation: Negative"); | ||
a(d.toString(0, 0), "-.011", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 0), "-.011", "String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "0", "String presentation: Negative: Threshold #1"); | ||
@@ -93,21 +93,14 @@ a(d.toString(0, 2), "0", "String presentation: Negative: Threshold #2"); | ||
a(d.toString(1), "-11ms", "String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-11ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "0s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "0m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.011.11.00.0.00.0.00.0.00.0.00.0.0 ", | ||
"String presentation (custom): Negative"); | ||
a(d.toString(1, 0), "-11ms", "String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "0s", "String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "0m", "String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.011.11.00.0.00.0.00.0.00.0.00.0.0 ", "String presentation (custom): Negative" | ||
); | ||
}, | ||
@@ -156,5 +149,7 @@ "Seconds": function (a) { | ||
a(d.toString(1, 7), "0y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + (7 * 1000 + 123) + ".07.7.00.0.00.0.00.0.00.0.0 ", | ||
"String presentation (custom)"); | ||
"String presentation (custom)" | ||
); | ||
@@ -180,4 +175,3 @@ d = t(d2, d1); | ||
a(d.toString(), "-7.123", "String presentation: Negative"); | ||
a(d.toString(0, 0), "-7.123", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 0), "-7.123", "String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-7", "String presentation: Negative: Threshold #1"); | ||
@@ -191,21 +185,15 @@ a(d.toString(0, 2), "0", "String presentation: Negative: Threshold #2"); | ||
a(d.toString(1), "-7s 123ms", "String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-7s 123ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-7s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "0m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
a(d.toString(1, 0), "-7s 123ms", "String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-7s", "String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "0m", "String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + (7 * 1000 + 123) + ".07.7.00.0.00.0.00.0.00.0.0 ", | ||
"String presentation (custom): Negative"); | ||
"String presentation (custom): Negative" | ||
); | ||
}, | ||
@@ -247,4 +235,3 @@ "Minutes": function (a) { | ||
a(d.toString(1), "7m 12s 123ms", "String presentation #2"); | ||
a(d.toString(1, 0), "7m 12s 123ms", | ||
"String presentation #2: Threshold #0"); | ||
a(d.toString(1, 0), "7m 12s 123ms", "String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "7m 12s", "String presentation #2: Threshold #1"); | ||
@@ -257,9 +244,14 @@ a(d.toString(1, 2), "7m", "String presentation #2: Threshold #2"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + (7 * 60 * 1000 + 12 * 1000 + 123) + ".12." + (7 * 60 + 12) + | ||
".07.7.00.0.00.0.00.0.0 ", "String presentation (custom)"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + | ||
(7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + | ||
(7 * 60 + 12) + | ||
".07.7.00.0.00.0.00.0.0 ", | ||
"String presentation (custom)" | ||
); | ||
d = t(d2, d1); | ||
a(d.milliseconds, -(7 * 60 * 1000 + 12 * 1000 + 123), | ||
"Milliseconds: Negative"); | ||
a(d.milliseconds, -(7 * 60 * 1000 + 12 * 1000 + 123), "Milliseconds: Negative"); | ||
a(d.valueOf(), d.milliseconds, "Value: Negative"); | ||
@@ -282,6 +274,4 @@ a(d.seconds, -(7 * 60 + 12), "Seconds: Negative"); | ||
a(d.toString(), "-07:12.123", "String presentation: Negative"); | ||
a(d.toString(0, 0), "-07:12.123", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-07:12", | ||
"String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 0), "-07:12.123", "String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-07:12", "String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-7", "String presentation: Negative: Threshold #2"); | ||
@@ -293,21 +283,19 @@ a(d.toString(0, 3), "00", "String presentation: Negative: Threshold #3"); | ||
a(d.toString(1), "-7m 12s 123ms", "String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-7m 12s 123ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-7m 12s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-7m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + (7 * 60 * 1000 + 12 * 1000 + 123) + ".12." + (7 * 60 + 12) + | ||
".07.7.00.0.00.0.00.0.0 ", "String presentation (custom): Negative"); | ||
a(d.toString(1, 0), "-7m 12s 123ms", "String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-7m 12s", "String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-7m", "String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "0h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + | ||
(7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + | ||
(7 * 60 + 12) + | ||
".07.7.00.0.00.0.00.0.0 ", | ||
"String presentation (custom): Negative" | ||
); | ||
}, | ||
@@ -323,4 +311,3 @@ "Hours": function (a) { | ||
d = t(d1, d2); | ||
a(d.milliseconds, | ||
4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds"); | ||
a(d.milliseconds, 4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds"); | ||
a(d.valueOf(), d.milliseconds, "Value"); | ||
@@ -352,4 +339,3 @@ a(d.seconds, 4 * 60 * 60 + 7 * 60 + 12, "Seconds"); | ||
a(d.toString(1), "4h 7m 12s 123ms", "String presentation #2"); | ||
a(d.toString(1, 0), "4h 7m 12s 123ms", | ||
"String presentation #2: Threshold #0"); | ||
a(d.toString(1, 0), "4h 7m 12s 123ms", "String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "4h 7m 12s", "String presentation #2: Threshold #1"); | ||
@@ -362,11 +348,19 @@ a(d.toString(1, 2), "4h 7m", "String presentation #2: Threshold #2"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + (4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + (4 * 60 * 60 + 7 * 60 + 12) + ".07." + (4 * 60 + 7) + | ||
".04.4.00.0.00.0.0 ", "String presentation (custom)"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + | ||
(4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + | ||
(4 * 60 * 60 + 7 * 60 + 12) + | ||
".07." + | ||
(4 * 60 + 7) + | ||
".04.4.00.0.00.0.0 ", | ||
"String presentation (custom)" | ||
); | ||
d = t(d2, d1); | ||
a(d.milliseconds, | ||
-(4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123), | ||
"Milliseconds: Negative"); | ||
a( | ||
d.milliseconds, -(4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123), | ||
"Milliseconds: Negative" | ||
); | ||
a(d.valueOf(), d.milliseconds, "Value: Negative"); | ||
@@ -389,8 +383,5 @@ a(d.seconds, -(4 * 60 * 60 + 7 * 60 + 12), "Seconds: Negative"); | ||
a(d.toString(), "-04:07:12.123", "String presentation: Negative"); | ||
a(d.toString(0, 0), "-04:07:12.123", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-04:07:12", | ||
"String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-04:07", | ||
"String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 0), "-04:07:12.123", "String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-04:07:12", "String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-04:07", "String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 3), "-04", "String presentation: Negative: Threshold #3"); | ||
@@ -402,22 +393,24 @@ a(d.toString(0, 4), "0d", "String presentation: Negative: Threshold #4"); | ||
a(d.toString(1), "-4h 7m 12s 123ms", "String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-4h 7m 12s 123ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-4h 7m 12s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-4h 7m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "-4h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + (4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + (4 * 60 * 60 + 7 * 60 + 12) + ".07." + (4 * 60 + 7) + | ||
".04.4.00.0.00.0.0 ", "String presentation (custom): Negative"); | ||
a( | ||
d.toString(1, 0), "-4h 7m 12s 123ms", | ||
"String presentation #2: Negative: Threshold #0" | ||
); | ||
a(d.toString(1, 1), "-4h 7m 12s", "String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-4h 7m", "String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "-4h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "0d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + | ||
(4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123) + | ||
".12." + | ||
(4 * 60 * 60 + 7 * 60 + 12) + | ||
".07." + | ||
(4 * 60 + 7) + | ||
".04.4.00.0.00.0.0 ", | ||
"String presentation (custom): Negative" | ||
); | ||
}, | ||
@@ -434,7 +427,9 @@ "Days": function (a) { | ||
d = t(d1, d2); | ||
a(d.milliseconds, 2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds"); | ||
a( | ||
d.milliseconds, | ||
2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123, | ||
"Milliseconds" | ||
); | ||
a(d.valueOf(), d.milliseconds, "Value"); | ||
a(d.seconds, 2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12, | ||
"Seconds"); | ||
a(d.seconds, 2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12, "Seconds"); | ||
a(d.minutes, 2 * 24 * 60 + 14 * 60 + 7, "Minutes"); | ||
@@ -455,4 +450,3 @@ a(d.hours, 2 * 24 + 14, "Hours"); | ||
a(d.toString(), "2d 14:07:12.123", "String presentation"); | ||
a(d.toString(0, 0), "2d 14:07:12.123", | ||
"String presentation: Threshold #0"); | ||
a(d.toString(0, 0), "2d 14:07:12.123", "String presentation: Threshold #0"); | ||
a(d.toString(0, 1), "2d 14:07:12", "String presentation: Threshold #1"); | ||
@@ -466,6 +460,4 @@ a(d.toString(0, 2), "2d 14:07", "String presentation: Threshold #2"); | ||
a(d.toString(1), "2d 14h 7m 12s 123ms", "String presentation #2"); | ||
a(d.toString(1, 0), "2d 14h 7m 12s 123ms", | ||
"String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "2d 14h 7m 12s", | ||
"String presentation #2: Threshold #1"); | ||
a(d.toString(1, 0), "2d 14h 7m 12s 123ms", "String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "2d 14h 7m 12s", "String presentation #2: Threshold #1"); | ||
a(d.toString(1, 2), "2d 14h 7m", "String presentation #2: Threshold #2"); | ||
@@ -477,15 +469,28 @@ a(d.toString(1, 3), "2d 14h", "String presentation #2: Threshold #3"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + (2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + 12 * 1000 + 123) + ".12." + | ||
(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12) + ".07." + | ||
(2 * 24 * 60 + 14 * 60 + 7) + ".14." + (2 * 24 + 14) + | ||
".02.2.00.0.0 ", "String presentation (custom)"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .123." + | ||
(2 * 24 * 60 * 60 * 1000 + | ||
14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + | ||
12 * 1000 + | ||
123) + | ||
".12." + | ||
(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12) + | ||
".07." + | ||
(2 * 24 * 60 + 14 * 60 + 7) + | ||
".14." + | ||
(2 * 24 + 14) + | ||
".02.2.00.0.0 ", | ||
"String presentation (custom)" | ||
); | ||
d = t(d2, d1); | ||
a(d.milliseconds, -(2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + 12 * 1000 + 123), "Milliseconds: Negative"); | ||
a( | ||
d.milliseconds, | ||
-(2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123), | ||
"Milliseconds: Negative" | ||
); | ||
a(d.valueOf(), d.milliseconds, "Value: Negative"); | ||
a(d.seconds, -(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12), | ||
"Seconds: Negative"); | ||
a(d.seconds, -(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12), "Seconds: Negative"); | ||
a(d.minutes, -(2 * 24 * 60 + 14 * 60 + 7), "Minutes: Negative"); | ||
@@ -506,10 +511,6 @@ a(d.hours, -(2 * 24 + 14), "Hours: Negative"); | ||
a(d.toString(), "-2d 14:07:12.123", "String presentation: Negative"); | ||
a(d.toString(0, 0), "-2d 14:07:12.123", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-2d 14:07:12", | ||
"String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-2d 14:07", | ||
"String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 3), "-2d 14", | ||
"String presentation: Negative: Threshold #3"); | ||
a(d.toString(0, 0), "-2d 14:07:12.123", "String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-2d 14:07:12", "String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-2d 14:07", "String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 3), "-2d 14", "String presentation: Negative: Threshold #3"); | ||
a(d.toString(0, 4), "-2d", "String presentation: Negative: Threshold #4"); | ||
@@ -519,26 +520,31 @@ a(d.toString(0, 5), "0m", "String presentation: Negative: Threshold #5"); | ||
a(d.toString(0, 7), "0y", "String presentation: Negative: Threshold #7"); | ||
a(d.toString(1), "-2d 14h 7m 12s 123ms", | ||
"String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-2d 14h 7m 12s 123ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-2d 14h 7m 12s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-2d 14h 7m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "-2d 14h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "-2d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + (2 * 24 * 60 * 60 * 1000 + 14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + 12 * 1000 + 123) + ".12." + | ||
(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12) + ".07." + | ||
(2 * 24 * 60 + 14 * 60 + 7) + ".14." + (2 * 24 + 14) + | ||
".02.2.00.0.0 ", "String presentation (custom): Negative"); | ||
a(d.toString(1), "-2d 14h 7m 12s 123ms", "String presentation #2: Negative"); | ||
a( | ||
d.toString(1, 0), "-2d 14h 7m 12s 123ms", | ||
"String presentation #2: Negative: Threshold #0" | ||
); | ||
a(d.toString(1, 1), "-2d 14h 7m 12s", "String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-2d 14h 7m", "String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "-2d 14h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "-2d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "0m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "0y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "0y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.123." + | ||
(2 * 24 * 60 * 60 * 1000 + | ||
14 * 60 * 60 * 1000 + | ||
7 * 60 * 1000 + | ||
12 * 1000 + | ||
123) + | ||
".12." + | ||
(2 * 24 * 60 * 60 + 14 * 60 * 60 + 7 * 60 + 12) + | ||
".07." + | ||
(2 * 24 * 60 + 14 * 60 + 7) + | ||
".14." + | ||
(2 * 24 + 14) + | ||
".02.2.00.0.0 ", | ||
"String presentation (custom): Negative" | ||
); | ||
}, | ||
@@ -569,8 +575,5 @@ "Large duration": function (a) { | ||
a(d.toString(), "2y 2m 0d 00:00:00.000", "String presentation"); | ||
a(d.toString(0, 0), "2y 2m 0d 00:00:00.000", | ||
"String presentation: Threshold #0"); | ||
a(d.toString(0, 1), "2y 2m 0d 00:00:00", | ||
"String presentation: Threshold #1"); | ||
a(d.toString(0, 2), "2y 2m 0d 00:00", | ||
"String presentation: Threshold #2"); | ||
a(d.toString(0, 0), "2y 2m 0d 00:00:00.000", "String presentation: Threshold #0"); | ||
a(d.toString(0, 1), "2y 2m 0d 00:00:00", "String presentation: Threshold #1"); | ||
a(d.toString(0, 2), "2y 2m 0d 00:00", "String presentation: Threshold #2"); | ||
a(d.toString(0, 3), "2y 2m 0d 00", "String presentation: Threshold #3"); | ||
@@ -582,10 +585,6 @@ a(d.toString(0, 4), "2y 2m 0d", "String presentation: Threshold #4"); | ||
a(d.toString(1), "2y 2m 0d 0h 0m 0s 0ms", "String presentation #2"); | ||
a(d.toString(1, 0), "2y 2m 0d 0h 0m 0s 0ms", | ||
"String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "2y 2m 0d 0h 0m 0s", | ||
"String presentation #2: Threshold #1"); | ||
a(d.toString(1, 2), "2y 2m 0d 0h 0m", | ||
"String presentation #2: Threshold #2"); | ||
a(d.toString(1, 3), "2y 2m 0d 0h", | ||
"String presentation #2: Threshold #3"); | ||
a(d.toString(1, 0), "2y 2m 0d 0h 0m 0s 0ms", "String presentation #2: Threshold #0"); | ||
a(d.toString(1, 1), "2y 2m 0d 0h 0m 0s", "String presentation #2: Threshold #1"); | ||
a(d.toString(1, 2), "2y 2m 0d 0h 0m", "String presentation #2: Threshold #2"); | ||
a(d.toString(1, 3), "2y 2m 0d 0h", "String presentation #2: Threshold #3"); | ||
a(d.toString(1, 4), "2y 2m 0d", "String presentation #2: Threshold #4"); | ||
@@ -595,11 +594,22 @@ a(d.toString(1, 5), "2y 2m", "String presentation #2: Threshold #5"); | ||
a(d.toString(1, 7), "2y", "String presentation #2: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .000." + (days * 24 * 60 * 60 * 1000) + ".00." + | ||
(days * 24 * 60 * 60) + ".00." + (days * 24 * 60) + ".00." + | ||
(days * 24) + ".00." + days + ".02." + 26 + ".2 ", | ||
"String presentation (custom)"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" .000." + | ||
days * 24 * 60 * 60 * 1000 + | ||
".00." + | ||
days * 24 * 60 * 60 + | ||
".00." + | ||
days * 24 * 60 + | ||
".00." + | ||
days * 24 + | ||
".00." + | ||
days + | ||
".02." + | ||
26 + | ||
".2 ", | ||
"String presentation (custom)" | ||
); | ||
d = t(d2, d1); | ||
a(d.milliseconds, -(days * 24 * 60 * 60 * 1000), | ||
"Milliseconds: Negative"); | ||
a(d.milliseconds, -(days * 24 * 60 * 60 * 1000), "Milliseconds: Negative"); | ||
a(d.valueOf(), d.milliseconds, "Value: Negative"); | ||
@@ -621,43 +631,60 @@ a(d.seconds, -(days * 24 * 60 * 60), "Seconds: Negative"); | ||
a(d.toString(), "-2y 2m 0d 00:00:00.000", | ||
"String presentation: Negative"); | ||
a(d.toString(0, 0), "-2y 2m 0d 00:00:00.000", | ||
"String presentation: Negative: Threshold #0"); | ||
a(d.toString(0, 1), "-2y 2m 0d 00:00:00", | ||
"String presentation: Negative: Threshold #1"); | ||
a(d.toString(0, 2), "-2y 2m 0d 00:00", | ||
"String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 3), "-2y 2m 0d 00", | ||
"String presentation: Negative: Threshold #3"); | ||
a(d.toString(0, 4), "-2y 2m 0d", | ||
"String presentation: Negative: Threshold #4"); | ||
a(d.toString(0, 5), "-2y 2m", | ||
"String presentation: Negative: Threshold #5"); | ||
a(d.toString(), "-2y 2m 0d 00:00:00.000", "String presentation: Negative"); | ||
a( | ||
d.toString(0, 0), "-2y 2m 0d 00:00:00.000", | ||
"String presentation: Negative: Threshold #0" | ||
); | ||
a( | ||
d.toString(0, 1), "-2y 2m 0d 00:00:00", | ||
"String presentation: Negative: Threshold #1" | ||
); | ||
a(d.toString(0, 2), "-2y 2m 0d 00:00", "String presentation: Negative: Threshold #2"); | ||
a(d.toString(0, 3), "-2y 2m 0d 00", "String presentation: Negative: Threshold #3"); | ||
a(d.toString(0, 4), "-2y 2m 0d", "String presentation: Negative: Threshold #4"); | ||
a(d.toString(0, 5), "-2y 2m", "String presentation: Negative: Threshold #5"); | ||
a(d.toString(0, 6), "-2y", "String presentation: Negative: Threshold #6"); | ||
a(d.toString(0, 7), "-2y", "String presentation: Negative: Threshold #7"); | ||
a(d.toString(1), "-2y 2m 0d 0h 0m 0s 0ms", | ||
"String presentation #2: Negative"); | ||
a(d.toString(1, 0), "-2y 2m 0d 0h 0m 0s 0ms", | ||
"String presentation #2: Negative: Threshold #0"); | ||
a(d.toString(1, 1), "-2y 2m 0d 0h 0m 0s", | ||
"String presentation #2: Negative: Threshold #1"); | ||
a(d.toString(1, 2), "-2y 2m 0d 0h 0m", | ||
"String presentation #2: Negative: Threshold #2"); | ||
a(d.toString(1, 3), "-2y 2m 0d 0h", | ||
"String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "-2y 2m 0d", | ||
"String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "-2y 2m", | ||
"String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "-2y", | ||
"String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "-2y", | ||
"String presentation #2: Negative: Threshold #7"); | ||
a(d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.000." + (days * 24 * 60 * 60 * 1000) + ".00." + | ||
(days * 24 * 60 * 60) + ".00." + (days * 24 * 60) + ".00." + | ||
(days * 24) + ".00." + days + ".02." + 26 + ".2 ", | ||
"String presentation (custom): Negative"); | ||
a(d.toString(1), "-2y 2m 0d 0h 0m 0s 0ms", "String presentation #2: Negative"); | ||
a( | ||
d.toString(1, 0), "-2y 2m 0d 0h 0m 0s 0ms", | ||
"String presentation #2: Negative: Threshold #0" | ||
); | ||
a( | ||
d.toString(1, 1), "-2y 2m 0d 0h 0m 0s", | ||
"String presentation #2: Negative: Threshold #1" | ||
); | ||
a( | ||
d.toString(1, 2), "-2y 2m 0d 0h 0m", | ||
"String presentation #2: Negative: Threshold #2" | ||
); | ||
a(d.toString(1, 3), "-2y 2m 0d 0h", "String presentation #2: Negative: Threshold #3"); | ||
a(d.toString(1, 4), "-2y 2m 0d", "String presentation #2: Negative: Threshold #4"); | ||
a(d.toString(1, 5), "-2y 2m", "String presentation #2: Negative: Threshold #5"); | ||
a(d.toString(1, 6), "-2y", "String presentation #2: Negative: Threshold #6"); | ||
a(d.toString(1, 7), "-2y", "String presentation #2: Negative: Threshold #7"); | ||
a( | ||
d.toString(" %sign.%L.%Ls.%S.%Ss.%M.%Ms.%H.%Hs.%d.%ds.%m.%ms.%y "), | ||
" -.000." + | ||
days * 24 * 60 * 60 * 1000 + | ||
".00." + | ||
days * 24 * 60 * 60 + | ||
".00." + | ||
days * 24 * 60 + | ||
".00." + | ||
days * 24 + | ||
".00." + | ||
days + | ||
".02." + | ||
26 + | ||
".2 ", | ||
"String presentation (custom): Negative" | ||
); | ||
}, | ||
"Special case": function (t, a) { | ||
var dateFrom = new Date(1540999566129); | ||
var dateTo = new Date(1577750400000); | ||
d = t(dateFrom, dateTo); | ||
a(d.day, 30); | ||
} | ||
}; | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45038
789
0
Updatedes5-ext@~0.10.46