date-vir 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,8 +23,20 @@ decimalCount) {
|
|
|
23
23
|
exports.roundDuration = roundDuration;
|
|
24
24
|
/** Convert a duration from any combination of units into a single unit. */
|
|
25
25
|
function convertDuration(inputDuration, requiredUnit) {
|
|
26
|
+
if (hasInfinity(inputDuration)) {
|
|
27
|
+
return { [requiredUnit]: Infinity };
|
|
28
|
+
}
|
|
29
|
+
else if (hasNegativeInfinity(inputDuration)) {
|
|
30
|
+
return { [requiredUnit]: -Infinity };
|
|
31
|
+
}
|
|
26
32
|
const luxonDuration = luxon_1.Duration.fromObject(inputDuration);
|
|
27
33
|
const newUnitValue = luxonDuration.as(requiredUnit);
|
|
28
34
|
return { [requiredUnit]: newUnitValue };
|
|
29
35
|
}
|
|
30
36
|
exports.convertDuration = convertDuration;
|
|
37
|
+
function hasInfinity(duration) {
|
|
38
|
+
return Object.values(duration).some((value) => value === Infinity);
|
|
39
|
+
}
|
|
40
|
+
function hasNegativeInfinity(duration) {
|
|
41
|
+
return Object.values(duration).some((value) => value === -Infinity);
|
|
42
|
+
}
|
|
@@ -19,7 +19,19 @@ decimalCount) {
|
|
|
19
19
|
}
|
|
20
20
|
/** Convert a duration from any combination of units into a single unit. */
|
|
21
21
|
export function convertDuration(inputDuration, requiredUnit) {
|
|
22
|
+
if (hasInfinity(inputDuration)) {
|
|
23
|
+
return { [requiredUnit]: Infinity };
|
|
24
|
+
}
|
|
25
|
+
else if (hasNegativeInfinity(inputDuration)) {
|
|
26
|
+
return { [requiredUnit]: -Infinity };
|
|
27
|
+
}
|
|
22
28
|
const luxonDuration = LuxonDuration.fromObject(inputDuration);
|
|
23
29
|
const newUnitValue = luxonDuration.as(requiredUnit);
|
|
24
30
|
return { [requiredUnit]: newUnitValue };
|
|
25
31
|
}
|
|
32
|
+
function hasInfinity(duration) {
|
|
33
|
+
return Object.values(duration).some((value) => value === Infinity);
|
|
34
|
+
}
|
|
35
|
+
function hasNegativeInfinity(duration) {
|
|
36
|
+
return Object.values(duration).some((value) => value === -Infinity);
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-vir",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "Easy and explicit dates and times",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"test:watch": "web-test-runner --watch --color --config configs/web-test-runner.config.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@augment-vir/common": "^
|
|
45
|
-
"@types/luxon": "^3.4.
|
|
44
|
+
"@augment-vir/common": "^23.0.0",
|
|
45
|
+
"@types/luxon": "^3.4.2",
|
|
46
46
|
"luxon": "^3.4.4",
|
|
47
|
-
"object-shape-tester": "^1.0
|
|
47
|
+
"object-shape-tester": "^2.1.0",
|
|
48
48
|
"type-fest": "^4.9.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@augment-vir/browser": "^
|
|
52
|
-
"@augment-vir/browser-testing": "^
|
|
51
|
+
"@augment-vir/browser": "^23.0.0",
|
|
52
|
+
"@augment-vir/browser-testing": "^23.0.0",
|
|
53
53
|
"@open-wc/testing": "^4.0.0",
|
|
54
54
|
"@types/chai": "^4.3.11",
|
|
55
55
|
"@types/mocha": "^10.0.6",
|