date-vir 5.3.1 → 6.0.1
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.
- package/LICENSE-MIT +1 -1
- package/README.md +28 -28
- package/dist/date-operations/calculate-relative-date.d.ts +17 -0
- package/dist/{esm/date-operations → date-operations}/calculate-relative-date.js +10 -1
- package/dist/date-operations/combine-dates.d.ts +43 -0
- package/dist/{esm/date-operations → date-operations}/combine-dates.js +6 -4
- package/dist/date-operations/diff-dates.d.ts +95 -0
- package/dist/date-operations/diff-dates.js +124 -0
- package/dist/extra-utils/has-date-props.d.ts +35 -0
- package/dist/extra-utils/has-date-props.js +46 -0
- package/dist/extra-utils/js-date-conversion.d.ts +26 -0
- package/dist/extra-utils/js-date-conversion.js +28 -0
- package/dist/extra-utils/now.d.ts +56 -0
- package/dist/extra-utils/now.js +68 -0
- package/dist/extra-utils/override-date.d.ts +27 -0
- package/dist/extra-utils/override-date.js +27 -0
- package/dist/extra-utils/zero.d.ts +99 -0
- package/dist/extra-utils/zero.js +94 -0
- package/dist/formatting/formatted-string.d.ts +58 -0
- package/dist/formatting/formatted-string.js +73 -0
- package/dist/formatting/html-input.d.ts +30 -0
- package/dist/formatting/html-input.js +47 -0
- package/dist/formatting/relative-string.d.ts +53 -0
- package/dist/formatting/relative-string.js +93 -0
- package/dist/formatting/simple-strings.d.ts +187 -0
- package/dist/formatting/simple-strings.js +120 -0
- package/dist/formatting/string-format-types.d.ts +59 -0
- package/dist/formatting/string-format-types.js +19 -0
- package/dist/formatting/timestamp.d.ts +51 -0
- package/dist/formatting/timestamp.js +61 -0
- package/dist/full-date/create-full-date.d.ts +91 -0
- package/dist/full-date/create-full-date.js +142 -0
- package/dist/full-date/date-like.d.ts +9 -0
- package/dist/{esm/full-date → full-date}/format-presets.d.ts +4 -2
- package/dist/{esm/full-date → full-date}/format-presets.js +4 -2
- package/dist/full-date/full-date-parts.d.ts +48 -0
- package/dist/full-date/full-date-parts.js +45 -0
- package/dist/full-date/full-date-shape.d.ts +106 -0
- package/dist/{esm/full-date → full-date}/full-date-shape.js +15 -22
- package/dist/full-date/is-valid-full-date.d.ts +21 -0
- package/dist/full-date/is-valid-full-date.js +38 -0
- package/dist/full-date/luxon-date-time-conversion.d.ts +19 -0
- package/dist/{esm/full-date → full-date}/luxon-date-time-conversion.js +10 -6
- package/dist/full-date/parsing.d.ts +33 -0
- package/dist/full-date/parsing.js +47 -0
- package/dist/full-date/string-parsing.d.ts +9 -0
- package/dist/{esm/full-date → full-date}/string-parsing.js +6 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +27 -0
- package/dist/locales.d.ts +6 -0
- package/dist/locales.js +7 -0
- package/dist/timezone/timezone-checks.d.ts +21 -0
- package/dist/timezone/timezone-checks.js +34 -0
- package/dist/{esm/timezone → timezone}/timezone-names.d.ts +11 -5
- package/dist/{esm/timezone → timezone}/timezone-names.js +11 -3
- package/dist/timezone/timezones.d.ts +42 -0
- package/dist/timezone/timezones.js +31 -0
- package/package.json +30 -48
- package/cspell.config.cjs +0 -13
- package/dist/cjs/date-operations/calculate-relative-date.js +0 -12
- package/dist/cjs/date-operations/combine-dates.js +0 -50
- package/dist/cjs/date-operations/diff-dates.js +0 -105
- package/dist/cjs/duration/duration-unit.js +0 -41
- package/dist/cjs/duration/duration-utils.js +0 -42
- package/dist/cjs/duration/duration.js +0 -2
- package/dist/cjs/extra-utils/date-transforms.js +0 -8
- package/dist/cjs/extra-utils/has-date-props.js +0 -25
- package/dist/cjs/extra-utils/js-date-conversion.js +0 -8
- package/dist/cjs/extra-utils/now.js +0 -22
- package/dist/cjs/extra-utils/zero.js +0 -31
- package/dist/cjs/formatting/formatted-string.js +0 -34
- package/dist/cjs/formatting/html-input.js +0 -37
- package/dist/cjs/formatting/relative-string.js +0 -77
- package/dist/cjs/formatting/simple-strings.js +0 -58
- package/dist/cjs/formatting/string-format-types.js +0 -9
- package/dist/cjs/formatting/timestamp.js +0 -21
- package/dist/cjs/full-date/create-full-date.js +0 -81
- package/dist/cjs/full-date/date-like.js +0 -2
- package/dist/cjs/full-date/format-presets.js +0 -32
- package/dist/cjs/full-date/full-date-shape.js +0 -54
- package/dist/cjs/full-date/is-valid-full-date.js +0 -28
- package/dist/cjs/full-date/luxon-date-time-conversion.js +0 -43
- package/dist/cjs/full-date/parsing.js +0 -48
- package/dist/cjs/full-date/string-parsing.js +0 -33
- package/dist/cjs/index.js +0 -44
- package/dist/cjs/locales.js +0 -5
- package/dist/cjs/timezone/timezone-checks.js +0 -34
- package/dist/cjs/timezone/timezone-names.js +0 -479
- package/dist/cjs/timezone/timezones.js +0 -14
- package/dist/esm/date-operations/calculate-relative-date.d.ts +0 -8
- package/dist/esm/date-operations/combine-dates.d.ts +0 -35
- package/dist/esm/date-operations/diff-dates.d.ts +0 -66
- package/dist/esm/date-operations/diff-dates.js +0 -100
- package/dist/esm/duration/duration-unit.d.ts +0 -27
- package/dist/esm/duration/duration-unit.js +0 -38
- package/dist/esm/duration/duration-utils.d.ts +0 -11
- package/dist/esm/duration/duration-utils.js +0 -37
- package/dist/esm/duration/duration.d.ts +0 -32
- package/dist/esm/duration/duration.js +0 -1
- package/dist/esm/extra-utils/date-transforms.d.ts +0 -4
- package/dist/esm/extra-utils/date-transforms.js +0 -4
- package/dist/esm/extra-utils/has-date-props.d.ts +0 -9
- package/dist/esm/extra-utils/has-date-props.js +0 -20
- package/dist/esm/extra-utils/js-date-conversion.d.ts +0 -2
- package/dist/esm/extra-utils/js-date-conversion.js +0 -4
- package/dist/esm/extra-utils/now.d.ts +0 -5
- package/dist/esm/extra-utils/now.js +0 -16
- package/dist/esm/extra-utils/zero.d.ts +0 -31
- package/dist/esm/extra-utils/zero.js +0 -26
- package/dist/esm/formatting/formatted-string.d.ts +0 -14
- package/dist/esm/formatting/formatted-string.js +0 -29
- package/dist/esm/formatting/html-input.d.ts +0 -19
- package/dist/esm/formatting/html-input.js +0 -33
- package/dist/esm/formatting/relative-string.d.ts +0 -31
- package/dist/esm/formatting/relative-string.js +0 -73
- package/dist/esm/formatting/simple-strings.d.ts +0 -71
- package/dist/esm/formatting/simple-strings.js +0 -51
- package/dist/esm/formatting/string-format-types.d.ts +0 -7
- package/dist/esm/formatting/string-format-types.js +0 -5
- package/dist/esm/formatting/timestamp.d.ts +0 -6
- package/dist/esm/formatting/timestamp.js +0 -16
- package/dist/esm/full-date/create-full-date.d.ts +0 -21
- package/dist/esm/full-date/create-full-date.js +0 -73
- package/dist/esm/full-date/date-like.d.ts +0 -5
- package/dist/esm/full-date/full-date-shape.d.ts +0 -80
- package/dist/esm/full-date/is-valid-full-date.d.ts +0 -5
- package/dist/esm/full-date/is-valid-full-date.js +0 -22
- package/dist/esm/full-date/luxon-date-time-conversion.d.ts +0 -15
- package/dist/esm/full-date/parsing.d.ts +0 -27
- package/dist/esm/full-date/parsing.js +0 -43
- package/dist/esm/full-date/string-parsing.d.ts +0 -3
- package/dist/esm/index.d.ts +0 -28
- package/dist/esm/index.js +0 -28
- package/dist/esm/locales.d.ts +0 -1
- package/dist/esm/locales.js +0 -2
- package/dist/esm/timezone/timezone-checks.d.ts +0 -17
- package/dist/esm/timezone/timezone-checks.js +0 -29
- package/dist/esm/timezone/timezones.d.ts +0 -480
- package/dist/esm/timezone/timezones.js +0 -11
- package/public/index.css +0 -7
- /package/dist/{esm/full-date → full-date}/date-like.js +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { DatePart, FullDate, FullDatePartEnum, TimePart } from '../full-date/full-date-shape';
|
|
2
|
-
import { Timezone } from '../timezone/timezone-names';
|
|
3
|
-
/** An object containing date and/or time parts or neither. */
|
|
4
|
-
type MaybeDateParts<SpecificTimezone extends Timezone> = Partial<{
|
|
5
|
-
[FullDatePartEnum.Date]: DatePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
|
|
6
|
-
[FullDatePartEnum.Time]: TimePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
|
|
7
|
-
}>;
|
|
8
|
-
/** A full date, time or date parts of a date, or undefined. */
|
|
9
|
-
export type MaybeDatePart<SpecificTimezone extends Timezone> = FullDate<SpecificTimezone> | Partial<FullDate<SpecificTimezone>> | DatePart<SpecificTimezone> | TimePart<SpecificTimezone> | undefined;
|
|
10
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
11
|
-
[FullDatePartEnum.Date]: DatePart<SpecificTimezone>;
|
|
12
|
-
[FullDatePartEnum.Time]: TimePart<SpecificTimezone>;
|
|
13
|
-
}): FullDate<SpecificTimezone>;
|
|
14
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
15
|
-
[FullDatePartEnum.Date]?: undefined;
|
|
16
|
-
[FullDatePartEnum.Time]?: undefined;
|
|
17
|
-
}): undefined;
|
|
18
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
19
|
-
[FullDatePartEnum.Date]: DatePart<SpecificTimezone>;
|
|
20
|
-
[FullDatePartEnum.Time]?: undefined;
|
|
21
|
-
}): DatePart<SpecificTimezone>;
|
|
22
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
23
|
-
[FullDatePartEnum.Date]: DatePart<SpecificTimezone>;
|
|
24
|
-
[FullDatePartEnum.Time]?: TimePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
|
|
25
|
-
}): FullDate<SpecificTimezone> | DatePart<SpecificTimezone>;
|
|
26
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
27
|
-
[FullDatePartEnum.Date]?: undefined;
|
|
28
|
-
[FullDatePartEnum.Time]: TimePart<SpecificTimezone>;
|
|
29
|
-
}): TimePart<SpecificTimezone>;
|
|
30
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
|
|
31
|
-
[FullDatePartEnum.Date]?: DatePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
|
|
32
|
-
[FullDatePartEnum.Time]: TimePart<SpecificTimezone>;
|
|
33
|
-
}): FullDate<SpecificTimezone> | TimePart<SpecificTimezone>;
|
|
34
|
-
export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: MaybeDateParts<SpecificTimezone>): MaybeDatePart<SpecificTimezone>;
|
|
35
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ArrayElement } from '@augment-vir/common';
|
|
2
|
-
import { Duration } from '../duration/duration';
|
|
3
|
-
import { DurationUnit } from '../duration/duration-unit';
|
|
4
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
5
|
-
export declare enum DiffType {
|
|
6
|
-
/**
|
|
7
|
-
* Causes the diffDates function to output the diff split between each unit provided. To get the
|
|
8
|
-
* full duration, each output unit needs to be added together.
|
|
9
|
-
*/
|
|
10
|
-
AdditiveUnits = "additive-units",
|
|
11
|
-
/**
|
|
12
|
-
* Causes the diffDates function to output the diff in each unit provided with each unit being
|
|
13
|
-
* equivalent in value. Meaning, each unit will be the same duration of time converted into that
|
|
14
|
-
* unit.
|
|
15
|
-
*/
|
|
16
|
-
EquivalentUnits = "equivalent-units"
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Diffs two dates and returns the diff in the specific unit.
|
|
20
|
-
*
|
|
21
|
-
* Note: when years, quarters, or months are used for the unit then "long term" durations are used
|
|
22
|
-
* to calculate the diff. See more details here:
|
|
23
|
-
* https://moment.github.io/luxon/#/math?id=casual-vs-longterm-conversion-accuracy
|
|
24
|
-
*/
|
|
25
|
-
export declare function diffDates<const ChosenDurationUnits extends DurationUnit>(params: {
|
|
26
|
-
start: Readonly<FullDate>;
|
|
27
|
-
end: Readonly<FullDate>;
|
|
28
|
-
/** The unit which the output should contain. */
|
|
29
|
-
unit: ChosenDurationUnits;
|
|
30
|
-
/**
|
|
31
|
-
* Determine the diff type calculation. See DiffType values for explanations on each one.
|
|
32
|
-
* Optional when only one unit is provided, as the diffType will not change the output either
|
|
33
|
-
* way.
|
|
34
|
-
*/
|
|
35
|
-
diffType?: DiffType | undefined;
|
|
36
|
-
/** How many decimals to round the outputs to. Leave undefined to skip rounding entirely. */
|
|
37
|
-
decimalCount?: number | undefined;
|
|
38
|
-
}): Duration<ChosenDurationUnits>;
|
|
39
|
-
export declare function diffDates<const ChosenDurationUnits extends Readonly<[DurationUnit]>>(params: {
|
|
40
|
-
start: Readonly<FullDate>;
|
|
41
|
-
end: Readonly<FullDate>;
|
|
42
|
-
/** Which units the output should contain. */
|
|
43
|
-
units: ChosenDurationUnits;
|
|
44
|
-
/**
|
|
45
|
-
* Determine the diff type calculation. See DiffType values for explanations on each one.
|
|
46
|
-
* Optional when only one unit is provided, as the diffType will not change the output either
|
|
47
|
-
* way.
|
|
48
|
-
*/
|
|
49
|
-
diffType?: DiffType | undefined;
|
|
50
|
-
/** How many decimals to round the outputs to. Leave undefined to skip rounding entirely. */
|
|
51
|
-
decimalCount?: number | undefined;
|
|
52
|
-
}): Duration<ArrayElement<ChosenDurationUnits>>;
|
|
53
|
-
export declare function diffDates<const ChosenDurationUnits extends ReadonlyArray<DurationUnit>>(params: {
|
|
54
|
-
start: Readonly<FullDate>;
|
|
55
|
-
end: Readonly<FullDate>;
|
|
56
|
-
/** Which units the output should contain. */
|
|
57
|
-
units: ChosenDurationUnits;
|
|
58
|
-
/** Determine the diff type calculation. See DiffType values for explanations on each one. */
|
|
59
|
-
diffType: DiffType;
|
|
60
|
-
/** How many decimals to round the outputs to. Leave undefined to skip rounding entirely. */
|
|
61
|
-
decimalCount?: number | undefined;
|
|
62
|
-
}): Duration<ArrayElement<ChosenDurationUnits>>;
|
|
63
|
-
export declare function isDateAfter({ relativeTo, fullDate, }: {
|
|
64
|
-
relativeTo: Readonly<FullDate>;
|
|
65
|
-
fullDate: Readonly<FullDate>;
|
|
66
|
-
}): boolean;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { makeWritable, typedObjectFromEntries } from '@augment-vir/common';
|
|
2
|
-
import { DurationUnit } from '../duration/duration-unit';
|
|
3
|
-
import { roundDuration } from '../duration/duration-utils';
|
|
4
|
-
import { toLuxonDateTime } from '../full-date/luxon-date-time-conversion';
|
|
5
|
-
const accuracyPriority = {
|
|
6
|
-
longterm: 1,
|
|
7
|
-
casual: 0,
|
|
8
|
-
};
|
|
9
|
-
const conversionAccuracies = {
|
|
10
|
-
[DurationUnit.Years]: 'longterm',
|
|
11
|
-
[DurationUnit.Quarters]: 'longterm',
|
|
12
|
-
[DurationUnit.Months]: 'longterm',
|
|
13
|
-
[DurationUnit.Weeks]: 'casual',
|
|
14
|
-
[DurationUnit.Days]: 'casual',
|
|
15
|
-
[DurationUnit.Hours]: 'casual',
|
|
16
|
-
[DurationUnit.Minutes]: 'casual',
|
|
17
|
-
[DurationUnit.Seconds]: 'casual',
|
|
18
|
-
[DurationUnit.Milliseconds]: 'casual',
|
|
19
|
-
};
|
|
20
|
-
function getHighestPriorityConversionAccuracy(units) {
|
|
21
|
-
const currentConversionAccuracies = units.map((unit) => conversionAccuracies[unit]);
|
|
22
|
-
const highestPriorityAccuracy = currentConversionAccuracies.reduce((priorityAccuracy, currentAccuracy) => {
|
|
23
|
-
if (accuracyPriority[currentAccuracy] > accuracyPriority[priorityAccuracy]) {
|
|
24
|
-
return currentAccuracy;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return priorityAccuracy;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return highestPriorityAccuracy;
|
|
31
|
-
}
|
|
32
|
-
export var DiffType;
|
|
33
|
-
(function (DiffType) {
|
|
34
|
-
/**
|
|
35
|
-
* Causes the diffDates function to output the diff split between each unit provided. To get the
|
|
36
|
-
* full duration, each output unit needs to be added together.
|
|
37
|
-
*/
|
|
38
|
-
DiffType["AdditiveUnits"] = "additive-units";
|
|
39
|
-
/**
|
|
40
|
-
* Causes the diffDates function to output the diff in each unit provided with each unit being
|
|
41
|
-
* equivalent in value. Meaning, each unit will be the same duration of time converted into that
|
|
42
|
-
* unit.
|
|
43
|
-
*/
|
|
44
|
-
DiffType["EquivalentUnits"] = "equivalent-units";
|
|
45
|
-
})(DiffType || (DiffType = {}));
|
|
46
|
-
export function diffDates({ start, end, units: unitsInput, unit: unitInput, diffType: diffTypeInput, decimalCount, }) {
|
|
47
|
-
const luxonDateStart = toLuxonDateTime(start);
|
|
48
|
-
const luxonDateEnd = toLuxonDateTime(end);
|
|
49
|
-
const units = (unitsInput ?? [unitInput]);
|
|
50
|
-
const diffType = units.length === 1
|
|
51
|
-
? /**
|
|
52
|
-
* When only one unit is provided, it doesn't matter which diff type we use so lets just use this
|
|
53
|
-
* one.
|
|
54
|
-
*/
|
|
55
|
-
DiffType.EquivalentUnits
|
|
56
|
-
: diffTypeInput;
|
|
57
|
-
if (!diffType) {
|
|
58
|
-
throw new Error('Failed to diff dates: no diffType was provided.');
|
|
59
|
-
}
|
|
60
|
-
if (diffType === DiffType.AdditiveUnits) {
|
|
61
|
-
const conversionAccuracy = getHighestPriorityConversionAccuracy(units);
|
|
62
|
-
const additiveDiff = luxonDateEnd
|
|
63
|
-
.diff(luxonDateStart, makeWritable(units), {
|
|
64
|
-
conversionAccuracy,
|
|
65
|
-
})
|
|
66
|
-
.toObject();
|
|
67
|
-
return roundDuration(additiveDiff, decimalCount);
|
|
68
|
-
}
|
|
69
|
-
else if (diffType === DiffType.EquivalentUnits) {
|
|
70
|
-
const allUnitDiffEntries = units.map((durationUnit) => {
|
|
71
|
-
const diff = luxonDateEnd
|
|
72
|
-
.diff(luxonDateStart, durationUnit, {
|
|
73
|
-
conversionAccuracy: conversionAccuracies[durationUnit],
|
|
74
|
-
})
|
|
75
|
-
.toObject();
|
|
76
|
-
const duration = diff[durationUnit];
|
|
77
|
-
/** Ignore this edge case in coverage cause its for type guarding. */
|
|
78
|
-
/* c8 ignore next 5 */
|
|
79
|
-
if (duration == undefined) {
|
|
80
|
-
throw new Error(`Internal date-vir error: failed to find duration for '${durationUnit}'`);
|
|
81
|
-
}
|
|
82
|
-
return [
|
|
83
|
-
durationUnit,
|
|
84
|
-
duration,
|
|
85
|
-
];
|
|
86
|
-
});
|
|
87
|
-
const equivalentDiff = typedObjectFromEntries(allUnitDiffEntries);
|
|
88
|
-
return roundDuration(equivalentDiff, decimalCount);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
throw new Error(`Failed to diff dates: provided diffType is invalid: '${diffType}'`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export function isDateAfter({ relativeTo, fullDate, }) {
|
|
95
|
-
return (diffDates({
|
|
96
|
-
start: relativeTo,
|
|
97
|
-
end: fullDate,
|
|
98
|
-
unit: DurationUnit.Milliseconds,
|
|
99
|
-
}).milliseconds >= 0);
|
|
100
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare enum DurationUnit {
|
|
2
|
-
Years = "years",
|
|
3
|
-
Quarters = "quarters",
|
|
4
|
-
Months = "months",
|
|
5
|
-
Weeks = "weeks",
|
|
6
|
-
Days = "days",
|
|
7
|
-
Hours = "hours",
|
|
8
|
-
Minutes = "minutes",
|
|
9
|
-
Seconds = "seconds",
|
|
10
|
-
Milliseconds = "milliseconds"
|
|
11
|
-
}
|
|
12
|
-
export declare const singularDurationUnitNames: {
|
|
13
|
-
readonly milliseconds: "millisecond";
|
|
14
|
-
readonly seconds: "second";
|
|
15
|
-
readonly minutes: "minute";
|
|
16
|
-
readonly hours: "hour";
|
|
17
|
-
readonly days: "day";
|
|
18
|
-
readonly weeks: "week";
|
|
19
|
-
readonly months: "month";
|
|
20
|
-
readonly quarters: "quarter";
|
|
21
|
-
readonly years: "year";
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Array of DurationUnit values: from smallest unit (milliseconds at index 0) to longest unit
|
|
25
|
-
* (years).
|
|
26
|
-
*/
|
|
27
|
-
export declare const orderedDurationUnits: readonly [DurationUnit.Milliseconds, DurationUnit.Seconds, DurationUnit.Minutes, DurationUnit.Hours, DurationUnit.Days, DurationUnit.Weeks, DurationUnit.Months, DurationUnit.Quarters, DurationUnit.Years];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export var DurationUnit;
|
|
2
|
-
(function (DurationUnit) {
|
|
3
|
-
DurationUnit["Years"] = "years";
|
|
4
|
-
DurationUnit["Quarters"] = "quarters";
|
|
5
|
-
DurationUnit["Months"] = "months";
|
|
6
|
-
DurationUnit["Weeks"] = "weeks";
|
|
7
|
-
DurationUnit["Days"] = "days";
|
|
8
|
-
DurationUnit["Hours"] = "hours";
|
|
9
|
-
DurationUnit["Minutes"] = "minutes";
|
|
10
|
-
DurationUnit["Seconds"] = "seconds";
|
|
11
|
-
DurationUnit["Milliseconds"] = "milliseconds";
|
|
12
|
-
})(DurationUnit || (DurationUnit = {}));
|
|
13
|
-
export const singularDurationUnitNames = {
|
|
14
|
-
[DurationUnit.Milliseconds]: 'millisecond',
|
|
15
|
-
[DurationUnit.Seconds]: 'second',
|
|
16
|
-
[DurationUnit.Minutes]: 'minute',
|
|
17
|
-
[DurationUnit.Hours]: 'hour',
|
|
18
|
-
[DurationUnit.Days]: 'day',
|
|
19
|
-
[DurationUnit.Weeks]: 'week',
|
|
20
|
-
[DurationUnit.Months]: 'month',
|
|
21
|
-
[DurationUnit.Quarters]: 'quarter',
|
|
22
|
-
[DurationUnit.Years]: 'year',
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Array of DurationUnit values: from smallest unit (milliseconds at index 0) to longest unit
|
|
26
|
-
* (years).
|
|
27
|
-
*/
|
|
28
|
-
export const orderedDurationUnits = [
|
|
29
|
-
DurationUnit.Milliseconds,
|
|
30
|
-
DurationUnit.Seconds,
|
|
31
|
-
DurationUnit.Minutes,
|
|
32
|
-
DurationUnit.Hours,
|
|
33
|
-
DurationUnit.Days,
|
|
34
|
-
DurationUnit.Weeks,
|
|
35
|
-
DurationUnit.Months,
|
|
36
|
-
DurationUnit.Quarters,
|
|
37
|
-
DurationUnit.Years,
|
|
38
|
-
];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AnyDuration, Duration } from './duration';
|
|
2
|
-
import { DurationUnit } from './duration-unit';
|
|
3
|
-
/** Round every unit in a given duration to the given number of decimal points. */
|
|
4
|
-
export declare function roundDuration<InputDuration extends AnyDuration>(duration: Readonly<InputDuration>,
|
|
5
|
-
/**
|
|
6
|
-
* How many decimals to round to. Leave undefined to skip rounding. (Though if you skip
|
|
7
|
-
* rounding, why are you using this function?)
|
|
8
|
-
*/
|
|
9
|
-
decimalCount: number | undefined): InputDuration;
|
|
10
|
-
/** Convert a duration from any combination of units into a single unit. */
|
|
11
|
-
export declare function convertDuration<RequiredDurationUnit extends DurationUnit>(inputDuration: AnyDuration, requiredUnit: RequiredDurationUnit): Duration<RequiredDurationUnit>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { mapObjectValues, round } from '@augment-vir/common';
|
|
2
|
-
import { Duration as LuxonDuration } from 'luxon';
|
|
3
|
-
import { isRunTimeType } from 'run-time-assertions';
|
|
4
|
-
/** Round every unit in a given duration to the given number of decimal points. */
|
|
5
|
-
export function roundDuration(duration,
|
|
6
|
-
/**
|
|
7
|
-
* How many decimals to round to. Leave undefined to skip rounding. (Though if you skip
|
|
8
|
-
* rounding, why are you using this function?)
|
|
9
|
-
*/
|
|
10
|
-
decimalCount) {
|
|
11
|
-
return mapObjectValues(duration, (key, value) => {
|
|
12
|
-
if (decimalCount == undefined || !isRunTimeType(value, 'number')) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return round({ number: value, digits: decimalCount });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/** Convert a duration from any combination of units into a single unit. */
|
|
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
|
-
}
|
|
28
|
-
const luxonDuration = LuxonDuration.fromObject(inputDuration);
|
|
29
|
-
const newUnitValue = luxonDuration.as(requiredUnit);
|
|
30
|
-
return { [requiredUnit]: newUnitValue };
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { RequiredAndNotNull } from '@augment-vir/common';
|
|
2
|
-
import { IsUnknown, RequireAtLeastOne, UnionToIntersection } from 'type-fest';
|
|
3
|
-
import { DurationUnit } from './duration-unit';
|
|
4
|
-
/**
|
|
5
|
-
* All possible options for the more strict Duration type. Matches the DurationObjectUnits type from
|
|
6
|
-
* the luxon package.
|
|
7
|
-
*/
|
|
8
|
-
export type AnyDuration = {
|
|
9
|
-
years?: number | undefined;
|
|
10
|
-
quarters?: number | undefined;
|
|
11
|
-
months?: number | undefined;
|
|
12
|
-
weeks?: number | undefined;
|
|
13
|
-
days?: number | undefined;
|
|
14
|
-
hours?: number | undefined;
|
|
15
|
-
minutes?: number | undefined;
|
|
16
|
-
seconds?: number | undefined;
|
|
17
|
-
milliseconds?: number | undefined;
|
|
18
|
-
};
|
|
19
|
-
/** Requires at least one duration unit to be set. */
|
|
20
|
-
export type AtLeastOneDuration = RequireAtLeastOne<RequiredAndNotNull<AnyDuration>>;
|
|
21
|
-
/**
|
|
22
|
-
* All possible duration units at once. Whether these duration units should be added together to
|
|
23
|
-
* form the whole picture or whether each duration is the same value but calculated in different
|
|
24
|
-
* units depends on the context of this type's usage.
|
|
25
|
-
*/
|
|
26
|
-
export type AllDurations = RequiredAndNotNull<AnyDuration>;
|
|
27
|
-
/**
|
|
28
|
-
* Not a single date instance, but a description of a date duration. Used to calculate diffs between
|
|
29
|
-
* dates, or add offsets to an existing date, or describe a single time duration. Usually only one
|
|
30
|
-
* property is set on this at any given time.
|
|
31
|
-
*/
|
|
32
|
-
export type Duration<DurationKeys extends DurationUnit | unknown> = UnionToIntersection<IsUnknown<DurationKeys> extends true ? AnyDuration : DurationKeys extends DurationUnit ? Pick<AllDurations, `${DurationKeys}`> : never>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
2
|
-
import { Timezone } from '../timezone/timezone-names';
|
|
3
|
-
/** Override the initial provided FullDate with all subsequent FullDate parts. */
|
|
4
|
-
export declare function overrideDateParts<const SpecificTimezone extends Timezone>(date: FullDate<SpecificTimezone>, ...overrides: Partial<FullDate<SpecificTimezone>>[]): FullDate<SpecificTimezone>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PartialAndUndefined, RequiredAndNotNullBy } from '@augment-vir/common';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
3
|
-
import { Timezone } from '../timezone/timezone-names';
|
|
4
|
-
export declare function hasDateProps<SpecificTimezone extends Timezone, PartialFullDate extends PartialAndUndefined<FullDate<SpecificTimezone>>,
|
|
5
|
-
/** A union of strings. */
|
|
6
|
-
RequiredKeysUnion extends keyof FullDate<SpecificTimezone>>(dateInput: PartialAndUndefined<FullDate<SpecificTimezone>>, keys: ReadonlyArray<RequiredKeysUnion>): dateInput is RequiredAndNotNullBy<PartialFullDate, RequiredKeysUnion>;
|
|
7
|
-
export declare function assertHasDateProps<SpecificTimezone extends Timezone, PartialFullDate extends PartialAndUndefined<FullDate<SpecificTimezone>>,
|
|
8
|
-
/** A union of strings. */
|
|
9
|
-
RequiredKeysUnion extends keyof FullDate<SpecificTimezone>>(dateInput: PartialAndUndefined<FullDate<SpecificTimezone>>, keys: ReadonlyArray<RequiredKeysUnion>): asserts dateInput is RequiredAndNotNullBy<PartialFullDate, RequiredKeysUnion>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function hasDateProps(dateInput, keys) {
|
|
2
|
-
try {
|
|
3
|
-
assertHasDateProps(dateInput, keys);
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
6
|
-
catch (error) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function assertHasDateProps(dateInput, keys) {
|
|
11
|
-
const missingKeys = [];
|
|
12
|
-
keys.forEach((key) => {
|
|
13
|
-
if (dateInput[key] == undefined) {
|
|
14
|
-
missingKeys.push(key);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (missingKeys.length) {
|
|
18
|
-
throw new Error(`Missing required FullDate key(s): ${missingKeys.join(', ')}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { UtcIsoString } from '../formatting/string-format-types';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
3
|
-
export declare function getNowInIsoString(): UtcIsoString;
|
|
4
|
-
export declare function getNowInUserTimezone(): FullDate;
|
|
5
|
-
export declare function getNowInUtcTimezone(): FullDate;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { toIsoString } from '../formatting/timestamp';
|
|
2
|
-
import { getNowFullDate } from '../full-date/create-full-date';
|
|
3
|
-
import { userTimezone, utcTimezone } from '../timezone/timezones';
|
|
4
|
-
export function getNowInIsoString() {
|
|
5
|
-
/**
|
|
6
|
-
* The time zone doesn't matter here because the ISO string will be identical for a given date
|
|
7
|
-
* no matter what its timezone is.
|
|
8
|
-
*/
|
|
9
|
-
return toIsoString(getNowFullDate(utcTimezone));
|
|
10
|
-
}
|
|
11
|
-
export function getNowInUserTimezone() {
|
|
12
|
-
return getNowFullDate(userTimezone);
|
|
13
|
-
}
|
|
14
|
-
export function getNowInUtcTimezone() {
|
|
15
|
-
return getNowFullDate(utcTimezone);
|
|
16
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
2
|
-
import { Timezone } from '../timezone/timezone-names';
|
|
3
|
-
export declare const zeroDate: {
|
|
4
|
-
readonly year: 0;
|
|
5
|
-
readonly month: 1;
|
|
6
|
-
readonly day: 1;
|
|
7
|
-
readonly hour: 0;
|
|
8
|
-
readonly minute: 0;
|
|
9
|
-
readonly second: 0;
|
|
10
|
-
readonly millisecond: 0;
|
|
11
|
-
};
|
|
12
|
-
export declare const emptyDate: {
|
|
13
|
-
readonly year: 0;
|
|
14
|
-
readonly month: 1;
|
|
15
|
-
readonly day: 1;
|
|
16
|
-
readonly hour: 0;
|
|
17
|
-
readonly minute: 0;
|
|
18
|
-
readonly second: 0;
|
|
19
|
-
readonly millisecond: 0;
|
|
20
|
-
};
|
|
21
|
-
export declare const zeroTime: Pick<{
|
|
22
|
-
year: 0;
|
|
23
|
-
month: 1;
|
|
24
|
-
day: 1;
|
|
25
|
-
hour: 0;
|
|
26
|
-
minute: 0;
|
|
27
|
-
second: 0;
|
|
28
|
-
millisecond: 0;
|
|
29
|
-
}, "millisecond" | "second" | "minute" | "hour">;
|
|
30
|
-
export declare function clearTime<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>): FullDate<SpecificTimezone>;
|
|
31
|
-
export declare function clearParts<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>, parts: ReadonlyArray<Exclude<keyof FullDate, 'timezone'>>): FullDate<SpecificTimezone>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { pickObjectKeys, typedObjectFromEntries } from '@augment-vir/common';
|
|
2
|
-
import { timeFullDateKeys } from '../full-date/full-date-shape';
|
|
3
|
-
import { overrideDateParts } from './date-transforms';
|
|
4
|
-
export const zeroDate = {
|
|
5
|
-
year: 0,
|
|
6
|
-
month: 1,
|
|
7
|
-
day: 1,
|
|
8
|
-
hour: 0,
|
|
9
|
-
minute: 0,
|
|
10
|
-
second: 0,
|
|
11
|
-
millisecond: 0,
|
|
12
|
-
};
|
|
13
|
-
export const emptyDate = zeroDate;
|
|
14
|
-
export const zeroTime = pickObjectKeys(zeroDate, timeFullDateKeys);
|
|
15
|
-
export function clearTime(inputFullDate) {
|
|
16
|
-
return clearParts(inputFullDate, timeFullDateKeys);
|
|
17
|
-
}
|
|
18
|
-
export function clearParts(inputFullDate, parts) {
|
|
19
|
-
const clearParts = typedObjectFromEntries(parts.map((keyName) => {
|
|
20
|
-
return [
|
|
21
|
-
keyName,
|
|
22
|
-
zeroDate[keyName],
|
|
23
|
-
];
|
|
24
|
-
}));
|
|
25
|
-
return overrideDateParts(inputFullDate, clearParts);
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PartialAndUndefined } from '@augment-vir/common';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
3
|
-
/** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
|
|
4
|
-
export declare function toLocaleString(fullDate: FullDate, formatOptions?: (Intl.DateTimeFormatOptions & PartialAndUndefined<{
|
|
5
|
-
locale: string;
|
|
6
|
-
}>) | undefined): string;
|
|
7
|
-
/**
|
|
8
|
-
* Provides arbitrary date formatting using Luxon. For full details on the options for the format
|
|
9
|
-
* string input, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens
|
|
10
|
-
*
|
|
11
|
-
* You probably should **prefer toLocaleString** so your users see the format they expect. It
|
|
12
|
-
* already has many formatting options.
|
|
13
|
-
*/
|
|
14
|
-
export declare function toFormattedString(fullDate: FullDate, format: string, localeOverride?: string): string;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { toLuxonDateTime } from '../full-date/luxon-date-time-conversion';
|
|
2
|
-
import { userLocale } from '../locales';
|
|
3
|
-
/**
|
|
4
|
-
* Chromium has a weird behavior where the "NARROW NO-BREAK SPACE" character (code 8239) is used
|
|
5
|
-
* instead of a space (code 32) before AM/PM.
|
|
6
|
-
*/
|
|
7
|
-
function fixChromiumSpace(original) {
|
|
8
|
-
return original.replace(new RegExp(String.fromCharCode(8239), 'g'), ' ');
|
|
9
|
-
}
|
|
10
|
-
/** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
|
|
11
|
-
export function toLocaleString(fullDate, formatOptions) {
|
|
12
|
-
const localeString = toLuxonDateTime(fullDate).toLocaleString({
|
|
13
|
-
...formatOptions,
|
|
14
|
-
}, {
|
|
15
|
-
locale: formatOptions?.locale ?? userLocale,
|
|
16
|
-
});
|
|
17
|
-
return fixChromiumSpace(localeString);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Provides arbitrary date formatting using Luxon. For full details on the options for the format
|
|
21
|
-
* string input, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens
|
|
22
|
-
*
|
|
23
|
-
* You probably should **prefer toLocaleString** so your users see the format they expect. It
|
|
24
|
-
* already has many formatting options.
|
|
25
|
-
*/
|
|
26
|
-
export function toFormattedString(fullDate, format, localeOverride = userLocale) {
|
|
27
|
-
const formattedString = toLuxonDateTime(fullDate).toFormat(format, { locale: localeOverride });
|
|
28
|
-
return fixChromiumSpace(formattedString);
|
|
29
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FullDate, FullDatePartEnum, OnlyDatePart, OnlyHourMinutePart, OnlyHourMinuteSecondPart } from '../full-date/full-date-shape';
|
|
2
|
-
import { DateTimeString, DateTimeWithSeconds, JustDateString, JustTimeString, JustTimeWithSecondsString } from './string-format-types';
|
|
3
|
-
/**
|
|
4
|
-
* Converts a FullDate object into a string that is understood by type="date" or type="time"
|
|
5
|
-
* HTMLInputElement instances. Can optionally include seconds as well for type="time".
|
|
6
|
-
*
|
|
7
|
-
* This function ignores the timezone, the literal stored date and time numbers are simply
|
|
8
|
-
* concatenated into a string. If you wish to convert time zones, first call toNewTimezone on your
|
|
9
|
-
* FullDate object.
|
|
10
|
-
*/
|
|
11
|
-
export declare function toHtmlInputString(fullDate: Omit<FullDate, 'timezone'>, inputType: FullDatePartEnum.DateTime, includeSeconds: true): DateTimeWithSeconds;
|
|
12
|
-
export declare function toHtmlInputString(fullDate: Omit<FullDate, 'timezone'>, inputType: FullDatePartEnum.DateTime, includeSeconds?: false | undefined): DateTimeString;
|
|
13
|
-
export declare function toHtmlInputString(fullDate: OnlyDatePart, inputType: FullDatePartEnum.Date): JustDateString;
|
|
14
|
-
export declare function toHtmlInputString(fullDate: OnlyHourMinutePart, inputType: FullDatePartEnum.Time, includeSeconds?: false | undefined): JustTimeString;
|
|
15
|
-
export declare function toHtmlInputString(fullDate: OnlyHourMinuteSecondPart, inputType: FullDatePartEnum.Time, includeSeconds: true): JustTimeWithSecondsString;
|
|
16
|
-
export declare function toHtmlInputString(fullDate: OnlyHourMinutePart | OnlyHourMinuteSecondPart, inputType: FullDatePartEnum.Time, includeSeconds?: boolean | undefined): JustTimeWithSecondsString | JustTimeString;
|
|
17
|
-
export declare function toHtmlInputString(fullDate: OnlyHourMinuteSecondPart | OnlyDatePart, inputType: FullDatePartEnum, includeSeconds: true): JustDateString | JustTimeWithSecondsString;
|
|
18
|
-
export declare function toHtmlInputString(fullDate: OnlyHourMinutePart | OnlyDatePart, inputType: FullDatePartEnum, includeSeconds?: false | undefined): JustDateString | JustTimeString;
|
|
19
|
-
export declare function toHtmlInputString(fullDate: Omit<FullDate, 'timezone'> | OnlyHourMinutePart | OnlyHourMinuteSecondPart | OnlyDatePart, inputType: FullDatePartEnum, includeSeconds?: boolean | undefined): JustDateString | JustTimeWithSecondsString | JustTimeString | DateTimeWithSeconds | DateTimeString;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getEnumTypedValues } from '@augment-vir/common';
|
|
2
|
-
import { assertHasDateProps } from '../extra-utils/has-date-props';
|
|
3
|
-
import { FullDatePartEnum, } from '../full-date/full-date-shape';
|
|
4
|
-
import { toSimpleDatePartString, toSimpleTimePartString } from './simple-strings';
|
|
5
|
-
export function toHtmlInputString(fullDate, inputType, includeSeconds) {
|
|
6
|
-
const internalFullDate = fullDate;
|
|
7
|
-
if (inputType === FullDatePartEnum.Date) {
|
|
8
|
-
assertHasDateProps(internalFullDate, [
|
|
9
|
-
'year',
|
|
10
|
-
'month',
|
|
11
|
-
'day',
|
|
12
|
-
]);
|
|
13
|
-
return toSimpleDatePartString(internalFullDate);
|
|
14
|
-
}
|
|
15
|
-
else if (inputType === FullDatePartEnum.Time) {
|
|
16
|
-
if (includeSeconds && internalFullDate.second == undefined) {
|
|
17
|
-
throw new Error('Tried to include seconds in the time string but no seconds were provided.');
|
|
18
|
-
}
|
|
19
|
-
assertHasDateProps(internalFullDate, [
|
|
20
|
-
'hour',
|
|
21
|
-
'minute',
|
|
22
|
-
]);
|
|
23
|
-
return toSimpleTimePartString(internalFullDate, !!includeSeconds);
|
|
24
|
-
}
|
|
25
|
-
else if (inputType === FullDatePartEnum.DateTime) {
|
|
26
|
-
const datePart = toHtmlInputString(fullDate, FullDatePartEnum.Date);
|
|
27
|
-
const timePart = toHtmlInputString(fullDate, FullDatePartEnum.Time, includeSeconds);
|
|
28
|
-
return `${datePart}T${timePart}`;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
throw new Error(`Unexpected inputTyped: '${inputType}'. Expected usage of FullDatePartEnum or one of ${getEnumTypedValues(FullDatePartEnum).join(', ')}.`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { PartialAndUndefined } from '@augment-vir/common';
|
|
2
|
-
import { DurationUnit } from '../duration/duration-unit';
|
|
3
|
-
import { FullDate } from '../full-date/full-date-shape';
|
|
4
|
-
export type RelativeStringOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* The relative units that the relative string function is not allowed to use. By default, all
|
|
7
|
-
* units are allowed. Thus, you can use this to selectively disable some of them.
|
|
8
|
-
*/
|
|
9
|
-
blockedRelativeUnits: ReadonlyArray<DurationUnit>;
|
|
10
|
-
/**
|
|
11
|
-
* The number of digits to round the relative number value to. Defaults to 0, meaning there will
|
|
12
|
-
* be no decimal digits.
|
|
13
|
-
*
|
|
14
|
-
* Example output: {decimalDigitCount: 4} can result in values like 5.6789 whereas
|
|
15
|
-
* {decimalDigitCount: 0} will result in values like 6.
|
|
16
|
-
*/
|
|
17
|
-
decimalDigitCount: number;
|
|
18
|
-
/** Set this to true to block the 'just now' relative string. By default, that string is allowed. */
|
|
19
|
-
blockJustNow: true;
|
|
20
|
-
/**
|
|
21
|
-
* Set to true to limit durations to their max value. Each unit's max value is its value when it
|
|
22
|
-
* turns into the subsequent unit. For example, seconds maxes out at 60, at which point it
|
|
23
|
-
* becomes a minute.
|
|
24
|
-
*/
|
|
25
|
-
limitUnitMax: true;
|
|
26
|
-
};
|
|
27
|
-
export declare function toRelativeString({ fullDate, relativeTo, options, }: {
|
|
28
|
-
fullDate: Readonly<FullDate>;
|
|
29
|
-
relativeTo: Readonly<FullDate>;
|
|
30
|
-
options?: PartialAndUndefined<RelativeStringOptions>;
|
|
31
|
-
}): string | undefined;
|