@venizia/ignis-helpers 0.2.2-1 → 0.2.2-3
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/dist/cjs/modules/temporal/abstract.d.ts +295 -0
- package/dist/cjs/modules/temporal/abstract.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/abstract.js +330 -0
- package/dist/cjs/modules/temporal/abstract.js.map +1 -0
- package/dist/cjs/modules/temporal/adapters/dayjs.d.ts +1 -1
- package/dist/cjs/modules/temporal/adapters/dayjs.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/adapters/dayjs.js +3 -3
- package/dist/cjs/modules/temporal/adapters/dayjs.js.map +1 -1
- package/dist/cjs/modules/temporal/adapters/intl.d.ts +1 -1
- package/dist/cjs/modules/temporal/adapters/intl.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/adapters/intl.js +7 -7
- package/dist/cjs/modules/temporal/adapters/intl.js.map +1 -1
- package/dist/cjs/modules/temporal/adapters/luxon.d.ts +1 -1
- package/dist/cjs/modules/temporal/adapters/luxon.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/adapters/luxon.js +3 -3
- package/dist/cjs/modules/temporal/adapters/luxon.js.map +1 -1
- package/dist/cjs/modules/temporal/adapters/native.d.ts +3 -1
- package/dist/cjs/modules/temporal/adapters/native.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/adapters/native.js +13 -5
- package/dist/cjs/modules/temporal/adapters/native.js.map +1 -1
- package/dist/cjs/modules/temporal/calendar/calendar.d.ts +56 -0
- package/dist/cjs/modules/temporal/calendar/calendar.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/calendar/calendar.js +166 -0
- package/dist/cjs/modules/temporal/calendar/calendar.js.map +1 -0
- package/dist/cjs/modules/temporal/calendar/index.d.ts +2 -0
- package/dist/cjs/modules/temporal/calendar/index.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/calendar/index.js +18 -0
- package/dist/cjs/modules/temporal/calendar/index.js.map +1 -0
- package/dist/cjs/modules/temporal/common/constants.d.ts +14 -3
- package/dist/cjs/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/common/constants.js +23 -4
- package/dist/cjs/modules/temporal/common/constants.js.map +1 -1
- package/dist/cjs/modules/temporal/common/types.d.ts +258 -5
- package/dist/cjs/modules/temporal/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/{duration.d.ts → duration/duration.d.ts} +9 -2
- package/dist/cjs/modules/temporal/duration/duration.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/duration/duration.js +135 -0
- package/dist/cjs/modules/temporal/duration/duration.js.map +1 -0
- package/dist/cjs/modules/temporal/duration/index.d.ts +2 -0
- package/dist/cjs/modules/temporal/duration/index.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/duration/index.js +18 -0
- package/dist/cjs/modules/temporal/duration/index.js.map +1 -0
- package/dist/cjs/modules/temporal/helper.d.ts +105 -77
- package/dist/cjs/modules/temporal/helper.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/helper.js +209 -258
- package/dist/cjs/modules/temporal/helper.js.map +1 -1
- package/dist/cjs/modules/temporal/index.d.ts +1 -0
- package/dist/cjs/modules/temporal/index.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/index.js +1 -0
- package/dist/cjs/modules/temporal/index.js.map +1 -1
- package/dist/cjs/modules/temporal/locale/index.d.ts +2 -0
- package/dist/cjs/modules/temporal/locale/index.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/locale/index.js +18 -0
- package/dist/cjs/modules/temporal/locale/index.js.map +1 -0
- package/dist/{esm/modules/temporal → cjs/modules/temporal/locale}/locale.d.ts +3 -2
- package/dist/cjs/modules/temporal/locale/locale.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/{locale.js → locale/locale.js} +3 -3
- package/dist/cjs/modules/temporal/locale/locale.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts +2 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.js +18 -0
- package/dist/cjs/modules/temporal/pattern/common/index.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts +26 -0
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/types.js +3 -0
- package/dist/cjs/modules/temporal/pattern/common/types.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/index.d.ts +4 -0
- package/dist/cjs/modules/temporal/pattern/index.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/index.js +20 -0
- package/dist/cjs/modules/temporal/pattern/index.js.map +1 -0
- package/dist/{esm/modules/temporal → cjs/modules/temporal/pattern}/pattern.d.ts +2 -1
- package/dist/cjs/modules/temporal/pattern/pattern.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/{pattern.js → pattern/pattern.js} +19 -14
- package/dist/cjs/modules/temporal/pattern/pattern.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts +59 -0
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/tokens.js +195 -0
- package/dist/cjs/modules/temporal/pattern/tokens.js.map +1 -0
- package/dist/esm/modules/temporal/abstract.d.ts +295 -0
- package/dist/esm/modules/temporal/abstract.d.ts.map +1 -0
- package/dist/esm/modules/temporal/abstract.js +326 -0
- package/dist/esm/modules/temporal/abstract.js.map +1 -0
- package/dist/esm/modules/temporal/adapters/dayjs.d.ts +1 -1
- package/dist/esm/modules/temporal/adapters/dayjs.d.ts.map +1 -1
- package/dist/esm/modules/temporal/adapters/dayjs.js +3 -3
- package/dist/esm/modules/temporal/adapters/dayjs.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/intl.d.ts +1 -1
- package/dist/esm/modules/temporal/adapters/intl.d.ts.map +1 -1
- package/dist/esm/modules/temporal/adapters/intl.js +7 -7
- package/dist/esm/modules/temporal/adapters/intl.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/luxon.d.ts +1 -1
- package/dist/esm/modules/temporal/adapters/luxon.d.ts.map +1 -1
- package/dist/esm/modules/temporal/adapters/luxon.js +3 -3
- package/dist/esm/modules/temporal/adapters/luxon.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/native.d.ts +3 -1
- package/dist/esm/modules/temporal/adapters/native.d.ts.map +1 -1
- package/dist/esm/modules/temporal/adapters/native.js +13 -5
- package/dist/esm/modules/temporal/adapters/native.js.map +1 -1
- package/dist/esm/modules/temporal/calendar/calendar.d.ts +56 -0
- package/dist/esm/modules/temporal/calendar/calendar.d.ts.map +1 -0
- package/dist/esm/modules/temporal/calendar/calendar.js +162 -0
- package/dist/esm/modules/temporal/calendar/calendar.js.map +1 -0
- package/dist/esm/modules/temporal/calendar/index.d.ts +2 -0
- package/dist/esm/modules/temporal/calendar/index.d.ts.map +1 -0
- package/dist/esm/modules/temporal/calendar/index.js +2 -0
- package/dist/esm/modules/temporal/calendar/index.js.map +1 -0
- package/dist/esm/modules/temporal/common/constants.d.ts +14 -3
- package/dist/esm/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/temporal/common/constants.js +21 -3
- package/dist/esm/modules/temporal/common/constants.js.map +1 -1
- package/dist/esm/modules/temporal/common/types.d.ts +258 -5
- package/dist/esm/modules/temporal/common/types.d.ts.map +1 -1
- package/dist/esm/modules/temporal/{duration.d.ts → duration/duration.d.ts} +9 -2
- package/dist/esm/modules/temporal/duration/duration.d.ts.map +1 -0
- package/dist/esm/modules/temporal/duration/duration.js +131 -0
- package/dist/esm/modules/temporal/duration/duration.js.map +1 -0
- package/dist/esm/modules/temporal/duration/index.d.ts +2 -0
- package/dist/esm/modules/temporal/duration/index.d.ts.map +1 -0
- package/dist/esm/modules/temporal/duration/index.js +2 -0
- package/dist/esm/modules/temporal/duration/index.js.map +1 -0
- package/dist/esm/modules/temporal/helper.d.ts +105 -77
- package/dist/esm/modules/temporal/helper.d.ts.map +1 -1
- package/dist/esm/modules/temporal/helper.js +214 -263
- package/dist/esm/modules/temporal/helper.js.map +1 -1
- package/dist/esm/modules/temporal/index.d.ts +1 -0
- package/dist/esm/modules/temporal/index.d.ts.map +1 -1
- package/dist/esm/modules/temporal/index.js +1 -0
- package/dist/esm/modules/temporal/index.js.map +1 -1
- package/dist/esm/modules/temporal/locale/index.d.ts +2 -0
- package/dist/esm/modules/temporal/locale/index.d.ts.map +1 -0
- package/dist/esm/modules/temporal/locale/index.js +2 -0
- package/dist/esm/modules/temporal/locale/index.js.map +1 -0
- package/dist/{cjs/modules/temporal → esm/modules/temporal/locale}/locale.d.ts +3 -2
- package/dist/esm/modules/temporal/locale/locale.d.ts.map +1 -0
- package/dist/esm/modules/temporal/{locale.js → locale/locale.js} +3 -3
- package/dist/esm/modules/temporal/locale/locale.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts +2 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.js +2 -0
- package/dist/esm/modules/temporal/pattern/common/index.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/types.d.ts +26 -0
- package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/types.js +2 -0
- package/dist/esm/modules/temporal/pattern/common/types.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/index.d.ts +4 -0
- package/dist/esm/modules/temporal/pattern/index.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/index.js +4 -0
- package/dist/esm/modules/temporal/pattern/index.js.map +1 -0
- package/dist/{cjs/modules/temporal → esm/modules/temporal/pattern}/pattern.d.ts +2 -1
- package/dist/esm/modules/temporal/pattern/pattern.d.ts.map +1 -0
- package/dist/esm/modules/temporal/{pattern.js → pattern/pattern.js} +20 -15
- package/dist/esm/modules/temporal/pattern/pattern.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/tokens.d.ts +59 -0
- package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/tokens.js +191 -0
- package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -0
- package/package.json +2 -2
- package/dist/cjs/modules/temporal/adapters/guards.d.ts +0 -4
- package/dist/cjs/modules/temporal/adapters/guards.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/adapters/guards.js +0 -14
- package/dist/cjs/modules/temporal/adapters/guards.js.map +0 -1
- package/dist/cjs/modules/temporal/calendar.d.ts +0 -52
- package/dist/cjs/modules/temporal/calendar.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/calendar.js +0 -151
- package/dist/cjs/modules/temporal/calendar.js.map +0 -1
- package/dist/cjs/modules/temporal/duration.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/duration.js +0 -64
- package/dist/cjs/modules/temporal/duration.js.map +0 -1
- package/dist/cjs/modules/temporal/locale.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/locale.js.map +0 -1
- package/dist/cjs/modules/temporal/pattern.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/pattern.js.map +0 -1
- package/dist/cjs/modules/temporal/tokens.d.ts +0 -78
- package/dist/cjs/modules/temporal/tokens.d.ts.map +0 -1
- package/dist/cjs/modules/temporal/tokens.js +0 -145
- package/dist/cjs/modules/temporal/tokens.js.map +0 -1
- package/dist/esm/modules/temporal/adapters/guards.d.ts +0 -4
- package/dist/esm/modules/temporal/adapters/guards.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/guards.js +0 -10
- package/dist/esm/modules/temporal/adapters/guards.js.map +0 -1
- package/dist/esm/modules/temporal/calendar.d.ts +0 -52
- package/dist/esm/modules/temporal/calendar.d.ts.map +0 -1
- package/dist/esm/modules/temporal/calendar.js +0 -138
- package/dist/esm/modules/temporal/calendar.js.map +0 -1
- package/dist/esm/modules/temporal/duration.d.ts.map +0 -1
- package/dist/esm/modules/temporal/duration.js +0 -60
- package/dist/esm/modules/temporal/duration.js.map +0 -1
- package/dist/esm/modules/temporal/locale.d.ts.map +0 -1
- package/dist/esm/modules/temporal/locale.js.map +0 -1
- package/dist/esm/modules/temporal/pattern.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern.js.map +0 -1
- package/dist/esm/modules/temporal/tokens.d.ts +0 -78
- package/dist/esm/modules/temporal/tokens.d.ts.map +0 -1
- package/dist/esm/modules/temporal/tokens.js +0 -133
- package/dist/esm/modules/temporal/tokens.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TTemporalUnit } from '../common/constants.js';
|
|
2
|
+
import type { ITemporalParts, IZonedTemporalParts } from '../common/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Calendar arithmetic on wall-clock fields, at a fixed offset or none at all - never a time zone,
|
|
5
|
+
* never the host's. `TemporalHelper` brings the zone.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TemporalCalendar {
|
|
8
|
+
/** The years a four-digit `YYYY` spells - the range every method reads and writes. */
|
|
9
|
+
static readonly MIN_YEAR = 1;
|
|
10
|
+
static readonly MAX_YEAR = 9999;
|
|
11
|
+
/** Units that measure elapsed time rather than the calendar - 24 hours is not always a day. */
|
|
12
|
+
static readonly EXACT_UNIT_MILLISECONDS: Partial<Record<TTemporalUnit, number>>;
|
|
13
|
+
/** A UTC scratch date - `Date.UTC` maps years 0-99 onto 1900-1999, `setUTCFullYear` does not. */
|
|
14
|
+
private static scratch;
|
|
15
|
+
static isSupportedYear(opts: {
|
|
16
|
+
year: number;
|
|
17
|
+
}): boolean;
|
|
18
|
+
static daysInMonth(opts: {
|
|
19
|
+
year: number;
|
|
20
|
+
month: number;
|
|
21
|
+
}): number;
|
|
22
|
+
/** Whether the fields name a day and a time the calendar has - Feb 30, 24:00 and year 0 do not. */
|
|
23
|
+
static isRealDateTime(opts: {
|
|
24
|
+
parts: ITemporalParts;
|
|
25
|
+
}): boolean;
|
|
26
|
+
/** Epoch milliseconds of wall-clock fields read at a fixed offset. */
|
|
27
|
+
static epochAtOffset(opts: {
|
|
28
|
+
parts: ITemporalParts;
|
|
29
|
+
offsetMilliseconds: number;
|
|
30
|
+
}): number;
|
|
31
|
+
/** The wall clock an instant shows at a fixed offset - pure arithmetic, never the host's zone. */
|
|
32
|
+
static wallClockAt(opts: {
|
|
33
|
+
epoch: number;
|
|
34
|
+
offsetMilliseconds: number;
|
|
35
|
+
}): IZonedTemporalParts;
|
|
36
|
+
/** The wall-clock fields alone, without the weekday and the offset. */
|
|
37
|
+
static wallClockOf(opts: {
|
|
38
|
+
parts: ITemporalParts;
|
|
39
|
+
}): ITemporalParts;
|
|
40
|
+
/** The wall-clock start of the unit holding `parts`. Weeks start on Monday; quarters in Jan, Apr, Jul, Oct. */
|
|
41
|
+
static truncate(opts: {
|
|
42
|
+
parts: IZonedTemporalParts;
|
|
43
|
+
unit: TTemporalUnit;
|
|
44
|
+
}): ITemporalParts;
|
|
45
|
+
/**
|
|
46
|
+
* `parts` moved by whole units on the wall clock - no time zone involved. Hours and smaller move
|
|
47
|
+
* elapsed time; days and weeks move the calendar date, wall time untouched; months, quarters and
|
|
48
|
+
* years move the month, the day clamped to the target month: Jan 31 + 1 month is Feb 28.
|
|
49
|
+
*/
|
|
50
|
+
static shift(opts: {
|
|
51
|
+
parts: ITemporalParts;
|
|
52
|
+
amount: number;
|
|
53
|
+
unit: TTemporalUnit;
|
|
54
|
+
}): ITemporalParts;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/calendar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAM3E;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,sFAAsF;IACtF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IAAI,EAAE,aAAa,CAAC;KACrB,GAAG,cAAc;CAwCnB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { TemporalUnits } from '../common/constants.js';
|
|
2
|
+
const MILLISECONDS_PER_MINUTE = 60_000;
|
|
3
|
+
const MONTHS_PER_YEAR = 12;
|
|
4
|
+
const DAYS_PER_WEEK = 7;
|
|
5
|
+
/**
|
|
6
|
+
* Calendar arithmetic on wall-clock fields, at a fixed offset or none at all - never a time zone,
|
|
7
|
+
* never the host's. `TemporalHelper` brings the zone.
|
|
8
|
+
*/
|
|
9
|
+
export class TemporalCalendar {
|
|
10
|
+
/** The years a four-digit `YYYY` spells - the range every method reads and writes. */
|
|
11
|
+
static { this.MIN_YEAR = 1; }
|
|
12
|
+
static { this.MAX_YEAR = 9999; }
|
|
13
|
+
/** Units that measure elapsed time rather than the calendar - 24 hours is not always a day. */
|
|
14
|
+
static { this.EXACT_UNIT_MILLISECONDS = {
|
|
15
|
+
[TemporalUnits.MILLISECOND]: 1,
|
|
16
|
+
[TemporalUnits.SECOND]: 1_000,
|
|
17
|
+
[TemporalUnits.MINUTE]: 60_000,
|
|
18
|
+
[TemporalUnits.HOUR]: 3_600_000,
|
|
19
|
+
}; }
|
|
20
|
+
/** A UTC scratch date - `Date.UTC` maps years 0-99 onto 1900-1999, `setUTCFullYear` does not. */
|
|
21
|
+
static scratch(opts) {
|
|
22
|
+
const date = new Date(0);
|
|
23
|
+
date.setUTCFullYear(opts.year, opts.month - 1, opts.day);
|
|
24
|
+
return date;
|
|
25
|
+
}
|
|
26
|
+
static isSupportedYear(opts) {
|
|
27
|
+
return opts.year >= TemporalCalendar.MIN_YEAR && opts.year <= TemporalCalendar.MAX_YEAR;
|
|
28
|
+
}
|
|
29
|
+
static daysInMonth(opts) {
|
|
30
|
+
return TemporalCalendar.scratch({
|
|
31
|
+
year: opts.year,
|
|
32
|
+
month: opts.month + 1,
|
|
33
|
+
day: 0,
|
|
34
|
+
}).getUTCDate();
|
|
35
|
+
}
|
|
36
|
+
/** Whether the fields name a day and a time the calendar has - Feb 30, 24:00 and year 0 do not. */
|
|
37
|
+
static isRealDateTime(opts) {
|
|
38
|
+
const { year, month, day, hour, minute, second, millisecond } = opts.parts;
|
|
39
|
+
return (TemporalCalendar.isSupportedYear({ year }) &&
|
|
40
|
+
month >= 1 &&
|
|
41
|
+
month <= 12 &&
|
|
42
|
+
day >= 1 &&
|
|
43
|
+
day <= TemporalCalendar.daysInMonth({ year, month }) &&
|
|
44
|
+
hour >= 0 &&
|
|
45
|
+
hour <= 23 &&
|
|
46
|
+
minute >= 0 &&
|
|
47
|
+
minute <= 59 &&
|
|
48
|
+
second >= 0 &&
|
|
49
|
+
second <= 59 &&
|
|
50
|
+
millisecond >= 0 &&
|
|
51
|
+
millisecond <= 999);
|
|
52
|
+
}
|
|
53
|
+
/** Epoch milliseconds of wall-clock fields read at a fixed offset. */
|
|
54
|
+
static epochAtOffset(opts) {
|
|
55
|
+
const { parts, offsetMilliseconds } = opts;
|
|
56
|
+
const date = TemporalCalendar.scratch({
|
|
57
|
+
year: parts.year,
|
|
58
|
+
month: parts.month,
|
|
59
|
+
day: parts.day,
|
|
60
|
+
});
|
|
61
|
+
date.setUTCHours(parts.hour, parts.minute, parts.second, parts.millisecond);
|
|
62
|
+
return date.getTime() - offsetMilliseconds;
|
|
63
|
+
}
|
|
64
|
+
/** The wall clock an instant shows at a fixed offset - pure arithmetic, never the host's zone. */
|
|
65
|
+
static wallClockAt(opts) {
|
|
66
|
+
const { epoch, offsetMilliseconds } = opts;
|
|
67
|
+
const date = new Date(epoch + offsetMilliseconds);
|
|
68
|
+
return {
|
|
69
|
+
year: date.getUTCFullYear(),
|
|
70
|
+
month: date.getUTCMonth() + 1,
|
|
71
|
+
day: date.getUTCDate(),
|
|
72
|
+
hour: date.getUTCHours(),
|
|
73
|
+
minute: date.getUTCMinutes(),
|
|
74
|
+
second: date.getUTCSeconds(),
|
|
75
|
+
millisecond: date.getUTCMilliseconds(),
|
|
76
|
+
// `getUTCDay` counts Sunday as 0; ISO counts Monday as 1 and Sunday as 7.
|
|
77
|
+
dayOfWeek: ((date.getUTCDay() + 6) % 7) + 1,
|
|
78
|
+
offsetMinutes: offsetMilliseconds / MILLISECONDS_PER_MINUTE,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** The wall-clock fields alone, without the weekday and the offset. */
|
|
82
|
+
static wallClockOf(opts) {
|
|
83
|
+
const { year, month, day, hour, minute, second, millisecond } = opts.parts;
|
|
84
|
+
return { year, month, day, hour, minute, second, millisecond };
|
|
85
|
+
}
|
|
86
|
+
/** The wall-clock start of the unit holding `parts`. Weeks start on Monday; quarters in Jan, Apr, Jul, Oct. */
|
|
87
|
+
static truncate(opts) {
|
|
88
|
+
const { parts, unit } = opts;
|
|
89
|
+
const wall = TemporalCalendar.wallClockOf({ parts });
|
|
90
|
+
const midnight = { ...wall, hour: 0, minute: 0, second: 0, millisecond: 0 };
|
|
91
|
+
switch (unit) {
|
|
92
|
+
case TemporalUnits.SECOND: {
|
|
93
|
+
return { ...wall, millisecond: 0 };
|
|
94
|
+
}
|
|
95
|
+
case TemporalUnits.MINUTE: {
|
|
96
|
+
return { ...wall, second: 0, millisecond: 0 };
|
|
97
|
+
}
|
|
98
|
+
case TemporalUnits.HOUR: {
|
|
99
|
+
return { ...wall, minute: 0, second: 0, millisecond: 0 };
|
|
100
|
+
}
|
|
101
|
+
case TemporalUnits.DAY: {
|
|
102
|
+
return midnight;
|
|
103
|
+
}
|
|
104
|
+
case TemporalUnits.WEEK: {
|
|
105
|
+
return TemporalCalendar.shift({
|
|
106
|
+
parts: midnight,
|
|
107
|
+
amount: 1 - parts.dayOfWeek,
|
|
108
|
+
unit: TemporalUnits.DAY,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
case TemporalUnits.MONTH: {
|
|
112
|
+
return { ...midnight, day: 1 };
|
|
113
|
+
}
|
|
114
|
+
case TemporalUnits.QUARTER: {
|
|
115
|
+
return { ...midnight, month: Math.floor((wall.month - 1) / 3) * 3 + 1, day: 1 };
|
|
116
|
+
}
|
|
117
|
+
default: {
|
|
118
|
+
return { ...midnight, month: 1, day: 1 };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* `parts` moved by whole units on the wall clock - no time zone involved. Hours and smaller move
|
|
124
|
+
* elapsed time; days and weeks move the calendar date, wall time untouched; months, quarters and
|
|
125
|
+
* years move the month, the day clamped to the target month: Jan 31 + 1 month is Feb 28.
|
|
126
|
+
*/
|
|
127
|
+
static shift(opts) {
|
|
128
|
+
const { parts, amount, unit } = opts;
|
|
129
|
+
const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];
|
|
130
|
+
if (exact !== undefined) {
|
|
131
|
+
const epoch = TemporalCalendar.epochAtOffset({ parts, offsetMilliseconds: 0 }) + amount * exact;
|
|
132
|
+
return TemporalCalendar.wallClockOf({
|
|
133
|
+
parts: TemporalCalendar.wallClockAt({ epoch, offsetMilliseconds: 0 }),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (unit === TemporalUnits.DAY || unit === TemporalUnits.WEEK) {
|
|
137
|
+
const days = unit === TemporalUnits.WEEK ? amount * DAYS_PER_WEEK : amount;
|
|
138
|
+
const date = TemporalCalendar.scratch({
|
|
139
|
+
year: parts.year,
|
|
140
|
+
month: parts.month,
|
|
141
|
+
day: parts.day + days,
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
...parts,
|
|
145
|
+
year: date.getUTCFullYear(),
|
|
146
|
+
month: date.getUTCMonth() + 1,
|
|
147
|
+
day: date.getUTCDate(),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const monthsPerUnit = unit === TemporalUnits.QUARTER ? 3 : unit === TemporalUnits.YEAR ? MONTHS_PER_YEAR : 1;
|
|
151
|
+
const total = parts.year * MONTHS_PER_YEAR + (parts.month - 1) + amount * monthsPerUnit;
|
|
152
|
+
const year = Math.floor(total / MONTHS_PER_YEAR);
|
|
153
|
+
const month = total - year * MONTHS_PER_YEAR + 1;
|
|
154
|
+
return {
|
|
155
|
+
...parts,
|
|
156
|
+
year,
|
|
157
|
+
month,
|
|
158
|
+
day: Math.min(parts.day, TemporalCalendar.daysInMonth({ year, month })),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B,sFAAsF;aACtE,aAAQ,GAAG,CAAC,CAAC;aACb,aAAQ,GAAG,IAAI,CAAC;IAEhC,+FAA+F;aAC/E,4BAAuB,GAA2C;QAChF,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK;QAC7B,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM;QAC9B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS;KAChC,CAAC;IAEF,iGAAiG;IACzF,MAAM,CAAC,OAAO,CAAC,IAAkD;QACvE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,IAAsB;QAC3C,OAAO,I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,CAAC;gBACpC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,GAAG,EAAE,KAAK,CAAC,GAAG,GAAG,IAAI;aACtB,CAAC,CAAC;YACH,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE;gBAC3B,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC;gBAC7B,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE;aACvB,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GACjB,IAAI,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,GAAG,eAAe,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,aAAa,CAAC;QACxF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,eAAe,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,eAAe,GAAG,CAAC,CAAC;QAEjD,OAAO;YACL,GAAG,KAAK;YACR,IAAI;YACJ,KAAK;YACL,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;SACxE,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TConstValue } from '../../../common/types/index.js';
|
|
2
|
-
/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday. */
|
|
2
|
+
/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */
|
|
3
3
|
export declare class TemporalUnits {
|
|
4
4
|
static readonly MILLISECOND = "millisecond";
|
|
5
5
|
static readonly SECOND = "second";
|
|
@@ -8,13 +8,14 @@ export declare class TemporalUnits {
|
|
|
8
8
|
static readonly DAY = "day";
|
|
9
9
|
static readonly WEEK = "week";
|
|
10
10
|
static readonly MONTH = "month";
|
|
11
|
+
static readonly QUARTER = "quarter";
|
|
11
12
|
static readonly YEAR = "year";
|
|
12
13
|
static readonly SCHEME_SET: Set<string>;
|
|
13
14
|
static isValid(input: string): input is TTemporalUnit;
|
|
14
15
|
}
|
|
15
16
|
export type TTemporalUnit = TConstValue<typeof TemporalUnits>;
|
|
16
|
-
/** A helper built without a `
|
|
17
|
-
export declare const
|
|
17
|
+
/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */
|
|
18
|
+
export declare const DEFAULT_TEMPORAL_TZ = "UTC";
|
|
18
19
|
/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */
|
|
19
20
|
export declare const DEFAULT_TEMPORAL_PATTERN = "YYYY-MM-DDTHH:mm:ss.SSSZ";
|
|
20
21
|
/** The locale name tokens and `formatIntl` write in when a helper is built without one. */
|
|
@@ -29,4 +30,14 @@ export declare class TemporalDurationStyles {
|
|
|
29
30
|
static isValid(input: string): input is TTemporalDurationStyle;
|
|
30
31
|
}
|
|
31
32
|
export type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;
|
|
33
|
+
/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */
|
|
34
|
+
export declare class TemporalInclusivities {
|
|
35
|
+
static readonly EXCLUSIVE = "()";
|
|
36
|
+
static readonly INCLUSIVE = "[]";
|
|
37
|
+
static readonly START_ONLY = "[)";
|
|
38
|
+
static readonly END_ONLY = "(]";
|
|
39
|
+
static readonly SCHEME_SET: Set<string>;
|
|
40
|
+
static isValid(input: string): input is TTemporalInclusivity;
|
|
41
|
+
}
|
|
42
|
+
export type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;
|
|
32
43
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,kLAAkL;AAClL,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAUvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI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they start on Monday; a quarter is three calendar months from January, April, July or October. */
|
|
2
2
|
export class TemporalUnits {
|
|
3
3
|
static { this.MILLISECOND = 'millisecond'; }
|
|
4
4
|
static { this.SECOND = 'second'; }
|
|
@@ -7,6 +7,7 @@ export class TemporalUnits {
|
|
|
7
7
|
static { this.DAY = 'day'; }
|
|
8
8
|
static { this.WEEK = 'week'; }
|
|
9
9
|
static { this.MONTH = 'month'; }
|
|
10
|
+
static { this.QUARTER = 'quarter'; }
|
|
10
11
|
static { this.YEAR = 'year'; }
|
|
11
12
|
static { this.SCHEME_SET = new Set([
|
|
12
13
|
this.MILLISECOND,
|
|
@@ -16,14 +17,15 @@ export class TemporalUnits {
|
|
|
16
17
|
this.DAY,
|
|
17
18
|
this.WEEK,
|
|
18
19
|
this.MONTH,
|
|
20
|
+
this.QUARTER,
|
|
19
21
|
this.YEAR,
|
|
20
22
|
]); }
|
|
21
23
|
static isValid(input) {
|
|
22
24
|
return this.SCHEME_SET.has(input);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
/** A helper built without a `
|
|
26
|
-
export const
|
|
27
|
+
/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */
|
|
28
|
+
export const DEFAULT_TEMPORAL_TZ = 'UTC';
|
|
27
29
|
/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */
|
|
28
30
|
export const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
|
|
29
31
|
/** The locale name tokens and `formatIntl` write in when a helper is built without one. */
|
|
@@ -39,4 +41,20 @@ export class TemporalDurationStyles {
|
|
|
39
41
|
return this.SCHEME_SET.has(input);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */
|
|
45
|
+
export class TemporalInclusivities {
|
|
46
|
+
static { this.EXCLUSIVE = '()'; }
|
|
47
|
+
static { this.INCLUSIVE = '[]'; }
|
|
48
|
+
static { this.START_ONLY = '[)'; }
|
|
49
|
+
static { this.END_ONLY = '(]'; }
|
|
50
|
+
static { this.SCHEME_SET = new Set([
|
|
51
|
+
this.EXCLUSIVE,
|
|
52
|
+
this.INCLUSIVE,
|
|
53
|
+
this.START_ONLY,
|
|
54
|
+
this.END_ONLY,
|
|
55
|
+
]); }
|
|
56
|
+
static isValid(input) {
|
|
57
|
+
return this.SCHEME_SET.has(input);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
42
60
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,uGAAuG;AACvG,MAAM,OAAO,sBAAsB;aACjB,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,0FAA0F;AAC1F,MAAM,OAAO,qBAAqB;aAChB,cAAS,GAAG,IAAI,CAAC;aACjB,cAAS,GAAG,IAAI,CAAC;aACjB,eAAU,GAAG,IAAI,CAAC;aAClB,aAAQ,GAAG,IAAI,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TemporalUnits, TTemporalDurationStyle, TTemporalInclusivity, TTemporalUnit } from './constants.js';
|
|
1
2
|
/** What a date-taking method accepts: a `Date`, epoch milliseconds, or an ISO 8601 string. */
|
|
2
3
|
export type TTemporalInput = Date | number | string;
|
|
3
4
|
/** Wall-clock fields. `month` is 1-12, `day` 1-31 - never zero-based. */
|
|
@@ -23,10 +24,10 @@ export interface IZonedTemporalParts extends ITemporalParts {
|
|
|
23
24
|
* adapter shares one behaviour.
|
|
24
25
|
*/
|
|
25
26
|
export interface ITemporalAdapter {
|
|
26
|
-
/** Milliseconds east of UTC that `
|
|
27
|
+
/** Milliseconds east of UTC that `tz` observes at `value`: `25_200_000` for `+07:00`. */
|
|
27
28
|
getOffsetMilliseconds(opts: {
|
|
28
29
|
value: Date;
|
|
29
|
-
|
|
30
|
+
tz: string;
|
|
30
31
|
}): number;
|
|
31
32
|
}
|
|
32
33
|
/** The part of a `Temporal.ZonedDateTime` this adapter reads. */
|
|
@@ -40,19 +41,19 @@ export interface ITemporalZonedDateTime {
|
|
|
40
41
|
export interface ITemporalNamespace {
|
|
41
42
|
Instant: {
|
|
42
43
|
fromEpochMilliseconds(epochMilliseconds: number): {
|
|
43
|
-
toZonedDateTimeISO(
|
|
44
|
+
toZonedDateTimeISO(tz: string): ITemporalZonedDateTime;
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
/** The part of a `Dayjs` object this adapter reads. */
|
|
48
49
|
export interface IDayjsInstance {
|
|
49
50
|
utcOffset(): number;
|
|
50
|
-
tz(
|
|
51
|
+
tz(tz: string): IDayjsInstance;
|
|
51
52
|
}
|
|
52
53
|
/** The part of the `dayjs` factory this adapter drives - with the `utc` and `timezone` plugins extended. */
|
|
53
54
|
export interface IDayjsFactory {
|
|
54
55
|
(value?: Date | number): IDayjsInstance;
|
|
55
|
-
tz: (value: string,
|
|
56
|
+
tz: (value: string, tz: string) => IDayjsInstance;
|
|
56
57
|
}
|
|
57
58
|
/** The part of a Luxon `DateTime` this adapter reads. */
|
|
58
59
|
export interface ILuxonDateTime {
|
|
@@ -75,4 +76,256 @@ export interface ITemporalDurationParts {
|
|
|
75
76
|
seconds: number;
|
|
76
77
|
milliseconds: number;
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* A locale's own wording, over what `Intl` writes for it: month names (January first), weekday
|
|
81
|
+
* names in ISO order (Monday first), and the AM and PM markers. Any list left out stays `Intl`'s.
|
|
82
|
+
*/
|
|
83
|
+
export interface ITemporalLocaleNames {
|
|
84
|
+
months?: ReadonlyArray<string>;
|
|
85
|
+
monthsShort?: ReadonlyArray<string>;
|
|
86
|
+
weekdays?: ReadonlyArray<string>;
|
|
87
|
+
weekdaysShort?: ReadonlyArray<string>;
|
|
88
|
+
weekdaysMin?: ReadonlyArray<string>;
|
|
89
|
+
meridiem?: readonly [string, string];
|
|
90
|
+
}
|
|
91
|
+
/** The fields `set` replaces on the wall clock: `month` is 1-12. */
|
|
92
|
+
export type TTemporalFields = Partial<ITemporalParts>;
|
|
93
|
+
/** The units `Intl.RelativeTimeFormat` speaks: every temporal unit but the millisecond. */
|
|
94
|
+
export type TRelativeUnit = Exclude<TTemporalUnit, typeof TemporalUnits.MILLISECOND>;
|
|
95
|
+
/** What a temporal helper does: dates in one time zone, through an adapter. `TemporalHelper` is the implementation. */
|
|
96
|
+
export interface ITemporalHelper {
|
|
97
|
+
/**
|
|
98
|
+
* A date picker hands back a `Date` meaning "this wall clock in the host's zone". This returns the
|
|
99
|
+
* instant that shows the same year, month, day and time in the helper's zone. `sourceTz` defaults
|
|
100
|
+
* to the host's. A skipped wall time resolves forward, a repeated one to the earlier instant.
|
|
101
|
+
*/
|
|
102
|
+
fromWallClock(opts: {
|
|
103
|
+
value: TTemporalInput;
|
|
104
|
+
sourceTz?: string;
|
|
105
|
+
tz?: string;
|
|
106
|
+
}): Date;
|
|
107
|
+
/**
|
|
108
|
+
* The reverse of `fromWallClock`, to feed a picker: a `Date` whose wall clock in `targetTz` (default:
|
|
109
|
+
* the host's) reads what the helper's zone reads for `value`.
|
|
110
|
+
*/
|
|
111
|
+
toWallClock(opts: {
|
|
112
|
+
value: TTemporalInput;
|
|
113
|
+
targetTz?: string;
|
|
114
|
+
tz?: string;
|
|
115
|
+
}): Date;
|
|
116
|
+
/** A helper like this one, with another locale or zone: same adapter, same `names`. */
|
|
117
|
+
clone(opts: {
|
|
118
|
+
locale?: string;
|
|
119
|
+
tz?: string;
|
|
120
|
+
}): ITemporalHelper;
|
|
121
|
+
getTz(): string;
|
|
122
|
+
getLocale(): string;
|
|
123
|
+
now(): Date;
|
|
124
|
+
/** The instant a value names. An ISO string without an offset is read as wall clock in the zone. */
|
|
125
|
+
toDate(opts: {
|
|
126
|
+
value: TTemporalInput;
|
|
127
|
+
tz?: string;
|
|
128
|
+
}): Date;
|
|
129
|
+
/** `toDate`, answering `null` where `toDate` refuses the value: null, undefined, bad text, NaN. */
|
|
130
|
+
tryToDate(opts: {
|
|
131
|
+
value: TTemporalInput | null | undefined;
|
|
132
|
+
tz?: string;
|
|
133
|
+
}): Date | null;
|
|
134
|
+
/** The wall clock the value shows in the zone, with its ISO weekday and UTC offset. */
|
|
135
|
+
parts(opts: {
|
|
136
|
+
value: TTemporalInput;
|
|
137
|
+
tz?: string;
|
|
138
|
+
}): IZonedTemporalParts;
|
|
139
|
+
/**
|
|
140
|
+
* Reads a string. With a `pattern` (`YYYY YY MM M DD D HH H mm m ss s SSS Z ZZ`, text in
|
|
141
|
+
* `[brackets]`), the value must match it exactly; without one it must be ISO 8601. An offset in
|
|
142
|
+
* the value wins; otherwise the fields are wall clock in the zone.
|
|
143
|
+
*/
|
|
144
|
+
parse(opts: {
|
|
145
|
+
value: string;
|
|
146
|
+
pattern?: string;
|
|
147
|
+
tz?: string;
|
|
148
|
+
}): Date;
|
|
149
|
+
/** `parse`, answering `null` where `parse` refuses the value. A pattern that does not compile still throws. */
|
|
150
|
+
tryParse(opts: {
|
|
151
|
+
value: string;
|
|
152
|
+
pattern?: string;
|
|
153
|
+
tz?: string;
|
|
154
|
+
}): Date | null;
|
|
155
|
+
/** Whether the value names an instant in years 1-9999 - a string read as `parse` reads it. */
|
|
156
|
+
isValid(opts: {
|
|
157
|
+
value: TTemporalInput | null | undefined;
|
|
158
|
+
pattern?: string;
|
|
159
|
+
tz?: string;
|
|
160
|
+
}): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Writes the value in the zone. Without a `pattern`: ISO 8601 with the zone's offset. The tokens
|
|
163
|
+
* `MMMM MMM dddd ddd dd A a hh h LL L` are spelled in `locale`. With a `fallback`, a value that is
|
|
164
|
+
* not a date - null included - writes the fallback; without one, it is a 400.
|
|
165
|
+
*/
|
|
166
|
+
format(opts: {
|
|
167
|
+
value: TTemporalInput | null | undefined;
|
|
168
|
+
pattern?: string;
|
|
169
|
+
tz?: string;
|
|
170
|
+
locale?: string;
|
|
171
|
+
fallback?: string;
|
|
172
|
+
}): string;
|
|
173
|
+
/** Writes the value with `Intl.DateTimeFormat` options, in the zone - for what the pattern tokens cannot say. */
|
|
174
|
+
formatIntl(opts: {
|
|
175
|
+
value: TTemporalInput;
|
|
176
|
+
options?: Omit<Intl.DateTimeFormatOptions, 'timeZone'>;
|
|
177
|
+
tz?: string;
|
|
178
|
+
locale?: string;
|
|
179
|
+
}): string;
|
|
180
|
+
/**
|
|
181
|
+
* Moves the value by whole units. Hours and smaller are elapsed time; days and larger move the
|
|
182
|
+
* calendar in the zone, so a day across a daylight-saving jump keeps the wall time, and a month
|
|
183
|
+
* past a shorter month clamps to its last day.
|
|
184
|
+
*/
|
|
185
|
+
add(opts: {
|
|
186
|
+
value: TTemporalInput;
|
|
187
|
+
amount: number;
|
|
188
|
+
unit: TTemporalUnit;
|
|
189
|
+
tz?: string;
|
|
190
|
+
}): Date;
|
|
191
|
+
subtract(opts: {
|
|
192
|
+
value: TTemporalInput;
|
|
193
|
+
amount: number;
|
|
194
|
+
unit: TTemporalUnit;
|
|
195
|
+
tz?: string;
|
|
196
|
+
}): Date;
|
|
197
|
+
/** The first instant of the unit containing the value, in the zone. Weeks start on Monday. */
|
|
198
|
+
startOf(opts: {
|
|
199
|
+
value: TTemporalInput;
|
|
200
|
+
unit: TTemporalUnit;
|
|
201
|
+
tz?: string;
|
|
202
|
+
}): Date;
|
|
203
|
+
/** The last millisecond of the unit containing the value, in the zone. */
|
|
204
|
+
endOf(opts: {
|
|
205
|
+
value: TTemporalInput;
|
|
206
|
+
unit: TTemporalUnit;
|
|
207
|
+
tz?: string;
|
|
208
|
+
}): Date;
|
|
209
|
+
/** Monday to Friday, read on the wall clock of the zone. */
|
|
210
|
+
isWeekday(opts: {
|
|
211
|
+
value: TTemporalInput;
|
|
212
|
+
tz?: string;
|
|
213
|
+
}): boolean;
|
|
214
|
+
nextWeekday(opts: {
|
|
215
|
+
value: TTemporalInput;
|
|
216
|
+
tz?: string;
|
|
217
|
+
}): Date;
|
|
218
|
+
previousWeekday(opts: {
|
|
219
|
+
value: TTemporalInput;
|
|
220
|
+
tz?: string;
|
|
221
|
+
}): Date;
|
|
222
|
+
/**
|
|
223
|
+
* The value with wall-clock fields replaced in the zone - `{ hour: 9, minute: 0 }` is 09:00 that day.
|
|
224
|
+
* `month` is 1-12. The day is clamped to the month's last day, so setting February on the 31st
|
|
225
|
+
* lands on the 28th or 29th. A wall time a daylight-saving jump skips resolves forward, as `parse` does.
|
|
226
|
+
*/
|
|
227
|
+
set(opts: {
|
|
228
|
+
value: TTemporalInput;
|
|
229
|
+
tz?: string;
|
|
230
|
+
} & TTemporalFields): Date;
|
|
231
|
+
/** `value` is before `other` - at the unit's granularity in the zone when `unit` is given. */
|
|
232
|
+
isBefore(opts: {
|
|
233
|
+
value: TTemporalInput;
|
|
234
|
+
other: TTemporalInput;
|
|
235
|
+
unit?: TTemporalUnit;
|
|
236
|
+
tz?: string;
|
|
237
|
+
}): boolean;
|
|
238
|
+
isAfter(opts: {
|
|
239
|
+
value: TTemporalInput;
|
|
240
|
+
other: TTemporalInput;
|
|
241
|
+
unit?: TTemporalUnit;
|
|
242
|
+
tz?: string;
|
|
243
|
+
}): boolean;
|
|
244
|
+
/** In the same unit - `unit: 'day'` is the same calendar day in the zone. */
|
|
245
|
+
isSame(opts: {
|
|
246
|
+
value: TTemporalInput;
|
|
247
|
+
other: TTemporalInput;
|
|
248
|
+
unit?: TTemporalUnit;
|
|
249
|
+
tz?: string;
|
|
250
|
+
}): boolean;
|
|
251
|
+
isSameOrBefore(opts: {
|
|
252
|
+
value: TTemporalInput;
|
|
253
|
+
other: TTemporalInput;
|
|
254
|
+
unit?: TTemporalUnit;
|
|
255
|
+
tz?: string;
|
|
256
|
+
}): boolean;
|
|
257
|
+
isSameOrAfter(opts: {
|
|
258
|
+
value: TTemporalInput;
|
|
259
|
+
other: TTemporalInput;
|
|
260
|
+
unit?: TTemporalUnit;
|
|
261
|
+
tz?: string;
|
|
262
|
+
}): boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Whether `value` lies between `from` and `to`, in either order. `inclusivity` says which ends count:
|
|
265
|
+
* `()` (the default) neither, `[]` both, `[)` the start, `(]` the end.
|
|
266
|
+
*/
|
|
267
|
+
isBetween(opts: {
|
|
268
|
+
value: TTemporalInput;
|
|
269
|
+
from: TTemporalInput;
|
|
270
|
+
to: TTemporalInput;
|
|
271
|
+
unit?: TTemporalUnit;
|
|
272
|
+
inclusivity?: TTemporalInclusivity;
|
|
273
|
+
tz?: string;
|
|
274
|
+
}): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* How many whole units `value` is past `other` - negative when it is before - truncated toward
|
|
277
|
+
* zero, counted as dayjs counts. Hours and smaller are elapsed time. Days and weeks are calendar
|
|
278
|
+
* days in the zone: the wall clocks' difference, so a 23-hour daylight-saving day is one day.
|
|
279
|
+
* Months, quarters and years are anchored on the date with the later day of the month, then
|
|
280
|
+
* truncated, so `diff(a, b)` is always `-diff(b, a)`.
|
|
281
|
+
*/
|
|
282
|
+
diff(opts: {
|
|
283
|
+
value: TTemporalInput;
|
|
284
|
+
other: TTemporalInput;
|
|
285
|
+
unit: TTemporalUnit;
|
|
286
|
+
tz?: string;
|
|
287
|
+
}): number;
|
|
288
|
+
/**
|
|
289
|
+
* `-1`, `0` or `1` as `value` is before, in, or after the unit that holds `other`, in the zone.
|
|
290
|
+
* Without a unit the two instants are compared to the millisecond.
|
|
291
|
+
*/
|
|
292
|
+
compare(opts: {
|
|
293
|
+
value: TTemporalInput;
|
|
294
|
+
other: TTemporalInput;
|
|
295
|
+
unit?: TTemporalUnit;
|
|
296
|
+
tz?: string;
|
|
297
|
+
}): -1 | 0 | 1;
|
|
298
|
+
/**
|
|
299
|
+
* `value` relative to `base` (default: now) in words, through `Intl.RelativeTimeFormat`:
|
|
300
|
+
* `3 hours ago`, `in 2 days`. With a `unit`, it counts the unit's boundaries in the zone, so
|
|
301
|
+
* 23:00 yesterday seen at 01:00 is `yesterday` under `numeric: 'auto'`. Without one it says the
|
|
302
|
+
* largest whole unit that has elapsed, from years down to seconds.
|
|
303
|
+
*/
|
|
304
|
+
relative(opts: {
|
|
305
|
+
value: TTemporalInput;
|
|
306
|
+
base?: TTemporalInput;
|
|
307
|
+
unit?: TTemporalUnit;
|
|
308
|
+
numeric?: Intl.RelativeTimeFormatNumeric;
|
|
309
|
+
style?: Intl.RelativeTimeFormatStyle;
|
|
310
|
+
tz?: string;
|
|
311
|
+
locale?: string;
|
|
312
|
+
}): string;
|
|
313
|
+
/** A span of milliseconds as days, hours, minutes, seconds and milliseconds. A day is 24 hours. */
|
|
314
|
+
durationParts(opts: {
|
|
315
|
+
milliseconds: number;
|
|
316
|
+
}): ITemporalDurationParts;
|
|
317
|
+
/**
|
|
318
|
+
* A span of milliseconds written out: `compact` (the default) is `1d1h30m`; `narrow`, `short` and
|
|
319
|
+
* `long` use the locale's unit words. Zero units are left out and milliseconds dropped.
|
|
320
|
+
*/
|
|
321
|
+
formatDuration(opts: {
|
|
322
|
+
milliseconds: number;
|
|
323
|
+
style?: TTemporalDurationStyle;
|
|
324
|
+
/** A clock face instead of words: `HH:mm:ss`, `mm:ss`, `D[d] HH:mm`. The largest token carries the rest. */
|
|
325
|
+
pattern?: string;
|
|
326
|
+
/** Only the largest units that are not zero: `1` writes `2 giờ` for 2 hours 5 minutes. */
|
|
327
|
+
maxUnits?: number;
|
|
328
|
+
locale?: string;
|
|
329
|
+
}): string;
|
|
330
|
+
}
|
|
78
331
|
//# sourceMappingURL=types.d.ts.map
|