@fragiola/primitives 0.0.0-stage → 0.0.0
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 +21 -0
- package/README.md +50 -2
- package/dist/async-list-Bv6ff5Oj.js +81 -0
- package/dist/async-list-Bv6ff5Oj.js.map +1 -0
- package/dist/async-list.d.ts +2 -0
- package/dist/async-list.js +1 -0
- package/dist/calendar-keys-DGYpjLwv.d.ts +12 -0
- package/dist/calendar-system-B5U5HcPQ.d.ts +415 -0
- package/dist/calendar-systems-Daa6Q_ca.js +659 -0
- package/dist/calendar-systems-Daa6Q_ca.js.map +1 -0
- package/dist/calendar-systems.d.ts +3 -0
- package/dist/calendar-systems.js +1 -0
- package/dist/carousel-LRbWqbAx.js +375 -0
- package/dist/carousel-LRbWqbAx.js.map +1 -0
- package/dist/carousel.d.ts +2 -0
- package/dist/carousel.js +1 -0
- package/dist/cascade-B155Xvvv.js +64 -0
- package/dist/cascade-B155Xvvv.js.map +1 -0
- package/dist/cascade.d.ts +2 -0
- package/dist/cascade.js +1 -0
- package/dist/clipboard-Cy2cbGEW.js +33 -0
- package/dist/clipboard-Cy2cbGEW.js.map +1 -0
- package/dist/clipboard.d.ts +2 -0
- package/dist/clipboard.js +1 -0
- package/dist/collection-Dbk-PB5S.js +609 -0
- package/dist/collection-Dbk-PB5S.js.map +1 -0
- package/dist/collection.d.ts +2 -0
- package/dist/collection.js +3 -0
- package/dist/color-sURV5Irg.js +699 -0
- package/dist/color-sURV5Irg.js.map +1 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +1 -0
- package/dist/command-DueCXi65.js +104 -0
- package/dist/command-DueCXi65.js.map +1 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +1 -0
- package/dist/date-CrbFSJKQ.js +215 -0
- package/dist/date-CrbFSJKQ.js.map +1 -0
- package/dist/date.d.ts +4 -0
- package/dist/date.js +1 -0
- package/dist/direction-CTnVLpmd.d.ts +8 -0
- package/dist/direction-DJDPvnxJ.js +13 -0
- package/dist/direction-DJDPvnxJ.js.map +1 -0
- package/dist/direction.d.ts +2 -0
- package/dist/direction.js +1 -0
- package/dist/drag-session-CSr06B5v.js +41 -0
- package/dist/drag-session-CSr06B5v.js.map +1 -0
- package/dist/file-DSLtfzbi.js +263 -0
- package/dist/file-DSLtfzbi.js.map +1 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +1 -0
- package/dist/focus-BI-VvM0f.js +75 -0
- package/dist/focus-BI-VvM0f.js.map +1 -0
- package/dist/focus.d.ts +2 -0
- package/dist/focus.js +3 -0
- package/dist/form-DovwKtqz.js +501 -0
- package/dist/form-DovwKtqz.js.map +1 -0
- package/dist/form.d.ts +2 -0
- package/dist/form.js +1 -0
- package/dist/hover-BakyPYnC.js +62 -0
- package/dist/hover-BakyPYnC.js.map +1 -0
- package/dist/hover.d.ts +2 -0
- package/dist/hover.js +1 -0
- package/dist/id-B0Y8iZrc.js +13 -0
- package/dist/id-B0Y8iZrc.js.map +1 -0
- package/dist/id.d.ts +2 -0
- package/dist/id.js +1 -0
- package/dist/image-D4X_yRYw.js +44 -0
- package/dist/image-D4X_yRYw.js.map +1 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +1 -0
- package/dist/index-B0rwIZw9.d.ts +51 -0
- package/dist/index-B4wF1isn.d.ts +128 -0
- package/dist/index-BHiBRE01.d.ts +20 -0
- package/dist/index-BNlMm-0u.d.ts +17 -0
- package/dist/index-BapNrjY9.d.ts +48 -0
- package/dist/index-Bd-tVb7C.d.ts +6 -0
- package/dist/index-BjE8nDiX.d.ts +125 -0
- package/dist/index-BpbT-FsX.d.ts +117 -0
- package/dist/index-CBgGcTeX.d.ts +37 -0
- package/dist/index-CGThV_Md.d.ts +100 -0
- package/dist/index-CMig3TXL.d.ts +28 -0
- package/dist/index-CWFRduRd.d.ts +212 -0
- package/dist/index-CkrHWyU_.d.ts +33 -0
- package/dist/index-Cwu6f7y1.d.ts +18 -0
- package/dist/index-D10LDdR6.d.ts +139 -0
- package/dist/index-D146vm21.d.ts +104 -0
- package/dist/index-DGKhEvNr.d.ts +107 -0
- package/dist/index-DbAu4s16.d.ts +48 -0
- package/dist/index-DdaCj6IO.d.ts +54 -0
- package/dist/index-DeHcNdjC.d.ts +68 -0
- package/dist/index-DeR4ncrW.d.ts +93 -0
- package/dist/index-HIksgK0e.d.ts +70 -0
- package/dist/index-IZB0mlZl.d.ts +71 -0
- package/dist/index-IfDZj87U.d.ts +28 -0
- package/dist/index-SrTuVBms.d.ts +75 -0
- package/dist/index-T9UcYvkf.d.ts +339 -0
- package/dist/index-fRTojAoR.d.ts +31 -0
- package/dist/index-fuLUke9n.d.ts +6 -0
- package/dist/index-l63esAck.d.ts +104 -0
- package/dist/index-raSUg9U7.d.ts +38 -0
- package/dist/index-twgzPKvZ.d.ts +278 -0
- package/dist/index-wBpjRykh.d.ts +125 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +42 -0
- package/dist/inert-DlGToy3q.js +80 -0
- package/dist/inert-DlGToy3q.js.map +1 -0
- package/dist/inert.d.ts +2 -0
- package/dist/inert.js +1 -0
- package/dist/layer-stack-BEtzaFC1.js +118 -0
- package/dist/layer-stack-BEtzaFC1.js.map +1 -0
- package/dist/layers-C-N4rrZX.js +24 -0
- package/dist/layers-C-N4rrZX.js.map +1 -0
- package/dist/layers.d.ts +2 -0
- package/dist/layers.js +3 -0
- package/dist/list-navigation-CbWv4DK5.js +40 -0
- package/dist/list-navigation-CbWv4DK5.js.map +1 -0
- package/dist/month-year-BG5imFUq.js +108 -0
- package/dist/month-year-BG5imFUq.js.map +1 -0
- package/dist/month-year.d.ts +3 -0
- package/dist/month-year.js +1 -0
- package/dist/number-BFUio97d.js +316 -0
- package/dist/number-BFUio97d.js.map +1 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +1 -0
- package/dist/overlay-BwPyiM3T.js +78 -0
- package/dist/overlay-BwPyiM3T.js.map +1 -0
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.js +1 -0
- package/dist/pagination-BkVzaIGP.js +51 -0
- package/dist/pagination-BkVzaIGP.js.map +1 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +1 -0
- package/dist/plain-date-idQH1P6X.d.ts +29 -0
- package/dist/plain-date-time-B8PGahhe.d.ts +99 -0
- package/dist/pointer-CuDtD9XA.js +189 -0
- package/dist/pointer-CuDtD9XA.js.map +1 -0
- package/dist/pointer.d.ts +2 -0
- package/dist/pointer.js +3 -0
- package/dist/positioning-DDUQ75mB.js +148 -0
- package/dist/positioning-DDUQ75mB.js.map +1 -0
- package/dist/positioning.d.ts +2 -0
- package/dist/positioning.js +1 -0
- package/dist/presence-BhKDOmII.js +86 -0
- package/dist/presence-BhKDOmII.js.map +1 -0
- package/dist/presence.d.ts +2 -0
- package/dist/presence.js +1 -0
- package/dist/range-o0_GBhyY.js +158 -0
- package/dist/range-o0_GBhyY.js.map +1 -0
- package/dist/range.d.ts +2 -0
- package/dist/range.js +1 -0
- package/dist/scroll-area-BYNhv36t.js +447 -0
- package/dist/scroll-area-BYNhv36t.js.map +1 -0
- package/dist/scroll-area.d.ts +2 -0
- package/dist/scroll-area.js +1 -0
- package/dist/scroll-lock-JzRNOA1O.js +42 -0
- package/dist/scroll-lock-JzRNOA1O.js.map +1 -0
- package/dist/scroll-lock.d.ts +2 -0
- package/dist/scroll-lock.js +1 -0
- package/dist/segments-eRu5G_Bd.js +587 -0
- package/dist/segments-eRu5G_Bd.js.map +1 -0
- package/dist/segments.d.ts +3 -0
- package/dist/segments.js +1 -0
- package/dist/selection-Cor67w_V.js +287 -0
- package/dist/selection-Cor67w_V.js.map +1 -0
- package/dist/selection.d.ts +2 -0
- package/dist/selection.js +1 -0
- package/dist/swipe.d.ts +2 -0
- package/dist/swipe.js +1 -0
- package/dist/tabbable-BPiLssIv.js +35 -0
- package/dist/tabbable-BPiLssIv.js.map +1 -0
- package/dist/time-Ct6oq9kt.js +208 -0
- package/dist/time-Ct6oq9kt.js.map +1 -0
- package/dist/time-zone-DegkzwST.js +305 -0
- package/dist/time-zone-DegkzwST.js.map +1 -0
- package/dist/time-zone.d.ts +2 -0
- package/dist/time-zone.js +1 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +1 -0
- package/dist/toast-BjRpJalM.js +400 -0
- package/dist/toast-BjRpJalM.js.map +1 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +1 -0
- package/dist/unit-grid-DJy8lb5D.d.ts +21 -0
- package/dist/virtual-BlX1RuHD.js +306 -0
- package/dist/virtual-BlX1RuHD.js.map +1 -0
- package/dist/virtual.d.ts +2 -0
- package/dist/virtual.js +1 -0
- package/dist/watch-swipe-BIucfr9O.js +301 -0
- package/dist/watch-swipe-BIucfr9O.js.map +1 -0
- package/package.json +234 -3
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// src/time/plain-time.ts
|
|
2
|
+
const MS_PER_DAY$1 = 864e5;
|
|
3
|
+
const LIMITS = {
|
|
4
|
+
hour: 24,
|
|
5
|
+
minute: 60,
|
|
6
|
+
second: 60,
|
|
7
|
+
millisecond: 1e3
|
|
8
|
+
};
|
|
9
|
+
/** Milliseconds since midnight. */
|
|
10
|
+
function toMilliseconds(time) {
|
|
11
|
+
return ((time.hour * 60 + time.minute) * 60 + time.second) * 1e3 + time.millisecond;
|
|
12
|
+
}
|
|
13
|
+
/** The time `ms` milliseconds after midnight, wrapped into one day. */
|
|
14
|
+
function fromMilliseconds(ms) {
|
|
15
|
+
const day = (Math.trunc(ms) % MS_PER_DAY$1 + MS_PER_DAY$1) % MS_PER_DAY$1;
|
|
16
|
+
return {
|
|
17
|
+
hour: Math.floor(day / 36e5),
|
|
18
|
+
minute: Math.floor(day / 6e4) % 60,
|
|
19
|
+
second: Math.floor(day / 1e3) % 60,
|
|
20
|
+
millisecond: day % 1e3
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Builds a time, wrapping overflow around midnight (`plainTime(25)` is 01:00, `plainTime(0, -1)`
|
|
25
|
+
* is 23:59), as a clock does.
|
|
26
|
+
*/
|
|
27
|
+
function plainTime(hour, minute = 0, second = 0, millisecond = 0) {
|
|
28
|
+
return fromMilliseconds(((hour * 60 + minute) * 60 + second) * 1e3 + millisecond);
|
|
29
|
+
}
|
|
30
|
+
/** The local time of `now` (the clock the page sees). */
|
|
31
|
+
function currentTime(now = /* @__PURE__ */ new Date()) {
|
|
32
|
+
return {
|
|
33
|
+
hour: now.getHours(),
|
|
34
|
+
minute: now.getMinutes(),
|
|
35
|
+
second: now.getSeconds(),
|
|
36
|
+
millisecond: now.getMilliseconds()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Negative when `a` is earlier than `b`, positive when later, 0 when the same time. */
|
|
40
|
+
function compareTimes(a, b) {
|
|
41
|
+
return toMilliseconds(a) - toMilliseconds(b);
|
|
42
|
+
}
|
|
43
|
+
function isSameTime(a, b) {
|
|
44
|
+
return a != null && b != null && compareTimes(a, b) === 0;
|
|
45
|
+
}
|
|
46
|
+
/** Adds a duration, carrying between fields and wrapping around midnight (23:30 + 1 h = 00:30). */
|
|
47
|
+
function addTime(time, duration) {
|
|
48
|
+
return fromMilliseconds(toMilliseconds(time) + (duration.hours ?? 0) * 36e5 + (duration.minutes ?? 0) * 6e4 + (duration.seconds ?? 0) * 1e3 + (duration.milliseconds ?? 0));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Adds `amount` to one field only, wrapping within it and carrying nothing (10:59 + 1 minute is
|
|
52
|
+
* 10:00): the way a time field's segment steps (spec/date-field.md, "Keyboard").
|
|
53
|
+
*/
|
|
54
|
+
function cycleTime(time, field, amount) {
|
|
55
|
+
const limit = LIMITS[field];
|
|
56
|
+
return {
|
|
57
|
+
...time,
|
|
58
|
+
[field]: ((time[field] + amount) % limit + limit) % limit
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const pad$1 = (value, size = 2) => String(value).padStart(size, "0");
|
|
62
|
+
/**
|
|
63
|
+
* `14:30`, `14:30:05`, `14:30:05.120` (ISO 8601, as `<input type="time">` writes it). `auto`
|
|
64
|
+
* (the default) leaves out the seconds and milliseconds when they are 0; the other precisions
|
|
65
|
+
* write exactly their fields, dropping the smaller ones.
|
|
66
|
+
*/
|
|
67
|
+
function toIsoTime(time, precision = "auto") {
|
|
68
|
+
const base = `${pad$1(time.hour)}:${pad$1(time.minute)}`;
|
|
69
|
+
const resolved = precision !== "auto" ? precision : time.millisecond !== 0 ? "millisecond" : time.second !== 0 ? "second" : "minute";
|
|
70
|
+
if (resolved === "minute") return base;
|
|
71
|
+
const seconds = `${base}:${pad$1(time.second)}`;
|
|
72
|
+
return resolved === "second" ? seconds : `${seconds}.${pad$1(time.millisecond, 3)}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Parses `HH:MM`, `HH:MM:SS` or `HH:MM:SS.s` (one to three fraction digits); `null` when the text
|
|
76
|
+
* is not a valid time.
|
|
77
|
+
*/
|
|
78
|
+
function fromIsoTime(text) {
|
|
79
|
+
const match = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/.exec(text);
|
|
80
|
+
if (match === null) return null;
|
|
81
|
+
const hour = Number(match[1]);
|
|
82
|
+
const minute = Number(match[2]);
|
|
83
|
+
const second = match[3] === void 0 ? 0 : Number(match[3]);
|
|
84
|
+
const millisecond = match[4] === void 0 ? 0 : Number(match[4].padEnd(3, "0"));
|
|
85
|
+
if (hour > 23 || minute > 59 || second > 59) return null;
|
|
86
|
+
return {
|
|
87
|
+
hour,
|
|
88
|
+
minute,
|
|
89
|
+
second,
|
|
90
|
+
millisecond
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// src/time/plain-date-time.ts
|
|
94
|
+
const MS_PER_DAY = 864e5;
|
|
95
|
+
/** A UTC `Date` of the fields, years 0–99 included (`Date.UTC` reads them as 19xx). */
|
|
96
|
+
function utc(year, month, day, ms) {
|
|
97
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
98
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
99
|
+
date.setUTCHours(0, 0, 0, ms);
|
|
100
|
+
return date;
|
|
101
|
+
}
|
|
102
|
+
function fromUtc(date) {
|
|
103
|
+
return {
|
|
104
|
+
year: date.getUTCFullYear(),
|
|
105
|
+
month: date.getUTCMonth() + 1,
|
|
106
|
+
day: date.getUTCDate(),
|
|
107
|
+
hour: date.getUTCHours(),
|
|
108
|
+
minute: date.getUTCMinutes(),
|
|
109
|
+
second: date.getUTCSeconds(),
|
|
110
|
+
millisecond: date.getUTCMilliseconds()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function timeMilliseconds(time) {
|
|
114
|
+
return ((time.hour ?? 0) * 60 + (time.minute ?? 0)) * 6e4 + (time.second ?? 0) * 1e3 + (time.millisecond ?? 0);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Builds a date and time from a date and a time (midnight when `time` is left out), normalizing
|
|
118
|
+
* overflow (`{ hour: 24 }` is midnight of the next day).
|
|
119
|
+
*/
|
|
120
|
+
function plainDateTime(date, time = {}) {
|
|
121
|
+
return fromUtc(utc(date.year, date.month, date.day, timeMilliseconds(time)));
|
|
122
|
+
}
|
|
123
|
+
/** The local date and time of `now` (the clock the page sees). */
|
|
124
|
+
function currentDateTime(now = /* @__PURE__ */ new Date()) {
|
|
125
|
+
return {
|
|
126
|
+
year: now.getFullYear(),
|
|
127
|
+
month: now.getMonth() + 1,
|
|
128
|
+
day: now.getDate(),
|
|
129
|
+
hour: now.getHours(),
|
|
130
|
+
minute: now.getMinutes(),
|
|
131
|
+
second: now.getSeconds(),
|
|
132
|
+
millisecond: now.getMilliseconds()
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** The date of a date and time. */
|
|
136
|
+
function toPlainDate(value) {
|
|
137
|
+
return {
|
|
138
|
+
year: value.year,
|
|
139
|
+
month: value.month,
|
|
140
|
+
day: value.day
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** The time of a date and time. */
|
|
144
|
+
function toPlainTime(value) {
|
|
145
|
+
return {
|
|
146
|
+
hour: value.hour,
|
|
147
|
+
minute: value.minute,
|
|
148
|
+
second: value.second,
|
|
149
|
+
millisecond: value.millisecond
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Negative when `a` is before `b`, positive when after, 0 when the same instant of the wall
|
|
154
|
+
* clock. A `PlainDate` counts as its midnight, so a date and time compares with a date bound.
|
|
155
|
+
*/
|
|
156
|
+
function compareDateTimes(a, b) {
|
|
157
|
+
return a.year - b.year || a.month - b.month || a.day - b.day || compareTimes({
|
|
158
|
+
hour: a.hour ?? 0,
|
|
159
|
+
minute: a.minute ?? 0,
|
|
160
|
+
second: a.second ?? 0,
|
|
161
|
+
millisecond: a.millisecond ?? 0
|
|
162
|
+
}, {
|
|
163
|
+
hour: b.hour ?? 0,
|
|
164
|
+
minute: b.minute ?? 0,
|
|
165
|
+
second: b.second ?? 0,
|
|
166
|
+
millisecond: b.millisecond ?? 0
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function isSameDateTime(a, b) {
|
|
170
|
+
return a != null && b != null && compareDateTimes(a, b) === 0;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Adds a duration: the years and months first (the day clamped to the month's last day, as the
|
|
174
|
+
* calendars' `addMonths`), then the days and the time, carrying across midnight.
|
|
175
|
+
*/
|
|
176
|
+
function addDateTime(value, duration) {
|
|
177
|
+
const months = value.year * 12 + (value.month - 1) + (duration.years ?? 0) * 12 + (duration.months ?? 0);
|
|
178
|
+
const year = Math.floor(months / 12);
|
|
179
|
+
const month = months % 12 + 1;
|
|
180
|
+
const last = utc(year, month + 1, 0, 0).getUTCDate();
|
|
181
|
+
return fromUtc(utc(year, month, Math.min(value.day, last), timeMilliseconds(value) + (duration.days ?? 0) * MS_PER_DAY + (duration.hours ?? 0) * 36e5 + (duration.minutes ?? 0) * 6e4 + (duration.seconds ?? 0) * 1e3 + (duration.milliseconds ?? 0)));
|
|
182
|
+
}
|
|
183
|
+
const pad = (value, size = 2) => String(value).padStart(size, "0");
|
|
184
|
+
/** `2026-11-23T14:30` (ISO 8601, as `<input type="datetime-local">` writes it); see `toIsoTime`. */
|
|
185
|
+
function toIsoDateTime(value, precision = "auto") {
|
|
186
|
+
return `${pad(value.year, 4)}-${pad(value.month)}-${pad(value.day)}T${toIsoTime(value, precision)}`;
|
|
187
|
+
}
|
|
188
|
+
/** Parses `YYYY-MM-DDTHH:MM[:SS[.sss]]`; `null` when the text is not a valid date and time. */
|
|
189
|
+
function fromIsoDateTime(text) {
|
|
190
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(.+)$/.exec(text);
|
|
191
|
+
if (match === null) return null;
|
|
192
|
+
const time = fromIsoTime(match[4]);
|
|
193
|
+
if (time === null) return null;
|
|
194
|
+
const year = Number(match[1]);
|
|
195
|
+
const month = Number(match[2]);
|
|
196
|
+
const day = Number(match[3]);
|
|
197
|
+
const date = fromUtc(utc(year, month, day, 0));
|
|
198
|
+
if (date.year !== year || date.month !== month || date.day !== day) return null;
|
|
199
|
+
return {
|
|
200
|
+
year,
|
|
201
|
+
month,
|
|
202
|
+
day,
|
|
203
|
+
...time
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export { toIsoTime as _, isSameDateTime as a, toPlainDate as c, compareTimes as d, currentTime as f, plainTime as g, isSameTime as h, fromIsoDateTime as i, toPlainTime as l, fromIsoTime as m, compareDateTimes as n, plainDateTime as o, cycleTime as p, currentDateTime as r, toIsoDateTime as s, addDateTime as t, addTime as u };
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=time-Ct6oq9kt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-Ct6oq9kt.js","names":["MS_PER_DAY","pad"],"sources":["../src/time/plain-time.ts","../src/time/plain-date-time.ts"],"sourcesContent":["/**\n * A wall-clock time with no date and no time zone (spec/date-field.md, \"Values\"). `hour` is\n * 0–23, `minute` and `second` 0–59, `millisecond` 0–999. Values are plain, immutable objects:\n * every function returns a new one.\n */\nexport interface PlainTime {\n readonly hour: number;\n readonly minute: number;\n readonly second: number;\n readonly millisecond: number;\n}\n\n/** A field of a time, the unit of {@link addTime} and {@link cycleTime}. */\nexport type TimeField = \"hour\" | \"minute\" | \"second\" | \"millisecond\";\n\n/** An amount to add to a time, field by field (each may be negative). */\n/**\n * A range of times of day, `{ start, end }` (a TimeRangeField's value, spec/date-range-field.md):\n * the time counterpart of `/date`'s `DateRange`. An end before its start is a value too, an\n * invalid one (no range across midnight).\n */\nexport interface TimeRange {\n readonly start: PlainTime;\n readonly end: PlainTime;\n}\n\nexport interface TimeDuration {\n readonly hours?: number;\n readonly minutes?: number;\n readonly seconds?: number;\n readonly milliseconds?: number;\n}\n\nconst MS_PER_DAY = 86_400_000;\n\nconst LIMITS: Readonly<Record<TimeField, number>> = {\n hour: 24,\n minute: 60,\n second: 60,\n millisecond: 1000,\n};\n\n/** Milliseconds since midnight. */\nfunction toMilliseconds(time: PlainTime): number {\n return (\n ((time.hour * 60 + time.minute) * 60 + time.second) * 1000 +\n time.millisecond\n );\n}\n\n/** The time `ms` milliseconds after midnight, wrapped into one day. */\nfunction fromMilliseconds(ms: number): PlainTime {\n const day = ((Math.trunc(ms) % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY;\n return {\n hour: Math.floor(day / 3_600_000),\n minute: Math.floor(day / 60_000) % 60,\n second: Math.floor(day / 1000) % 60,\n millisecond: day % 1000,\n };\n}\n\n/**\n * Builds a time, wrapping overflow around midnight (`plainTime(25)` is 01:00, `plainTime(0, -1)`\n * is 23:59), as a clock does.\n */\nexport function plainTime(\n hour: number,\n minute = 0,\n second = 0,\n millisecond = 0,\n): PlainTime {\n return fromMilliseconds(\n ((hour * 60 + minute) * 60 + second) * 1000 + millisecond,\n );\n}\n\n/** The local time of `now` (the clock the page sees). */\nexport function currentTime(now: Date = new Date()): PlainTime {\n return {\n hour: now.getHours(),\n minute: now.getMinutes(),\n second: now.getSeconds(),\n millisecond: now.getMilliseconds(),\n };\n}\n\n/** Negative when `a` is earlier than `b`, positive when later, 0 when the same time. */\nexport function compareTimes(a: PlainTime, b: PlainTime): number {\n return toMilliseconds(a) - toMilliseconds(b);\n}\n\nexport function isSameTime(\n a: PlainTime | null | undefined,\n b: PlainTime | null | undefined,\n): boolean {\n return a != null && b != null && compareTimes(a, b) === 0;\n}\n\n/** Adds a duration, carrying between fields and wrapping around midnight (23:30 + 1 h = 00:30). */\nexport function addTime(time: PlainTime, duration: TimeDuration): PlainTime {\n return fromMilliseconds(\n toMilliseconds(time) +\n (duration.hours ?? 0) * 3_600_000 +\n (duration.minutes ?? 0) * 60_000 +\n (duration.seconds ?? 0) * 1000 +\n (duration.milliseconds ?? 0),\n );\n}\n\n/**\n * Adds `amount` to one field only, wrapping within it and carrying nothing (10:59 + 1 minute is\n * 10:00): the way a time field's segment steps (spec/date-field.md, \"Keyboard\").\n */\nexport function cycleTime(\n time: PlainTime,\n field: TimeField,\n amount: number,\n): PlainTime {\n const limit = LIMITS[field];\n return {\n ...time,\n [field]: (((time[field] + amount) % limit) + limit) % limit,\n };\n}\n\n/** How many fields an ISO time writes: `auto` writes the shortest exact form. */\nexport type IsoTimePrecision = \"auto\" | \"minute\" | \"second\" | \"millisecond\";\n\nconst pad = (value: number, size = 2) => String(value).padStart(size, \"0\");\n\n/**\n * `14:30`, `14:30:05`, `14:30:05.120` (ISO 8601, as `<input type=\"time\">` writes it). `auto`\n * (the default) leaves out the seconds and milliseconds when they are 0; the other precisions\n * write exactly their fields, dropping the smaller ones.\n */\nexport function toIsoTime(\n time: PlainTime,\n precision: IsoTimePrecision = \"auto\",\n): string {\n const base = `${pad(time.hour)}:${pad(time.minute)}`;\n const resolved =\n precision !== \"auto\"\n ? precision\n : time.millisecond !== 0\n ? \"millisecond\"\n : time.second !== 0\n ? \"second\"\n : \"minute\";\n if (resolved === \"minute\") {\n return base;\n }\n const seconds = `${base}:${pad(time.second)}`;\n return resolved === \"second\"\n ? seconds\n : `${seconds}.${pad(time.millisecond, 3)}`;\n}\n\n/**\n * Parses `HH:MM`, `HH:MM:SS` or `HH:MM:SS.s` (one to three fraction digits); `null` when the text\n * is not a valid time.\n */\nexport function fromIsoTime(text: string): PlainTime | null {\n const match = /^(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?$/.exec(text);\n if (match === null) {\n return null;\n }\n const hour = Number(match[1]);\n const minute = Number(match[2]);\n const second = match[3] === undefined ? 0 : Number(match[3]);\n const millisecond =\n match[4] === undefined ? 0 : Number(match[4].padEnd(3, \"0\"));\n if (hour > 23 || minute > 59 || second > 59) {\n return null;\n }\n return { hour, minute, second, millisecond };\n}\n","import type { PlainDate } from \"../date/plain-date.ts\";\nimport {\n compareTimes,\n fromIsoTime,\n type IsoTimePrecision,\n type PlainTime,\n type TimeDuration,\n toIsoTime,\n} from \"./plain-time.ts\";\n\n/**\n * A date and a wall-clock time with no time zone (spec/date-field.md, \"Values\"): a\n * {@link PlainDate} and a {@link PlainTime} in one flat object, so it is also a `PlainDate` (the\n * date math and the calendars take it) and a `PlainTime`.\n */\nexport interface PlainDateTime extends PlainDate, PlainTime {}\n\n/** An amount to add to a date and time, field by field (each may be negative). */\nexport interface DateTimeDuration extends TimeDuration {\n readonly years?: number;\n readonly months?: number;\n readonly days?: number;\n}\n\nconst MS_PER_DAY = 86_400_000;\n\n/** A UTC `Date` of the fields, years 0–99 included (`Date.UTC` reads them as 19xx). */\nfunction utc(year: number, month: number, day: number, ms: number): Date {\n const date = new Date(0);\n date.setUTCFullYear(year, month - 1, day);\n date.setUTCHours(0, 0, 0, ms);\n return date;\n}\n\nfunction fromUtc(date: Date): PlainDateTime {\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n hour: date.getUTCHours(),\n minute: date.getUTCMinutes(),\n second: date.getUTCSeconds(),\n millisecond: date.getUTCMilliseconds(),\n };\n}\n\nfunction timeMilliseconds(time: Partial<PlainTime>): number {\n return (\n ((time.hour ?? 0) * 60 + (time.minute ?? 0)) * 60_000 +\n (time.second ?? 0) * 1000 +\n (time.millisecond ?? 0)\n );\n}\n\n/**\n * Builds a date and time from a date and a time (midnight when `time` is left out), normalizing\n * overflow (`{ hour: 24 }` is midnight of the next day).\n */\nexport function plainDateTime(\n date: PlainDate,\n time: Partial<PlainTime> = {},\n): PlainDateTime {\n return fromUtc(\n utc(date.year, date.month, date.day, timeMilliseconds(time)),\n );\n}\n\n/** The local date and time of `now` (the clock the page sees). */\nexport function currentDateTime(now: Date = new Date()): PlainDateTime {\n return {\n year: now.getFullYear(),\n month: now.getMonth() + 1,\n day: now.getDate(),\n hour: now.getHours(),\n minute: now.getMinutes(),\n second: now.getSeconds(),\n millisecond: now.getMilliseconds(),\n };\n}\n\n/** The date of a date and time. */\nexport function toPlainDate(value: PlainDate): PlainDate {\n return { year: value.year, month: value.month, day: value.day };\n}\n\n/** The time of a date and time. */\nexport function toPlainTime(value: PlainTime): PlainTime {\n return {\n hour: value.hour,\n minute: value.minute,\n second: value.second,\n millisecond: value.millisecond,\n };\n}\n\n/**\n * Negative when `a` is before `b`, positive when after, 0 when the same instant of the wall\n * clock. A `PlainDate` counts as its midnight, so a date and time compares with a date bound.\n */\nexport function compareDateTimes(\n a: PlainDate & Partial<PlainTime>,\n b: PlainDate & Partial<PlainTime>,\n): number {\n return (\n a.year - b.year ||\n a.month - b.month ||\n a.day - b.day ||\n compareTimes(\n {\n hour: a.hour ?? 0,\n minute: a.minute ?? 0,\n second: a.second ?? 0,\n millisecond: a.millisecond ?? 0,\n },\n {\n hour: b.hour ?? 0,\n minute: b.minute ?? 0,\n second: b.second ?? 0,\n millisecond: b.millisecond ?? 0,\n },\n )\n );\n}\n\nexport function isSameDateTime(\n a: PlainDateTime | null | undefined,\n b: PlainDateTime | null | undefined,\n): boolean {\n return a != null && b != null && compareDateTimes(a, b) === 0;\n}\n\n/**\n * Adds a duration: the years and months first (the day clamped to the month's last day, as the\n * calendars' `addMonths`), then the days and the time, carrying across midnight.\n */\nexport function addDateTime(\n value: PlainDateTime,\n duration: DateTimeDuration,\n): PlainDateTime {\n const months =\n value.year * 12 +\n (value.month - 1) +\n (duration.years ?? 0) * 12 +\n (duration.months ?? 0);\n const year = Math.floor(months / 12);\n const month = (months % 12) + 1;\n const last = utc(year, month + 1, 0, 0).getUTCDate();\n const day = Math.min(value.day, last);\n const ms =\n timeMilliseconds(value) +\n (duration.days ?? 0) * MS_PER_DAY +\n (duration.hours ?? 0) * 3_600_000 +\n (duration.minutes ?? 0) * 60_000 +\n (duration.seconds ?? 0) * 1000 +\n (duration.milliseconds ?? 0);\n return fromUtc(utc(year, month, day, ms));\n}\n\nconst pad = (value: number, size = 2) => String(value).padStart(size, \"0\");\n\n/** `2026-11-23T14:30` (ISO 8601, as `<input type=\"datetime-local\">` writes it); see `toIsoTime`. */\nexport function toIsoDateTime(\n value: PlainDateTime,\n precision: IsoTimePrecision = \"auto\",\n): string {\n return `${pad(value.year, 4)}-${pad(value.month)}-${pad(value.day)}T${toIsoTime(value, precision)}`;\n}\n\n/** Parses `YYYY-MM-DDTHH:MM[:SS[.sss]]`; `null` when the text is not a valid date and time. */\nexport function fromIsoDateTime(text: string): PlainDateTime | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})T(.+)$/.exec(text);\n if (match === null) {\n return null;\n }\n const time = fromIsoTime(match[4] as string);\n if (time === null) {\n return null;\n }\n const year = Number(match[1]);\n const month = Number(match[2]);\n const day = Number(match[3]);\n const date = fromUtc(utc(year, month, day, 0));\n if (date.year !== year || date.month !== month || date.day !== day) {\n return null;\n }\n return { year, month, day, ...time };\n}\n"],"mappings":";AAiCA,MAAMA,eAAa;AAEnB,MAAM,SAA8C;CAChD,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,aAAa;AACjB;;AAGA,SAAS,eA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-time.ts
|
|
2
|
+
const HOUR = 36e5;
|
|
3
|
+
const DAY = 864e5;
|
|
4
|
+
const formats = /* @__PURE__ */ new Map();
|
|
5
|
+
const pad = (value, size = 2) => String(Math.abs(value)).padStart(size, "0");
|
|
6
|
+
/** `2026-11-23T14:30` at a precision (`/time`'s `toIsoDateTime`). */
|
|
7
|
+
function toIsoDateTime(value, precision = "auto") {
|
|
8
|
+
const resolved = precision !== "auto" ? precision : value.millisecond !== 0 ? "millisecond" : value.second !== 0 ? "second" : "minute";
|
|
9
|
+
let text = `${value.year < 0 ? "-" : ""}${pad(value.year, 4)}-${pad(value.month)}-${pad(value.day)}T${pad(value.hour)}:${pad(value.minute)}`;
|
|
10
|
+
if (resolved !== "minute") text += `:${pad(value.second)}`;
|
|
11
|
+
return resolved === "millisecond" ? `${text}.${pad(value.millisecond, 3)}` : text;
|
|
12
|
+
}
|
|
13
|
+
/** Parses `YYYY-MM-DDTHH:MM[:SS[.sss]]` (`/time`'s `fromIsoDateTime`); `null` when invalid. */
|
|
14
|
+
function fromIsoDateTime(text) {
|
|
15
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/.exec(text);
|
|
16
|
+
if (match === null) return null;
|
|
17
|
+
const [year, month, day, hour, minute] = match.slice(1, 6).map(Number);
|
|
18
|
+
const value = {
|
|
19
|
+
year,
|
|
20
|
+
month,
|
|
21
|
+
day,
|
|
22
|
+
hour,
|
|
23
|
+
minute,
|
|
24
|
+
second: Number(match[6] ?? 0),
|
|
25
|
+
millisecond: Number((match[7] ?? "0").padEnd(3, "0"))
|
|
26
|
+
};
|
|
27
|
+
const back = fromWallTime(wallTime(value));
|
|
28
|
+
return back.month === month && back.day === day && hour < 24 && minute < 60 && value.second < 60 ? value : null;
|
|
29
|
+
}
|
|
30
|
+
/** The years, months and days of a duration added to a wall time, the day clamped to its month. */
|
|
31
|
+
function addDate(value, years, months, days) {
|
|
32
|
+
const total = value.year * 12 + value.month - 1 + years * 12 + months;
|
|
33
|
+
const year = Math.floor(total / 12);
|
|
34
|
+
const month = total - year * 12 + 1;
|
|
35
|
+
const last = fromWallTime(wallTime({
|
|
36
|
+
...value,
|
|
37
|
+
year,
|
|
38
|
+
month: month + 1,
|
|
39
|
+
day: 0
|
|
40
|
+
})).day;
|
|
41
|
+
return fromWallTime(wallTime({
|
|
42
|
+
...value,
|
|
43
|
+
year,
|
|
44
|
+
month,
|
|
45
|
+
day: Math.min(value.day, last)
|
|
46
|
+
}) + days * DAY);
|
|
47
|
+
}
|
|
48
|
+
/** The wall-clock fields' UTC milliseconds (as if the zone were UTC), years 0–99 included. */
|
|
49
|
+
function wallTime(value) {
|
|
50
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
51
|
+
date.setUTCFullYear(value.year, value.month - 1, value.day);
|
|
52
|
+
date.setUTCHours(value.hour, value.minute, value.second, value.millisecond);
|
|
53
|
+
return date.getTime();
|
|
54
|
+
}
|
|
55
|
+
function fromWallTime(ms) {
|
|
56
|
+
const date = new Date(ms);
|
|
57
|
+
return {
|
|
58
|
+
year: date.getUTCFullYear(),
|
|
59
|
+
month: date.getUTCMonth() + 1,
|
|
60
|
+
day: date.getUTCDate(),
|
|
61
|
+
hour: date.getUTCHours(),
|
|
62
|
+
minute: date.getUTCMinutes(),
|
|
63
|
+
second: date.getUTCSeconds(),
|
|
64
|
+
millisecond: date.getUTCMilliseconds()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function zoneFormat(timeZone) {
|
|
68
|
+
let format = formats.get(timeZone);
|
|
69
|
+
if (format === void 0) {
|
|
70
|
+
format = new Intl.DateTimeFormat("en-US", {
|
|
71
|
+
timeZone,
|
|
72
|
+
hourCycle: "h23",
|
|
73
|
+
era: "short",
|
|
74
|
+
year: "numeric",
|
|
75
|
+
month: "numeric",
|
|
76
|
+
day: "numeric",
|
|
77
|
+
hour: "numeric",
|
|
78
|
+
minute: "numeric",
|
|
79
|
+
second: "numeric"
|
|
80
|
+
});
|
|
81
|
+
formats.set(timeZone, format);
|
|
82
|
+
}
|
|
83
|
+
return format;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The zone's offset from UTC at an instant, in milliseconds, read from `Intl` (the wall-clock
|
|
87
|
+
* fields it writes there, less the instant).
|
|
88
|
+
*/
|
|
89
|
+
function offsetAt(timeZone, epochMs) {
|
|
90
|
+
const second = Math.floor(epochMs / 1e3) * 1e3;
|
|
91
|
+
const fields = {};
|
|
92
|
+
for (const part of zoneFormat(timeZone).formatToParts(second)) fields[part.type] = part.value;
|
|
93
|
+
return wallTime({
|
|
94
|
+
year: fields.era === "BC" || fields.era === "B" ? 1 - Number(fields.year) : Number(fields.year),
|
|
95
|
+
month: Number(fields.month),
|
|
96
|
+
day: Number(fields.day),
|
|
97
|
+
hour: Number(fields.hour) % 24,
|
|
98
|
+
minute: Number(fields.minute),
|
|
99
|
+
second: Number(fields.second),
|
|
100
|
+
millisecond: 0
|
|
101
|
+
}) - second;
|
|
102
|
+
}
|
|
103
|
+
/** The zone the page runs in (`Intl`'s default). */
|
|
104
|
+
function localTimeZone() {
|
|
105
|
+
return new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
106
|
+
}
|
|
107
|
+
/** The instant (epoch milliseconds) of a zoned date and time. */
|
|
108
|
+
function toInstant(value) {
|
|
109
|
+
return wallTime(value) - value.offset;
|
|
110
|
+
}
|
|
111
|
+
/** The date and time an instant (epoch milliseconds or a `Date`) has in a zone. */
|
|
112
|
+
function fromInstant(instant, timeZone) {
|
|
113
|
+
const ms = typeof instant === "number" ? instant : instant.getTime();
|
|
114
|
+
const offset = offsetAt(timeZone, ms);
|
|
115
|
+
return {
|
|
116
|
+
...fromWallTime(ms + offset),
|
|
117
|
+
timeZone,
|
|
118
|
+
offset
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The instants a wall-clock time names in a zone: one, two in an overlap (earlier first), none in
|
|
123
|
+
* a gap.
|
|
124
|
+
*/
|
|
125
|
+
function candidates(timeZone, wall) {
|
|
126
|
+
const before = offsetAt(timeZone, wall - DAY);
|
|
127
|
+
const after = offsetAt(timeZone, wall + DAY);
|
|
128
|
+
const found = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const offset of [before, after]) {
|
|
130
|
+
const instant = wall - offset;
|
|
131
|
+
if (offsetAt(timeZone, instant) === offset) found.add(instant);
|
|
132
|
+
}
|
|
133
|
+
return [...found].sort((a, b) => a - b);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A wall-clock date and time in a zone (spec/time-zones.md, "DST gaps and overlaps"), resolved
|
|
137
|
+
* with `disambiguation` when the zone skips or repeats it. In a gap, `compatible` and `later` move
|
|
138
|
+
* it forward by the gap (02:30 becomes 03:30), `earlier` back (01:30); `reject` throws.
|
|
139
|
+
*/
|
|
140
|
+
function toZoned(value, timeZone, disambiguation = "compatible") {
|
|
141
|
+
const wall = wallTime(value);
|
|
142
|
+
const found = candidates(timeZone, wall);
|
|
143
|
+
let instant;
|
|
144
|
+
if (found.length === 1) instant = found[0];
|
|
145
|
+
else if (disambiguation === "reject") throw new RangeError(`${toIsoDateTime(value)} is ${found.length === 0 ? "skipped" : "repeated"} in ${timeZone}`);
|
|
146
|
+
else if (found.length === 2) instant = disambiguation === "later" ? found[1] : found[0];
|
|
147
|
+
else {
|
|
148
|
+
const before = offsetAt(timeZone, wall - DAY);
|
|
149
|
+
const after = offsetAt(timeZone, wall + DAY);
|
|
150
|
+
instant = wall - (disambiguation === "earlier" ? after : before);
|
|
151
|
+
}
|
|
152
|
+
return fromInstant(instant, timeZone);
|
|
153
|
+
}
|
|
154
|
+
/** The same instant in another zone. */
|
|
155
|
+
function toTimeZone(value, timeZone) {
|
|
156
|
+
return value.timeZone === timeZone ? value : fromInstant(toInstant(value), timeZone);
|
|
157
|
+
}
|
|
158
|
+
/** Negative when `a` is the earlier instant, positive when later, 0 when the same. */
|
|
159
|
+
function compareZoned(a, b) {
|
|
160
|
+
return toInstant(a) - toInstant(b);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Adds a duration as Temporal's `ZonedDateTime#add`: the years, months and days to the wall-clock
|
|
164
|
+
* date (resolved `compatible`, so a day added across a DST change keeps its wall time), then the
|
|
165
|
+
* time in exact time (an hour added across a gap is one real hour).
|
|
166
|
+
*/
|
|
167
|
+
function addZoned(value, duration) {
|
|
168
|
+
const { years, months, days, ...time } = duration;
|
|
169
|
+
let result = value;
|
|
170
|
+
if (years || months || days) result = toZoned(addDate(value, years ?? 0, months ?? 0, days ?? 0), value.timeZone);
|
|
171
|
+
const ms = (time.hours ?? 0) * HOUR + (time.minutes ?? 0) * 6e4 + (time.seconds ?? 0) * 1e3 + (time.milliseconds ?? 0);
|
|
172
|
+
return ms === 0 ? result : fromInstant(toInstant(result) + ms, value.timeZone);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Steps one time field and wraps within its range, carrying nothing (the date segments' and
|
|
176
|
+
* React Aria's `cycle`): the hour walks the day's real hours (23 on a spring-forward day, 25 on a
|
|
177
|
+
* fall-back one, the repeated hour twice); a minute or second keeps the offset it had when the
|
|
178
|
+
* wall time still exists there, else resolves with `disambiguation`.
|
|
179
|
+
*/
|
|
180
|
+
function cycleZoned(value, field, amount, disambiguation = "compatible") {
|
|
181
|
+
const { timeZone } = value;
|
|
182
|
+
if (field === "hour") {
|
|
183
|
+
const start = toInstant(toZoned({
|
|
184
|
+
...value,
|
|
185
|
+
hour: 0,
|
|
186
|
+
minute: 0,
|
|
187
|
+
second: 0,
|
|
188
|
+
millisecond: 0
|
|
189
|
+
}, timeZone));
|
|
190
|
+
const end = toInstant(toZoned(addDate({
|
|
191
|
+
...value,
|
|
192
|
+
hour: 0,
|
|
193
|
+
minute: 0,
|
|
194
|
+
second: 0,
|
|
195
|
+
millisecond: 0
|
|
196
|
+
}, 0, 0, 1), timeZone));
|
|
197
|
+
const hours = Math.round((end - start) / HOUR);
|
|
198
|
+
const current = Math.floor((toInstant(value) - start) / HOUR);
|
|
199
|
+
const target = ((current + amount) % hours + hours) % hours;
|
|
200
|
+
return fromInstant(toInstant(value) + (target - current) * HOUR, timeZone);
|
|
201
|
+
}
|
|
202
|
+
const size = 60;
|
|
203
|
+
const wall = {
|
|
204
|
+
...value,
|
|
205
|
+
[field]: ((value[field] + amount) % size + size) % size
|
|
206
|
+
};
|
|
207
|
+
if (offsetAt(timeZone, wallTime(wall) - value.offset) === value.offset) return {
|
|
208
|
+
...wall,
|
|
209
|
+
timeZone,
|
|
210
|
+
offset: value.offset
|
|
211
|
+
};
|
|
212
|
+
return toZoned(wall, timeZone, disambiguation);
|
|
213
|
+
}
|
|
214
|
+
/** `+05:30`, `-04:00` (`+00:00` for UTC); seconds only when the offset has them. */
|
|
215
|
+
function toIsoOffset(offset) {
|
|
216
|
+
const sign = offset < 0 ? "-" : "+";
|
|
217
|
+
const total = Math.round(Math.abs(offset) / 1e3);
|
|
218
|
+
const hours = Math.floor(total / 3600);
|
|
219
|
+
const minutes = Math.floor(total % 3600 / 60);
|
|
220
|
+
const seconds = total % 60;
|
|
221
|
+
return `${sign}${pad(hours)}:${pad(minutes)}${seconds ? `:${pad(seconds)}` : ""}`;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* `2026-03-08T03:30-04:00[America/New_York]` (RFC 9557, Temporal's `ZonedDateTime#toString`): the
|
|
225
|
+
* wall time (see `toIsoDateTime` for `precision`), the offset and the zone.
|
|
226
|
+
*/
|
|
227
|
+
function toIsoZoned(value, precision = "auto") {
|
|
228
|
+
return `${toIsoDateTime(value, precision)}${toIsoOffset(value.offset)}[${value.timeZone}]`;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Parses `YYYY-MM-DDTHH:MM[:SS[.sss]][±HH:MM][<zone>]`; the offset, when it is one the zone has
|
|
232
|
+
* at that wall time, picks it (one of an overlap's two), else the wall time is resolved with
|
|
233
|
+
* `disambiguation`. `null` when the text is not one, or its zone is unknown.
|
|
234
|
+
*/
|
|
235
|
+
function fromIsoZoned(text, disambiguation = "compatible") {
|
|
236
|
+
const match = /^([^[]+?)(Z|[+-]\d{2}:\d{2}(?::\d{2})?)?\[([^\]]+)\]$/.exec(text);
|
|
237
|
+
if (match === null) return null;
|
|
238
|
+
const wall = fromIsoDateTime(match[1]);
|
|
239
|
+
const timeZone = match[3];
|
|
240
|
+
if (wall === null) return null;
|
|
241
|
+
try {
|
|
242
|
+
zoneFormat(timeZone);
|
|
243
|
+
} catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
const offsetText = match[2];
|
|
247
|
+
if (offsetText !== void 0 && offsetText !== "Z") {
|
|
248
|
+
const [hours, minutes, seconds] = offsetText.slice(1).split(":").map(Number);
|
|
249
|
+
const offset = (offsetText[0] === "-" ? -1 : 1) * (((hours ?? 0) * 60 + (minutes ?? 0)) * 60 + (seconds ?? 0)) * 1e3;
|
|
250
|
+
if (offsetAt(timeZone, wallTime(wall) - offset) === offset) return {
|
|
251
|
+
...wall,
|
|
252
|
+
timeZone,
|
|
253
|
+
offset
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return toZoned(wall, timeZone, disambiguation);
|
|
257
|
+
}
|
|
258
|
+
/** The zone's name at the value's instant, from `Intl` (`timeZoneName`, default `short`: "EST"). */
|
|
259
|
+
function formatTimeZoneName(locale, value, style = "short") {
|
|
260
|
+
return new Intl.DateTimeFormat(locale, {
|
|
261
|
+
timeZone: value.timeZone,
|
|
262
|
+
timeZoneName: style
|
|
263
|
+
}).formatToParts(toInstant(value)).find((part) => part.type === "timeZoneName")?.value.replace(/[ ]/g, " ") ?? value.timeZone;
|
|
264
|
+
}
|
|
265
|
+
// src/time-zone/time-zone.ts
|
|
266
|
+
/** The time zone `id` (default: the page's own) for a date field or picker's `timeZone`. */
|
|
267
|
+
function timeZone(id = localTimeZone()) {
|
|
268
|
+
const choose = (value, disambiguation) => toZoned(value, id, disambiguation === "reject" ? "compatible" : disambiguation);
|
|
269
|
+
return {
|
|
270
|
+
id,
|
|
271
|
+
resolve: (value, disambiguation) => toZoned(value, id, disambiguation),
|
|
272
|
+
convert: (value) => toTimeZone(value, id),
|
|
273
|
+
at: (instant) => fromInstant(instant, id),
|
|
274
|
+
name: (locale, value) => formatTimeZoneName(locale, value),
|
|
275
|
+
toIso: toIsoZoned,
|
|
276
|
+
choose,
|
|
277
|
+
segmentOptions: (options, intl) => options.hideTimeZone || !intl.year || !intl.hour ? intl : {
|
|
278
|
+
...intl,
|
|
279
|
+
timeZoneName: "short"
|
|
280
|
+
},
|
|
281
|
+
wallTime: (value) => "offset" in value && "timeZone" in value ? toTimeZone(value, id) : value,
|
|
282
|
+
segmentText: (format, type, sample) => type !== "timeZoneName" ? void 0 : formatTimeZoneName(format.locale, choose({
|
|
283
|
+
year: sample.getUTCFullYear(),
|
|
284
|
+
month: sample.getUTCMonth() + 1,
|
|
285
|
+
day: sample.getUTCDate(),
|
|
286
|
+
hour: sample.getUTCHours(),
|
|
287
|
+
minute: sample.getUTCMinutes(),
|
|
288
|
+
second: sample.getUTCSeconds(),
|
|
289
|
+
millisecond: 0
|
|
290
|
+
}, format.disambiguation)),
|
|
291
|
+
segmentsToDateTime: (format, date, time) => {
|
|
292
|
+
try {
|
|
293
|
+
return toZoned({
|
|
294
|
+
...date,
|
|
295
|
+
...time
|
|
296
|
+
}, id, format.disambiguation);
|
|
297
|
+
} catch {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
export { formatTimeZoneName as a, localTimeZone as c, toIsoOffset as d, toIsoZoned as f, cycleZoned as i, offsetAt as l, toZoned as m, addZoned as n, fromInstant as o, toTimeZone as p, compareZoned as r, fromIsoZoned as s, timeZone as t, toInstant as u };
|
|
304
|
+
|
|
305
|
+
//# sourceMappingURL=time-zone-DegkzwST.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-zone-DegkzwST.js","names":[],"sources":["../src/time-zone/zoned-date-time.ts","../src/time-zone/time-zone.ts"],"sourcesContent":["import type {\n DateTimeDuration,\n PlainDateTime,\n} from \"../time/plain-date-time.ts\";\nimport type { IsoTimePrecision, TimeField } from \"../time/plain-time.ts\";\n\n/**\n * A date and wall-clock time in a time zone (spec/time-zones.md, \"Values\"): a `PlainDateTime`\n * with its IANA `timeZone` and the `offset` from UTC it has there, in milliseconds (positive east:\n * `+05:30` is 19 800 000). The offset tells the two times of a DST overlap apart. A plain,\n * immutable object: every function returns a new one.\n */\nexport interface ZonedDateTime extends PlainDateTime {\n readonly timeZone: string;\n readonly offset: number;\n}\n\n/**\n * Which time a wall-clock time names when its zone skips it (a DST gap) or repeats it (an\n * overlap), as Temporal's `disambiguation`: `compatible` (the default) takes the later one in a\n * gap and the earlier in an overlap, `earlier` and `later` always that one, `reject` throws a\n * `RangeError`.\n */\nexport type Disambiguation = \"compatible\" | \"earlier\" | \"later\" | \"reject\";\n\nconst HOUR = 3_600_000;\nconst DAY = 86_400_000;\nconst formats = new Map<string, Intl.DateTimeFormat>();\n\n// The `/time` helpers this entry needs, kept here: it imports no other entry's code, so the\n// toolkit's chunks (and every existing entry's size) stay as they were.\n\nconst pad = (value: number, size = 2) =>\n String(Math.abs(value)).padStart(size, \"0\");\n\n/** `2026-11-23T14:30` at a precision (`/time`'s `toIsoDateTime`). */\nfunction toIsoDateTime(\n value: PlainDateTime,\n precision: IsoTimePrecision = \"auto\",\n): string {\n const resolved =\n precision !== \"auto\"\n ? precision\n : value.millisecond !== 0\n ? \"millisecond\"\n : value.second !== 0\n ? \"second\"\n : \"minute\";\n let text = `${value.year < 0 ? \"-\" : \"\"}${pad(value.year, 4)}-${pad(value.month)}-${pad(value.day)}T${pad(value.hour)}:${pad(value.minute)}`;\n if (resolved !== \"minute\") {\n text += `:${pad(value.second)}`;\n }\n return resolved === \"millisecond\"\n ? `${text}.${pad(value.millisecond, 3)}`\n : text;\n}\n\n/** Parses `YYYY-MM-DDTHH:MM[:SS[.sss]]` (`/time`'s `fromIsoDateTime`); `null` when invalid. */\nfunction fromIsoDateTime(text: string): PlainDateTime | null {\n const match =\n /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?$/.exec(\n text,\n );\n if (match === null) {\n return null;\n }\n const [year, month, day, hour, minute] = match.slice(1, 6).map(Number) as [\n number,\n number,\n number,\n number,\n number,\n ];\n const value: PlainDateTime = {\n year,\n month,\n day,\n hour,\n minute,\n second: Number(match[6] ?? 0),\n millisecond: Number((match[7] ?? \"0\").padEnd(3, \"0\")),\n };\n const back = fromWallTime(wallTime(value));\n return back.month === month &&\n back.day === day &&\n hour < 24 &&\n minute < 60 &&\n value.second < 60\n ? value\n : null;\n}\n\n/** The years, months and days of a duration added to a wall time, the day clamped to its month. */\nfunction addDate(\n value: PlainDateTime,\n years: number,\n months: number,\n days: number,\n): PlainDateTime {\n const total = value.year * 12 + value.month - 1 + years * 12 + months;\n const year = Math.floor(total / 12);\n const month = total - year * 12 + 1;\n const last = fromWallTime(\n wallTime({ ...value, year, month: month + 1, day: 0 }),\n ).day;\n return fromWallTime(\n wallTime({ ...value, year, month, day: Math.min(value.day, last) }) +\n days * DAY,\n );\n}\n\n/** The wall-clock fields' UTC milliseconds (as if the zone were UTC), years 0–99 included. */\nfunction wallTime(value: PlainDateTime): number {\n const date = new Date(0);\n date.setUTCFullYear(value.year, value.month - 1, value.day);\n date.setUTCHours(value.hour, value.minute, value.second, value.millisecond);\n return date.getTime();\n}\n\nfunction fromWallTime(ms: number): PlainDateTime {\n const date = new Date(ms);\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n hour: date.getUTCHours(),\n minute: date.getUTCMinutes(),\n second: date.getUTCSeconds(),\n millisecond: date.getUTCMilliseconds(),\n };\n}\n\nfunction zoneFormat(timeZone: string): Intl.DateTimeFormat {\n let format = formats.get(timeZone);\n if (format === undefined) {\n format = new Intl.DateTimeFormat(\"en-US\", {\n timeZone,\n hourCycle: \"h23\",\n era: \"short\",\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"numeric\",\n second: \"numeric\",\n });\n formats.set(timeZone, format);\n }\n return format;\n}\n\n/**\n * The zone's offset from UTC at an instant, in milliseconds, read from `Intl` (the wall-clock\n * fields it writes there, less the instant).\n */\nexport function offsetAt(timeZone: string, epochMs: number): number {\n const second = Math.floor(epochMs / 1000) * 1000;\n const fields: Record<string, string> = {};\n for (const part of zoneFormat(timeZone).formatToParts(second)) {\n fields[part.type] = part.value;\n }\n const year =\n fields.era === \"BC\" || fields.era === \"B\"\n ? 1 - Number(fields.year)\n : Number(fields.year);\n const wall = wallTime({\n year,\n month: Number(fields.month),\n day: Number(fields.day),\n hour: Number(fields.hour) % 24,\n minute: Number(fields.minute),\n second: Number(fields.second),\n millisecond: 0,\n });\n return wall - second;\n}\n\n/** The zone the page runs in (`Intl`'s default). */\nexport function localTimeZone(): string {\n return new Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\n/** The instant (epoch milliseconds) of a zoned date and time. */\nexport function toInstant(value: ZonedDateTime): number {\n return wallTime(value) - value.offset;\n}\n\n/** The date and time an instant (epoch milliseconds or a `Date`) has in a zone. */\nexport function fromInstant(\n instant: number | Date,\n timeZone: string,\n): ZonedDateTime {\n const ms = typeof instant === \"number\" ? instant : instant.getTime();\n const offset = offsetAt(timeZone, ms);\n return { ...fromWallTime(ms + offset), timeZone, offset };\n}\n\n/**\n * The instants a wall-clock time names in a zone: one, two in an overlap (earlier first), none in\n * a gap.\n */\nfunction candidates(timeZone: string, wall: number): number[] {\n const before = offsetAt(timeZone, wall - DAY);\n const after = offsetAt(timeZone, wall + DAY);\n const found = new Set<number>();\n for (const offset of [before, after]) {\n const instant = wall - offset;\n if (offsetAt(timeZone, instant) === offset) {\n found.add(instant);\n }\n }\n return [...found].sort((a, b) => a - b);\n}\n\n/**\n * A wall-clock date and time in a zone (spec/time-zones.md, \"DST gaps and overlaps\"), resolved\n * with `disambiguation` when the zone skips or repeats it. In a gap, `compatible` and `later` move\n * it forward by the gap (02:30 becomes 03:30), `earlier` back (01:30); `reject` throws.\n */\nexport function toZoned(\n value: PlainDateTime,\n timeZone: string,\n disambiguation: Disambiguation = \"compatible\",\n): ZonedDateTime {\n const wall = wallTime(value);\n const found = candidates(timeZone, wall);\n let instant: number;\n if (found.length === 1) {\n instant = found[0] as number;\n } else if (disambiguation === \"reject\") {\n throw new RangeError(\n `${toIsoDateTime(value)} is ${found.length === 0 ? \"skipped\" : \"repeated\"} in ${timeZone}`,\n );\n } else if (found.length === 2) {\n instant = (disambiguation === \"later\" ? found[1] : found[0]) as number;\n } else {\n // the offsets around the gap: before it (the earlier, smaller one east of UTC) and after\n const before = offsetAt(timeZone, wall - DAY);\n const after = offsetAt(timeZone, wall + DAY);\n instant = wall - (disambiguation === \"earlier\" ? after : before);\n }\n return fromInstant(instant, timeZone);\n}\n\n/** The same instant in another zone. */\nexport function toTimeZone(\n value: ZonedDateTime,\n timeZone: string,\n): ZonedDateTime {\n return value.timeZone === timeZone\n ? value\n : fromInstant(toInstant(value), timeZone);\n}\n\n/** Negative when `a` is the earlier instant, positive when later, 0 when the same. */\nexport function compareZoned(a: ZonedDateTime, b: ZonedDateTime): number {\n return toInstant(a) - toInstant(b);\n}\n\n/**\n * Adds a duration as Temporal's `ZonedDateTime#add`: the years, months and days to the wall-clock\n * date (resolved `compatible`, so a day added across a DST change keeps its wall time), then the\n * time in exact time (an hour added across a gap is one real hour).\n */\nexport function addZoned(\n value: ZonedDateTime,\n duration: DateTimeDuration,\n): ZonedDateTime {\n const { years, months, days, ...time } = duration;\n let result = value;\n if (years || months || days) {\n result = toZoned(\n addDate(value, years ?? 0, months ?? 0, days ?? 0),\n value.timeZone,\n );\n }\n const ms =\n (time.hours ?? 0) * HOUR +\n (time.minutes ?? 0) * 60_000 +\n (time.seconds ?? 0) * 1000 +\n (time.milliseconds ?? 0);\n return ms === 0\n ? result\n : fromInstant(toInstant(result) + ms, value.timeZone);\n}\n\n/**\n * Steps one time field and wraps within its range, carrying nothing (the date segments' and\n * React Aria's `cycle`): the hour walks the day's real hours (23 on a spring-forward day, 25 on a\n * fall-back one, the repeated hour twice); a minute or second keeps the offset it had when the\n * wall time still exists there, else resolves with `disambiguation`.\n */\nexport function cycleZoned(\n value: ZonedDateTime,\n field: Exclude<TimeField, \"millisecond\">,\n amount: number,\n disambiguation: Disambiguation = \"compatible\",\n): ZonedDateTime {\n const { timeZone } = value;\n if (field === \"hour\") {\n const start = toInstant(\n toZoned(\n { ...value, hour: 0, minute: 0, second: 0, millisecond: 0 },\n timeZone,\n ),\n );\n const next = addDate(\n { ...value, hour: 0, minute: 0, second: 0, millisecond: 0 },\n 0,\n 0,\n 1,\n );\n const end = toInstant(toZoned(next, timeZone));\n const hours = Math.round((end - start) / HOUR);\n const current = Math.floor((toInstant(value) - start) / HOUR);\n const target = (((current + amount) % hours) + hours) % hours;\n return fromInstant(\n toInstant(value) + (target - current) * HOUR,\n timeZone,\n );\n }\n const size = 60;\n const wall: PlainDateTime = {\n ...value,\n [field]: (((value[field] + amount) % size) + size) % size,\n };\n const instant = wallTime(wall) - value.offset;\n if (offsetAt(timeZone, instant) === value.offset) {\n return { ...wall, timeZone, offset: value.offset };\n }\n return toZoned(wall, timeZone, disambiguation);\n}\n\n/** `+05:30`, `-04:00` (`+00:00` for UTC); seconds only when the offset has them. */\nexport function toIsoOffset(offset: number): string {\n const sign = offset < 0 ? \"-\" : \"+\";\n const total = Math.round(Math.abs(offset) / 1000);\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n return `${sign}${pad(hours)}:${pad(minutes)}${seconds ? `:${pad(seconds)}` : \"\"}`;\n}\n\n/**\n * `2026-03-08T03:30-04:00[America/New_York]` (RFC 9557, Temporal's `ZonedDateTime#toString`): the\n * wall time (see `toIsoDateTime` for `precision`), the offset and the zone.\n */\nexport function toIsoZoned(\n value: ZonedDateTime,\n precision: IsoTimePrecision = \"auto\",\n): string {\n return `${toIsoDateTime(value, precision)}${toIsoOffset(value.offset)}[${value.timeZone}]`;\n}\n\n/**\n * Parses `YYYY-MM-DDTHH:MM[:SS[.sss]][±HH:MM][<zone>]`; the offset, when it is one the zone has\n * at that wall time, picks it (one of an overlap's two), else the wall time is resolved with\n * `disambiguation`. `null` when the text is not one, or its zone is unknown.\n */\nexport function fromIsoZoned(\n text: string,\n disambiguation: Disambiguation = \"compatible\",\n): ZonedDateTime | null {\n const match = /^([^[]+?)(Z|[+-]\\d{2}:\\d{2}(?::\\d{2})?)?\\[([^\\]]+)\\]$/.exec(\n text,\n );\n if (match === null) {\n return null;\n }\n const wall = fromIsoDateTime(match[1] as string);\n const timeZone = match[3] as string;\n if (wall === null) {\n return null;\n }\n try {\n zoneFormat(timeZone);\n } catch {\n return null;\n }\n const offsetText = match[2];\n if (offsetText !== undefined && offsetText !== \"Z\") {\n const [hours, minutes, seconds] = offsetText\n .slice(1)\n .split(\":\")\n .map(Number);\n const offset =\n (offsetText[0] === \"-\" ? -1 : 1) *\n (((hours ?? 0) * 60 + (minutes ?? 0)) * 60 + (seconds ?? 0)) *\n 1000;\n const instant = wallTime(wall) - offset;\n if (offsetAt(timeZone, instant) === offset) {\n return { ...wall, timeZone, offset };\n }\n }\n return toZoned(wall, timeZone, disambiguation);\n}\n\n/** The zone's name at the value's instant, from `Intl` (`timeZoneName`, default `short`: \"EST\"). */\nexport function formatTimeZoneName(\n locale: string,\n value: ZonedDateTime,\n style: Intl.DateTimeFormatOptions[\"timeZoneName\"] = \"short\",\n): string {\n return (\n new Intl.DateTimeFormat(locale, {\n timeZone: value.timeZone,\n timeZoneName: style,\n })\n .formatToParts(toInstant(value))\n .find((part) => part.type === \"timeZoneName\")\n ?.value.replace(/[ ]/g, \" \") ?? value.timeZone\n );\n}\n","import type { PlainDate } from \"../date/plain-date.ts\";\nimport type {\n SegmentFormat,\n SegmentFormatOptions,\n SegmentType,\n} from \"../segments/segment-format.ts\";\nimport type { PlainDateTime } from \"../time/plain-date-time.ts\";\nimport type { IsoTimePrecision, PlainTime } from \"../time/plain-time.ts\";\nimport {\n type Disambiguation,\n formatTimeZoneName,\n fromInstant,\n localTimeZone,\n toIsoZoned,\n toTimeZone,\n toZoned,\n type ZonedDateTime,\n} from \"./zoned-date-time.ts\";\n\n/**\n * A time zone as a date field or picker takes it (spec/time-zones.md, \"In the fields\"): its id and\n * the zoned math the field calls. A field given one holds `ZonedDateTime` values in that zone;\n * no component imports `/time-zone`, so a field given none bundles none of it.\n */\nexport interface TimeZone {\n /** The IANA id (`America/New_York`). */\n readonly id: string;\n /** A wall-clock date and time in this zone, resolved with `disambiguation`. */\n resolve(\n value: PlainDateTime,\n disambiguation?: Disambiguation,\n ): ZonedDateTime;\n /** The same instant in this zone. */\n convert(value: ZonedDateTime): ZonedDateTime;\n /** The date and time of an instant (epoch milliseconds or a `Date`) in this zone. */\n at(instant: number | Date): ZonedDateTime;\n /** The zone's short name at the value's instant (\"EST\", \"GMT+5:30\"), from `Intl`. */\n name(locale: string, value: ZonedDateTime): string;\n /** The value's ISO text with its offset and zone (what a form submits). */\n toIso(value: ZonedDateTime, precision?: IsoTimePrecision): string;\n /**\n * A wall time chosen (a picker's date, a segment's sample): resolved with `disambiguation`,\n * `reject` read as `compatible`, so a choice always has a value.\n */\n choose(\n value: PlainDateTime,\n disambiguation?: Disambiguation,\n ): ZonedDateTime;\n // The segments' hooks (`/segments` calls them through a format's `timeZone`, which is this\n // zone): a field given no zone bundles none of them.\n /** A value as this zone's wall time: a zoned one from another zone at its instant here. */\n wallTime<Value extends Partial<PlainDateTime>>(value: Value): Value;\n /**\n * The text of a part the zone writes: its name segment's (`timeZoneName`) at a sample's wall\n * time (its UTC fields); `undefined` for any other part.\n */\n segmentText(\n format: SegmentFormat,\n type: SegmentType,\n sample: Date,\n ): string | undefined;\n /** The zoned value of a typed wall time, with the format's `disambiguation` (`null`: rejected). */\n segmentsToDateTime(\n format: SegmentFormat,\n date: PlainDate,\n time: PlainTime,\n ): ZonedDateTime | null;\n /** The Intl options of a field's format, with the zone's name where a date and time shows it. */\n segmentOptions(\n options: SegmentFormatOptions,\n intl: Intl.DateTimeFormatOptions,\n ): Intl.DateTimeFormatOptions;\n}\n\n/** The time zone `id` (default: the page's own) for a date field or picker's `timeZone`. */\nexport function timeZone(id: string = localTimeZone()): TimeZone {\n const choose = (value: PlainDateTime, disambiguation?: Disambiguation) =>\n toZoned(\n value,\n id,\n disambiguation === \"reject\" ? \"compatible\" : disambiguation,\n );\n return {\n id,\n resolve: (value, disambiguation) => toZoned(value, id, disambiguation),\n convert: (value) => toTimeZone(value, id),\n at: (instant) => fromInstant(instant, id),\n name: (locale, value) => formatTimeZoneName(locale, value),\n toIso: toIsoZoned,\n choose,\n // where the locale writes it; its text is the field's zone's (`segmentText`)\n segmentOptions: (options, intl) =>\n options.hideTimeZone || !intl.year || !intl.hour\n ? intl\n : { ...intl, timeZoneName: \"short\" },\n wallTime: (value) =>\n \"offset\" in value && \"timeZone\" in value\n ? (toTimeZone(value as unknown as ZonedDateTime, id) as never)\n : value,\n segmentText: (format, type, sample) =>\n type !== \"timeZoneName\"\n ? undefined\n : formatTimeZoneName(\n format.locale,\n choose(\n {\n year: sample.getUTCFullYear(),\n month: sample.getUTCMonth() + 1,\n day: sample.getUTCDate(),\n hour: sample.getUTCHours(),\n minute: sample.getUTCMinutes(),\n second: sample.getUTCSeconds(),\n millisecond: 0,\n },\n format.disambiguation,\n ),\n ),\n segmentsToDateTime: (format, date, time) => {\n try {\n return toZoned({ ...date, ...time }, id, format.disambiguation);\n } catch {\n return null;\n }\n },\n };\n}\n"],"mappings":";AAyBA,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,0BAAU,IAAI,IAAiC;AAKrD,MAAM,OAAO,OAAe,OAAO,MAC/B,OAAO,KAAK,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OAAO,eAAe;GAC5B,OAAO,OAAO,YAAY,IAAI;GAC9B,KAAK,OAAO,WAAW;GACvB,MAAM,OAAO,YAAY;GACzB,QAAQ,OAAO,cAAc;GAC7B,QAAQ,OAAO,cAAc;GAC7B,aAAa;EACjB,GACA,OAAO,cACX,CACJ;EACV,qBAAqB,QAAQ,MAAM,SAAS;GACxC,IAAI;IACA,OAAO,QAAQ;KAAE,GAAG;KAAM,GAAG;IAAK,GAAG,IAAI,OAAO,cAAc;GAClE,QAAQ;IACJ,OAAO;GACX;EACJ;CACJ;AACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as timeZone, B as offsetAt, F as cycleZoned, G as toZoned, H as toIsoOffset, I as formatTimeZoneName, L as fromInstant, M as ZonedDateTime, N as addZoned, P as compareZoned, R as fromIsoZoned, U as toIsoZoned, V as toInstant, W as toTimeZone, j as Disambiguation, k as TimeZone, z as localTimeZone } from "./calendar-system-B5U5HcPQ.js";
|
|
2
|
+
export { type Disambiguation, type TimeZone, type ZonedDateTime, addZoned, compareZoned, cycleZoned, formatTimeZoneName, fromInstant, fromIsoZoned, localTimeZone, offsetAt, timeZone, toInstant, toIsoOffset, toIsoZoned, toTimeZone, toZoned };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as addZoned, r as compareZoned, i as cycleZoned, a as formatTimeZoneName, o as fromInstant, s as fromIsoZoned, c as localTimeZone, l as offsetAt, t as timeZone, u as toInstant, d as toIsoOffset, f as toIsoZoned, p as toTimeZone, m as toZoned } from "./time-zone-DegkzwST.js";
|
package/dist/time.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as plainTime, S as isSameTime, _ as addTime, a as currentDateTime, b as cycleTime, c as plainDateTime, d as toPlainTime, f as IsoTimePrecision, g as TimeRange, h as TimeField, i as compareDateTimes, l as toIsoDateTime, m as TimeDuration, n as PlainDateTime, o as fromIsoDateTime, p as PlainTime, r as addDateTime, s as isSameDateTime, t as DateTimeDuration, u as toPlainDate, v as compareTimes, w as toIsoTime, x as fromIsoTime, y as currentTime } from "./plain-date-time-B8PGahhe.js";
|
|
2
|
+
export { type DateTimeDuration, type IsoTimePrecision, type PlainDateTime, type PlainTime, type TimeDuration, type TimeField, type TimeRange, addDateTime, addTime, compareDateTimes, compareTimes, currentDateTime, currentTime, cycleTime, fromIsoDateTime, fromIsoTime, isSameDateTime, isSameTime, plainDateTime, plainTime, toIsoDateTime, toIsoTime, toPlainDate, toPlainTime };
|
package/dist/time.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as addDateTime, u as addTime, n as compareDateTimes, d as compareTimes, r as currentDateTime, f as currentTime, p as cycleTime, i as fromIsoDateTime, m as fromIsoTime, a as isSameDateTime, h as isSameTime, o as plainDateTime, g as plainTime, s as toIsoDateTime, _ as toIsoTime, c as toPlainDate, l as toPlainTime } from "./time-Ct6oq9kt.js";
|