date-vir 4.0.1 → 4.0.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.
|
@@ -25,16 +25,17 @@ function toRelativeString({ fullDate, relativeTo, options = {}, }) {
|
|
|
25
25
|
}, undefined);
|
|
26
26
|
const shouldUseJustNow = options.blockJustNow
|
|
27
27
|
? false
|
|
28
|
-
: (
|
|
28
|
+
: (0, common_1.areJsonEqual)(fullDate, relativeTo) ||
|
|
29
|
+
(unitToUse === duration_1.DurationUnit.Minutes && allUnitDiffs.minutes < 2) ||
|
|
29
30
|
(unitToUse === duration_1.DurationUnit.Seconds && allUnitDiffs.seconds < 11) ||
|
|
30
31
|
(unitToUse === duration_1.DurationUnit.Milliseconds && allUnitDiffs.milliseconds < 710);
|
|
31
32
|
/** Some short circuits. */
|
|
32
|
-
if (
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
else if (shouldUseJustNow) {
|
|
33
|
+
if (shouldUseJustNow) {
|
|
36
34
|
return 'just now';
|
|
37
35
|
}
|
|
36
|
+
else if (unitToUse == undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
38
39
|
const duration = allUnitDiffs[unitToUse];
|
|
39
40
|
const roundedAbsoluteDuration = Math.abs((0, common_1.round)({ digits: roundingDigits, number: duration }));
|
|
40
41
|
const isDurationSingular = roundedAbsoluteDuration === 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mapObjectValues, round } from '@augment-vir/common';
|
|
1
|
+
import { areJsonEqual, mapObjectValues, round } from '@augment-vir/common';
|
|
2
2
|
import { diffDatesAllUnits } from '../date-operations/diff-dates';
|
|
3
3
|
import { DurationUnit, orderedDurationUnits, singularDurationUnitNames } from '../duration';
|
|
4
4
|
export function toRelativeString({ fullDate, relativeTo, options = {}, }) {
|
|
@@ -22,16 +22,17 @@ export function toRelativeString({ fullDate, relativeTo, options = {}, }) {
|
|
|
22
22
|
}, undefined);
|
|
23
23
|
const shouldUseJustNow = options.blockJustNow
|
|
24
24
|
? false
|
|
25
|
-
: (
|
|
25
|
+
: areJsonEqual(fullDate, relativeTo) ||
|
|
26
|
+
(unitToUse === DurationUnit.Minutes && allUnitDiffs.minutes < 2) ||
|
|
26
27
|
(unitToUse === DurationUnit.Seconds && allUnitDiffs.seconds < 11) ||
|
|
27
28
|
(unitToUse === DurationUnit.Milliseconds && allUnitDiffs.milliseconds < 710);
|
|
28
29
|
/** Some short circuits. */
|
|
29
|
-
if (
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
else if (shouldUseJustNow) {
|
|
30
|
+
if (shouldUseJustNow) {
|
|
33
31
|
return 'just now';
|
|
34
32
|
}
|
|
33
|
+
else if (unitToUse == undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
35
36
|
const duration = allUnitDiffs[unitToUse];
|
|
36
37
|
const roundedAbsoluteDuration = Math.abs(round({ digits: roundingDigits, number: duration }));
|
|
37
38
|
const isDurationSingular = roundedAbsoluteDuration === 1;
|