@cerberus-design/react 0.25.0 → 0.25.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/combobox/combobox.cjs +1 -2
- package/dist/components/combobox/combobox.d.cts +1 -3
- package/dist/components/combobox/combobox.d.ts +1 -3
- package/dist/components/combobox/combobox.js +1 -2
- package/dist/components/cta-dialog/provider.cjs +3 -1
- package/dist/components/cta-dialog/provider.d.cts +2 -1
- package/dist/components/cta-dialog/provider.d.ts +2 -1
- package/dist/components/cta-dialog/provider.js +3 -1
- package/dist/components/date-picker/calendar.cjs +3 -1
- package/dist/components/date-picker/calendar.d.cts +4 -8
- package/dist/components/date-picker/calendar.d.ts +4 -8
- package/dist/components/date-picker/calendar.js +3 -1
- package/dist/components/date-picker/content.cjs +1 -3
- package/dist/components/date-picker/content.d.cts +1 -2
- package/dist/components/date-picker/content.d.ts +1 -2
- package/dist/components/date-picker/content.js +1 -3
- package/dist/components/date-picker/date-picker.cjs +47 -2
- package/dist/components/date-picker/date-picker.d.cts +1 -6
- package/dist/components/date-picker/date-picker.d.ts +1 -6
- package/dist/components/date-picker/date-picker.js +47 -2
- package/dist/components/date-picker/index.cjs +3 -3
- package/dist/components/date-picker/index.js +3 -3
- package/dist/components/date-picker/input.cjs +1 -1
- package/dist/components/date-picker/input.js +1 -1
- package/dist/components/date-picker/primitives.cjs +4 -1
- package/dist/components/date-picker/primitives.d.cts +1 -4
- package/dist/components/date-picker/primitives.d.ts +1 -4
- package/dist/components/date-picker/primitives.js +4 -1
- package/dist/components/date-picker/range-input.cjs +2 -2
- package/dist/components/date-picker/range-input.js +2 -2
- package/dist/components/field/status-indicator.cjs +1 -2
- package/dist/components/field/status-indicator.d.cts +1 -1
- package/dist/components/field/status-indicator.d.ts +1 -1
- package/dist/components/field/status-indicator.js +1 -2
- package/dist/components/file-upload/file-status.cjs +26 -43
- package/dist/components/file-upload/file-status.js +27 -44
- package/dist/components/file-upload/file-uploader.cjs +21 -47
- package/dist/components/file-upload/file-uploader.d.cts +7 -10
- package/dist/components/file-upload/file-uploader.d.ts +7 -10
- package/dist/components/file-upload/file-uploader.js +22 -48
- package/dist/components/file-upload/helpers.cjs +17 -0
- package/dist/components/file-upload/helpers.d.cts +16 -0
- package/dist/components/file-upload/helpers.d.ts +16 -0
- package/dist/components/file-upload/helpers.js +13 -0
- package/dist/components/file-upload/img-preview.cjs +30 -0
- package/dist/components/file-upload/img-preview.d.cts +2 -0
- package/dist/components/file-upload/img-preview.d.ts +2 -0
- package/dist/components/file-upload/img-preview.js +26 -0
- package/dist/components/file-upload/index.cjs +24 -0
- package/dist/components/file-upload/index.d.cts +4 -0
- package/dist/components/file-upload/index.d.ts +4 -0
- package/dist/components/file-upload/index.js +4 -0
- package/dist/components/file-upload/parts.cjs +28 -0
- package/dist/components/file-upload/parts.d.cts +86 -0
- package/dist/components/file-upload/parts.d.ts +86 -0
- package/dist/components/file-upload/parts.js +24 -0
- package/dist/components/file-upload/primitives.cjs +81 -0
- package/dist/components/file-upload/primitives.d.cts +45 -0
- package/dist/components/file-upload/primitives.d.ts +45 -0
- package/dist/components/file-upload/primitives.js +61 -0
- package/dist/components/file-upload/utils.cjs +18 -0
- package/dist/components/file-upload/utils.d.cts +7 -0
- package/dist/components/file-upload/utils.d.ts +7 -0
- package/dist/components/file-upload/utils.js +14 -0
- package/dist/components/select/select.cjs +6 -3
- package/dist/components/select/select.d.cts +1 -3
- package/dist/components/select/select.d.ts +1 -3
- package/dist/components/select/select.js +6 -3
- package/dist/context/confirm-modal.cjs +3 -1
- package/dist/context/confirm-modal.d.cts +2 -1
- package/dist/context/confirm-modal.d.ts +2 -1
- package/dist/context/confirm-modal.js +3 -1
- package/dist/context/prompt-modal.cjs +4 -2
- package/dist/context/prompt-modal.d.cts +2 -1
- package/dist/context/prompt-modal.d.ts +2 -1
- package/dist/context/prompt-modal.js +5 -3
- package/dist/index.cjs +163 -131
- package/dist/index.client.d.cts +1 -1
- package/dist/index.client.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.cjs +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.js +6 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.cjs +21 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.js +17 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.cjs +28 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.js +24 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.cjs +26 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.js +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.cjs +47 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.js +43 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.cjs +36 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.js +32 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/CalendarDate.js +3 -3
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/conversion.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/queries.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.cjs +218 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.js +212 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.cjs +135 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.js +131 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.cjs +101 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.js +93 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.cjs +200 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.js +186 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.cjs +352 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.js +336 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.cjs +39 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.js +30 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.cjs +44 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.js +37 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.cjs +10 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.js +6 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.cjs +649 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.js +643 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.cjs +147 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.js +138 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.cjs +53 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.js +48 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.cjs +9 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.js +9 -1
- package/package.json +7 -7
- package/src/components/combobox/combobox.tsx +7 -13
- package/src/components/cta-dialog/provider.tsx +8 -3
- package/src/components/date-picker/calendar.tsx +10 -9
- package/src/components/date-picker/content.tsx +4 -11
- package/src/components/date-picker/date-picker.tsx +55 -18
- package/src/components/date-picker/input.tsx +1 -1
- package/src/components/date-picker/primitives.tsx +4 -1
- package/src/components/date-picker/range-input.tsx +2 -2
- package/src/components/field/status-indicator.tsx +2 -5
- package/src/components/file-upload/file-status.tsx +14 -21
- package/src/components/file-upload/file-uploader.tsx +37 -49
- package/src/components/file-upload/helpers.ts +28 -0
- package/src/components/file-upload/img-preview.tsx +41 -0
- package/src/components/file-upload/index.ts +4 -0
- package/src/components/file-upload/parts.tsx +126 -0
- package/src/components/file-upload/primitives.ts +156 -0
- package/src/components/file-upload/utils.ts +20 -0
- package/src/components/select/select.tsx +11 -12
- package/src/context/confirm-modal.tsx +7 -2
- package/src/context/prompt-modal.tsx +9 -4
- package/src/index.client.ts +2 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { CalendarDate, ZonedDateTime, CalendarDateTime } from './CalendarDate.js';
|
|
3
|
+
import { constrain } from './manipulation.js';
|
|
4
|
+
import { getExtendedYear, GregorianCalendar } from './calendars/GregorianCalendar.js';
|
|
5
|
+
import { getLocalTimeZone, isEqualCalendar } from './queries.js';
|
|
6
|
+
|
|
7
|
+
function epochFromDate(date) {
|
|
8
|
+
date = toCalendar(date, new GregorianCalendar());
|
|
9
|
+
let year = getExtendedYear(date.era, date.year);
|
|
10
|
+
return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
|
|
11
|
+
}
|
|
12
|
+
function epochFromParts(year, month, day, hour, minute, second, millisecond) {
|
|
13
|
+
let date = /* @__PURE__ */ new Date();
|
|
14
|
+
date.setUTCHours(hour, minute, second, millisecond);
|
|
15
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
16
|
+
return date.getTime();
|
|
17
|
+
}
|
|
18
|
+
function getTimeZoneOffset(ms, timeZone) {
|
|
19
|
+
if (timeZone === "UTC") {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
if (ms > 0 && timeZone === getLocalTimeZone()) {
|
|
23
|
+
return new Date(ms).getTimezoneOffset() * -60 * 1e3;
|
|
24
|
+
}
|
|
25
|
+
let { year, month, day, hour, minute, second } = getTimeZoneParts(ms, timeZone);
|
|
26
|
+
let utc = epochFromParts(year, month, day, hour, minute, second, 0);
|
|
27
|
+
return utc - Math.floor(ms / 1e3) * 1e3;
|
|
28
|
+
}
|
|
29
|
+
const formattersByTimeZone = /* @__PURE__ */ new Map();
|
|
30
|
+
function getTimeZoneParts(ms, timeZone) {
|
|
31
|
+
let formatter = formattersByTimeZone.get(timeZone);
|
|
32
|
+
if (!formatter) {
|
|
33
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
34
|
+
timeZone,
|
|
35
|
+
hour12: false,
|
|
36
|
+
era: "short",
|
|
37
|
+
year: "numeric",
|
|
38
|
+
month: "numeric",
|
|
39
|
+
day: "numeric",
|
|
40
|
+
hour: "numeric",
|
|
41
|
+
minute: "numeric",
|
|
42
|
+
second: "numeric"
|
|
43
|
+
});
|
|
44
|
+
formattersByTimeZone.set(timeZone, formatter);
|
|
45
|
+
}
|
|
46
|
+
let parts = formatter.formatToParts(new Date(ms));
|
|
47
|
+
let namedParts = {};
|
|
48
|
+
for (let part of parts) {
|
|
49
|
+
if (part.type !== "literal") {
|
|
50
|
+
namedParts[part.type] = part.value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
// Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
|
|
55
|
+
year: namedParts.era === "BC" || namedParts.era === "B" ? -namedParts.year + 1 : +namedParts.year,
|
|
56
|
+
month: +namedParts.month,
|
|
57
|
+
day: +namedParts.day,
|
|
58
|
+
hour: namedParts.hour === "24" ? 0 : +namedParts.hour,
|
|
59
|
+
// bugs.chromium.org/p/chromium/issues/detail?id=1045791
|
|
60
|
+
minute: +namedParts.minute,
|
|
61
|
+
second: +namedParts.second
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const DAYMILLIS = 864e5;
|
|
65
|
+
function getValidWallTimes(date, timeZone, earlier, later) {
|
|
66
|
+
let found = earlier === later ? [earlier] : [earlier, later];
|
|
67
|
+
return found.filter((absolute) => isValidWallTime(date, timeZone, absolute));
|
|
68
|
+
}
|
|
69
|
+
function isValidWallTime(date, timeZone, absolute) {
|
|
70
|
+
let parts = getTimeZoneParts(absolute, timeZone);
|
|
71
|
+
return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second;
|
|
72
|
+
}
|
|
73
|
+
function toAbsolute(date, timeZone, disambiguation = "compatible") {
|
|
74
|
+
let dateTime = toCalendarDateTime(date);
|
|
75
|
+
if (timeZone === "UTC") {
|
|
76
|
+
return epochFromDate(dateTime);
|
|
77
|
+
}
|
|
78
|
+
if (timeZone === getLocalTimeZone() && disambiguation === "compatible") {
|
|
79
|
+
dateTime = toCalendar(dateTime, new GregorianCalendar());
|
|
80
|
+
let date2 = /* @__PURE__ */ new Date();
|
|
81
|
+
let year = getExtendedYear(dateTime.era, dateTime.year);
|
|
82
|
+
date2.setFullYear(year, dateTime.month - 1, dateTime.day);
|
|
83
|
+
date2.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
|
|
84
|
+
return date2.getTime();
|
|
85
|
+
}
|
|
86
|
+
let ms = epochFromDate(dateTime);
|
|
87
|
+
let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);
|
|
88
|
+
let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);
|
|
89
|
+
let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);
|
|
90
|
+
if (valid.length === 1) {
|
|
91
|
+
return valid[0];
|
|
92
|
+
}
|
|
93
|
+
if (valid.length > 1) {
|
|
94
|
+
switch (disambiguation) {
|
|
95
|
+
// 'compatible' means 'earlier' for "fall back" transitions
|
|
96
|
+
case "compatible":
|
|
97
|
+
case "earlier":
|
|
98
|
+
return valid[0];
|
|
99
|
+
case "later":
|
|
100
|
+
return valid[valid.length - 1];
|
|
101
|
+
case "reject":
|
|
102
|
+
throw new RangeError("Multiple possible absolute times found");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
switch (disambiguation) {
|
|
106
|
+
case "earlier":
|
|
107
|
+
return Math.min(ms - offsetBefore, ms - offsetAfter);
|
|
108
|
+
// 'compatible' means 'later' for "spring forward" transitions
|
|
109
|
+
case "compatible":
|
|
110
|
+
case "later":
|
|
111
|
+
return Math.max(ms - offsetBefore, ms - offsetAfter);
|
|
112
|
+
case "reject":
|
|
113
|
+
throw new RangeError("No such absolute time found");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function toDate(dateTime, timeZone, disambiguation = "compatible") {
|
|
117
|
+
return new Date(toAbsolute(dateTime, timeZone, disambiguation));
|
|
118
|
+
}
|
|
119
|
+
function fromAbsolute(ms, timeZone) {
|
|
120
|
+
let offset = getTimeZoneOffset(ms, timeZone);
|
|
121
|
+
let date = new Date(ms + offset);
|
|
122
|
+
let year = date.getUTCFullYear();
|
|
123
|
+
let month = date.getUTCMonth() + 1;
|
|
124
|
+
let day = date.getUTCDate();
|
|
125
|
+
let hour = date.getUTCHours();
|
|
126
|
+
let minute = date.getUTCMinutes();
|
|
127
|
+
let second = date.getUTCSeconds();
|
|
128
|
+
let millisecond = date.getUTCMilliseconds();
|
|
129
|
+
return new ZonedDateTime(year < 1 ? "BC" : "AD", year < 1 ? -year + 1 : year, month, day, timeZone, offset, hour, minute, second, millisecond);
|
|
130
|
+
}
|
|
131
|
+
function toCalendarDate(dateTime) {
|
|
132
|
+
return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);
|
|
133
|
+
}
|
|
134
|
+
function toCalendarDateTime(date, time) {
|
|
135
|
+
let hour = 0, minute = 0, second = 0, millisecond = 0;
|
|
136
|
+
if ("timeZone" in date) {
|
|
137
|
+
({ hour, minute, second, millisecond } = date);
|
|
138
|
+
} else if ("hour" in date && true) {
|
|
139
|
+
return date;
|
|
140
|
+
}
|
|
141
|
+
return new CalendarDateTime(
|
|
142
|
+
date.calendar,
|
|
143
|
+
date.era,
|
|
144
|
+
date.year,
|
|
145
|
+
date.month,
|
|
146
|
+
date.day,
|
|
147
|
+
hour,
|
|
148
|
+
minute,
|
|
149
|
+
second,
|
|
150
|
+
millisecond
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function toCalendar(date, calendar) {
|
|
154
|
+
if (isEqualCalendar(date.calendar, calendar)) {
|
|
155
|
+
return date;
|
|
156
|
+
}
|
|
157
|
+
let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
|
|
158
|
+
let copy = date.copy();
|
|
159
|
+
copy.calendar = calendar;
|
|
160
|
+
copy.era = calendarDate.era;
|
|
161
|
+
copy.year = calendarDate.year;
|
|
162
|
+
copy.month = calendarDate.month;
|
|
163
|
+
copy.day = calendarDate.day;
|
|
164
|
+
constrain(copy);
|
|
165
|
+
return copy;
|
|
166
|
+
}
|
|
167
|
+
function toZoned(date, timeZone, disambiguation) {
|
|
168
|
+
if (date instanceof ZonedDateTime) {
|
|
169
|
+
if (date.timeZone === timeZone) {
|
|
170
|
+
return date;
|
|
171
|
+
}
|
|
172
|
+
return toTimeZone(date, timeZone);
|
|
173
|
+
}
|
|
174
|
+
let ms = toAbsolute(date, timeZone, disambiguation);
|
|
175
|
+
return fromAbsolute(ms, timeZone);
|
|
176
|
+
}
|
|
177
|
+
function zonedToDate(date) {
|
|
178
|
+
let ms = epochFromDate(date) - date.offset;
|
|
179
|
+
return new Date(ms);
|
|
180
|
+
}
|
|
181
|
+
function toTimeZone(date, timeZone) {
|
|
182
|
+
let ms = epochFromDate(date) - date.offset;
|
|
183
|
+
return toCalendar(fromAbsolute(ms, timeZone), date.calendar);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { epochFromDate, fromAbsolute, getTimeZoneOffset, toAbsolute, toCalendar, toCalendarDate, toCalendarDateTime, toDate, toTimeZone, toZoned, zonedToDate };
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const conversion = require('./conversion.cjs');
|
|
7
|
+
const GregorianCalendar = require('./calendars/GregorianCalendar.cjs');
|
|
8
|
+
|
|
9
|
+
const ONE_HOUR = 36e5;
|
|
10
|
+
function add(date, duration) {
|
|
11
|
+
let mutableDate = date.copy();
|
|
12
|
+
let days = "hour" in mutableDate ? addTimeFields(mutableDate, duration) : 0;
|
|
13
|
+
addYears(mutableDate, duration.years || 0);
|
|
14
|
+
if (mutableDate.calendar.balanceYearMonth) {
|
|
15
|
+
mutableDate.calendar.balanceYearMonth(mutableDate, date);
|
|
16
|
+
}
|
|
17
|
+
mutableDate.month += duration.months || 0;
|
|
18
|
+
balanceYearMonth(mutableDate);
|
|
19
|
+
constrainMonthDay(mutableDate);
|
|
20
|
+
mutableDate.day += (duration.weeks || 0) * 7;
|
|
21
|
+
mutableDate.day += duration.days || 0;
|
|
22
|
+
mutableDate.day += days;
|
|
23
|
+
balanceDay(mutableDate);
|
|
24
|
+
if (mutableDate.calendar.balanceDate) {
|
|
25
|
+
mutableDate.calendar.balanceDate(mutableDate);
|
|
26
|
+
}
|
|
27
|
+
if (mutableDate.year < 1) {
|
|
28
|
+
mutableDate.year = 1;
|
|
29
|
+
mutableDate.month = 1;
|
|
30
|
+
mutableDate.day = 1;
|
|
31
|
+
}
|
|
32
|
+
let maxYear = mutableDate.calendar.getYearsInEra(mutableDate);
|
|
33
|
+
if (mutableDate.year > maxYear) {
|
|
34
|
+
let isInverseEra = mutableDate.calendar.isInverseEra?.(mutableDate);
|
|
35
|
+
mutableDate.year = maxYear;
|
|
36
|
+
mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate);
|
|
37
|
+
mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate);
|
|
38
|
+
}
|
|
39
|
+
if (mutableDate.month < 1) {
|
|
40
|
+
mutableDate.month = 1;
|
|
41
|
+
mutableDate.day = 1;
|
|
42
|
+
}
|
|
43
|
+
let maxMonth = mutableDate.calendar.getMonthsInYear(mutableDate);
|
|
44
|
+
if (mutableDate.month > maxMonth) {
|
|
45
|
+
mutableDate.month = maxMonth;
|
|
46
|
+
mutableDate.day = mutableDate.calendar.getDaysInMonth(mutableDate);
|
|
47
|
+
}
|
|
48
|
+
mutableDate.day = Math.max(1, Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day));
|
|
49
|
+
return mutableDate;
|
|
50
|
+
}
|
|
51
|
+
function addYears(date, years) {
|
|
52
|
+
if (date.calendar.isInverseEra?.(date)) {
|
|
53
|
+
years = -years;
|
|
54
|
+
}
|
|
55
|
+
date.year += years;
|
|
56
|
+
}
|
|
57
|
+
function balanceYearMonth(date) {
|
|
58
|
+
while (date.month < 1) {
|
|
59
|
+
addYears(date, -1);
|
|
60
|
+
date.month += date.calendar.getMonthsInYear(date);
|
|
61
|
+
}
|
|
62
|
+
let monthsInYear = 0;
|
|
63
|
+
while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {
|
|
64
|
+
date.month -= monthsInYear;
|
|
65
|
+
addYears(date, 1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function balanceDay(date) {
|
|
69
|
+
while (date.day < 1) {
|
|
70
|
+
date.month--;
|
|
71
|
+
balanceYearMonth(date);
|
|
72
|
+
date.day += date.calendar.getDaysInMonth(date);
|
|
73
|
+
}
|
|
74
|
+
while (date.day > date.calendar.getDaysInMonth(date)) {
|
|
75
|
+
date.day -= date.calendar.getDaysInMonth(date);
|
|
76
|
+
date.month++;
|
|
77
|
+
balanceYearMonth(date);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function constrainMonthDay(date) {
|
|
81
|
+
date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
|
|
82
|
+
date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
|
|
83
|
+
}
|
|
84
|
+
function constrain(date) {
|
|
85
|
+
if (date.calendar.constrainDate) {
|
|
86
|
+
date.calendar.constrainDate(date);
|
|
87
|
+
}
|
|
88
|
+
date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));
|
|
89
|
+
constrainMonthDay(date);
|
|
90
|
+
}
|
|
91
|
+
function invertDuration(duration) {
|
|
92
|
+
let inverseDuration = {};
|
|
93
|
+
for (let key in duration) {
|
|
94
|
+
if (typeof duration[key] === "number") {
|
|
95
|
+
inverseDuration[key] = -duration[key];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return inverseDuration;
|
|
99
|
+
}
|
|
100
|
+
function subtract(date, duration) {
|
|
101
|
+
return add(date, invertDuration(duration));
|
|
102
|
+
}
|
|
103
|
+
function set(date, fields) {
|
|
104
|
+
let mutableDate = date.copy();
|
|
105
|
+
if (fields.era != null) {
|
|
106
|
+
mutableDate.era = fields.era;
|
|
107
|
+
}
|
|
108
|
+
if (fields.year != null) {
|
|
109
|
+
mutableDate.year = fields.year;
|
|
110
|
+
}
|
|
111
|
+
if (fields.month != null) {
|
|
112
|
+
mutableDate.month = fields.month;
|
|
113
|
+
}
|
|
114
|
+
if (fields.day != null) {
|
|
115
|
+
mutableDate.day = fields.day;
|
|
116
|
+
}
|
|
117
|
+
constrain(mutableDate);
|
|
118
|
+
return mutableDate;
|
|
119
|
+
}
|
|
120
|
+
function setTime(value, fields) {
|
|
121
|
+
let mutableValue = value.copy();
|
|
122
|
+
if (fields.hour != null) {
|
|
123
|
+
mutableValue.hour = fields.hour;
|
|
124
|
+
}
|
|
125
|
+
if (fields.minute != null) {
|
|
126
|
+
mutableValue.minute = fields.minute;
|
|
127
|
+
}
|
|
128
|
+
if (fields.second != null) {
|
|
129
|
+
mutableValue.second = fields.second;
|
|
130
|
+
}
|
|
131
|
+
if (fields.millisecond != null) {
|
|
132
|
+
mutableValue.millisecond = fields.millisecond;
|
|
133
|
+
}
|
|
134
|
+
constrainTime(mutableValue);
|
|
135
|
+
return mutableValue;
|
|
136
|
+
}
|
|
137
|
+
function balanceTime(time) {
|
|
138
|
+
time.second += Math.floor(time.millisecond / 1e3);
|
|
139
|
+
time.millisecond = nonNegativeMod(time.millisecond, 1e3);
|
|
140
|
+
time.minute += Math.floor(time.second / 60);
|
|
141
|
+
time.second = nonNegativeMod(time.second, 60);
|
|
142
|
+
time.hour += Math.floor(time.minute / 60);
|
|
143
|
+
time.minute = nonNegativeMod(time.minute, 60);
|
|
144
|
+
let days = Math.floor(time.hour / 24);
|
|
145
|
+
time.hour = nonNegativeMod(time.hour, 24);
|
|
146
|
+
return days;
|
|
147
|
+
}
|
|
148
|
+
function constrainTime(time) {
|
|
149
|
+
time.millisecond = Math.max(0, Math.min(time.millisecond, 1e3));
|
|
150
|
+
time.second = Math.max(0, Math.min(time.second, 59));
|
|
151
|
+
time.minute = Math.max(0, Math.min(time.minute, 59));
|
|
152
|
+
time.hour = Math.max(0, Math.min(time.hour, 23));
|
|
153
|
+
}
|
|
154
|
+
function nonNegativeMod(a, b) {
|
|
155
|
+
let result = a % b;
|
|
156
|
+
if (result < 0) {
|
|
157
|
+
result += b;
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
function addTimeFields(time, duration) {
|
|
162
|
+
time.hour += duration.hours || 0;
|
|
163
|
+
time.minute += duration.minutes || 0;
|
|
164
|
+
time.second += duration.seconds || 0;
|
|
165
|
+
time.millisecond += duration.milliseconds || 0;
|
|
166
|
+
return balanceTime(time);
|
|
167
|
+
}
|
|
168
|
+
function cycleDate(value, field, amount, options) {
|
|
169
|
+
let mutable = value.copy();
|
|
170
|
+
switch (field) {
|
|
171
|
+
case "era": {
|
|
172
|
+
let eras = value.calendar.getEras();
|
|
173
|
+
let eraIndex = eras.indexOf(value.era);
|
|
174
|
+
if (eraIndex < 0) {
|
|
175
|
+
throw new Error("Invalid era: " + value.era);
|
|
176
|
+
}
|
|
177
|
+
eraIndex = cycleValue(eraIndex, amount, 0, eras.length - 1, options?.round);
|
|
178
|
+
mutable.era = eras[eraIndex];
|
|
179
|
+
constrain(mutable);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "year": {
|
|
183
|
+
if (mutable.calendar.isInverseEra?.(mutable)) {
|
|
184
|
+
amount = -amount;
|
|
185
|
+
}
|
|
186
|
+
mutable.year = cycleValue(value.year, amount, -Infinity, 9999, options?.round);
|
|
187
|
+
if (mutable.year === -Infinity) {
|
|
188
|
+
mutable.year = 1;
|
|
189
|
+
}
|
|
190
|
+
if (mutable.calendar.balanceYearMonth) {
|
|
191
|
+
mutable.calendar.balanceYearMonth(mutable, value);
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case "month":
|
|
196
|
+
mutable.month = cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options?.round);
|
|
197
|
+
break;
|
|
198
|
+
case "day":
|
|
199
|
+
mutable.day = cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options?.round);
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
throw new Error("Unsupported field " + field);
|
|
203
|
+
}
|
|
204
|
+
if (value.calendar.balanceDate) {
|
|
205
|
+
value.calendar.balanceDate(mutable);
|
|
206
|
+
}
|
|
207
|
+
constrain(mutable);
|
|
208
|
+
return mutable;
|
|
209
|
+
}
|
|
210
|
+
function cycleTime(value, field, amount, options) {
|
|
211
|
+
let mutable = value.copy();
|
|
212
|
+
switch (field) {
|
|
213
|
+
case "hour": {
|
|
214
|
+
let hours = value.hour;
|
|
215
|
+
let min = 0;
|
|
216
|
+
let max = 23;
|
|
217
|
+
if (options?.hourCycle === 12) {
|
|
218
|
+
let isPM = hours >= 12;
|
|
219
|
+
min = isPM ? 12 : 0;
|
|
220
|
+
max = isPM ? 23 : 11;
|
|
221
|
+
}
|
|
222
|
+
mutable.hour = cycleValue(hours, amount, min, max, options?.round);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case "minute":
|
|
226
|
+
mutable.minute = cycleValue(value.minute, amount, 0, 59, options?.round);
|
|
227
|
+
break;
|
|
228
|
+
case "second":
|
|
229
|
+
mutable.second = cycleValue(value.second, amount, 0, 59, options?.round);
|
|
230
|
+
break;
|
|
231
|
+
case "millisecond":
|
|
232
|
+
mutable.millisecond = cycleValue(value.millisecond, amount, 0, 999, options?.round);
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw new Error("Unsupported field " + field);
|
|
236
|
+
}
|
|
237
|
+
return mutable;
|
|
238
|
+
}
|
|
239
|
+
function cycleValue(value, amount, min, max, round = false) {
|
|
240
|
+
if (round) {
|
|
241
|
+
value += Math.sign(amount);
|
|
242
|
+
if (value < min) {
|
|
243
|
+
value = max;
|
|
244
|
+
}
|
|
245
|
+
let div = Math.abs(amount);
|
|
246
|
+
if (amount > 0) {
|
|
247
|
+
value = Math.ceil(value / div) * div;
|
|
248
|
+
} else {
|
|
249
|
+
value = Math.floor(value / div) * div;
|
|
250
|
+
}
|
|
251
|
+
if (value > max) {
|
|
252
|
+
value = min;
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
value += amount;
|
|
256
|
+
if (value < min) {
|
|
257
|
+
value = max - (min - value - 1);
|
|
258
|
+
} else if (value > max) {
|
|
259
|
+
value = min + (value - max - 1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
function addZoned(dateTime, duration) {
|
|
265
|
+
let ms;
|
|
266
|
+
if (duration.years != null && duration.years !== 0 || duration.months != null && duration.months !== 0 || duration.weeks != null && duration.weeks !== 0 || duration.days != null && duration.days !== 0) {
|
|
267
|
+
let res2 = add(conversion.toCalendarDateTime(dateTime), {
|
|
268
|
+
years: duration.years,
|
|
269
|
+
months: duration.months,
|
|
270
|
+
weeks: duration.weeks,
|
|
271
|
+
days: duration.days
|
|
272
|
+
});
|
|
273
|
+
ms = conversion.toAbsolute(res2, dateTime.timeZone);
|
|
274
|
+
} else {
|
|
275
|
+
ms = conversion.epochFromDate(dateTime) - dateTime.offset;
|
|
276
|
+
}
|
|
277
|
+
ms += duration.milliseconds || 0;
|
|
278
|
+
ms += (duration.seconds || 0) * 1e3;
|
|
279
|
+
ms += (duration.minutes || 0) * 60 * 1e3;
|
|
280
|
+
ms += (duration.hours || 0) * 60 * 60 * 1e3;
|
|
281
|
+
let res = conversion.fromAbsolute(ms, dateTime.timeZone);
|
|
282
|
+
return conversion.toCalendar(res, dateTime.calendar);
|
|
283
|
+
}
|
|
284
|
+
function subtractZoned(dateTime, duration) {
|
|
285
|
+
return addZoned(dateTime, invertDuration(duration));
|
|
286
|
+
}
|
|
287
|
+
function cycleZoned(dateTime, field, amount, options) {
|
|
288
|
+
switch (field) {
|
|
289
|
+
case "hour": {
|
|
290
|
+
let min = 0;
|
|
291
|
+
let max = 23;
|
|
292
|
+
if (options?.hourCycle === 12) {
|
|
293
|
+
let isPM = dateTime.hour >= 12;
|
|
294
|
+
min = isPM ? 12 : 0;
|
|
295
|
+
max = isPM ? 23 : 11;
|
|
296
|
+
}
|
|
297
|
+
let plainDateTime = conversion.toCalendarDateTime(dateTime);
|
|
298
|
+
let minDate = conversion.toCalendar(setTime(plainDateTime, { hour: min }), new GregorianCalendar.GregorianCalendar());
|
|
299
|
+
let minAbsolute = [conversion.toAbsolute(minDate, dateTime.timeZone, "earlier"), conversion.toAbsolute(minDate, dateTime.timeZone, "later")].filter((ms2) => conversion.fromAbsolute(ms2, dateTime.timeZone).day === minDate.day)[0];
|
|
300
|
+
let maxDate = conversion.toCalendar(setTime(plainDateTime, { hour: max }), new GregorianCalendar.GregorianCalendar());
|
|
301
|
+
let maxAbsolute = [conversion.toAbsolute(maxDate, dateTime.timeZone, "earlier"), conversion.toAbsolute(maxDate, dateTime.timeZone, "later")].filter((ms2) => conversion.fromAbsolute(ms2, dateTime.timeZone).day === maxDate.day).pop();
|
|
302
|
+
let ms = conversion.epochFromDate(dateTime) - dateTime.offset;
|
|
303
|
+
let hours = Math.floor(ms / ONE_HOUR);
|
|
304
|
+
let remainder = ms % ONE_HOUR;
|
|
305
|
+
ms = cycleValue(
|
|
306
|
+
hours,
|
|
307
|
+
amount,
|
|
308
|
+
Math.floor(minAbsolute / ONE_HOUR),
|
|
309
|
+
Math.floor(maxAbsolute / ONE_HOUR),
|
|
310
|
+
options?.round
|
|
311
|
+
) * ONE_HOUR + remainder;
|
|
312
|
+
return conversion.toCalendar(conversion.fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
313
|
+
}
|
|
314
|
+
case "minute":
|
|
315
|
+
case "second":
|
|
316
|
+
case "millisecond":
|
|
317
|
+
return cycleTime(dateTime, field, amount, options);
|
|
318
|
+
case "era":
|
|
319
|
+
case "year":
|
|
320
|
+
case "month":
|
|
321
|
+
case "day": {
|
|
322
|
+
let res = cycleDate(conversion.toCalendarDateTime(dateTime), field, amount, options);
|
|
323
|
+
let ms = conversion.toAbsolute(res, dateTime.timeZone);
|
|
324
|
+
return conversion.toCalendar(conversion.fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
325
|
+
}
|
|
326
|
+
default:
|
|
327
|
+
throw new Error("Unsupported field " + field);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function setZoned(dateTime, fields, disambiguation) {
|
|
331
|
+
let plainDateTime = conversion.toCalendarDateTime(dateTime);
|
|
332
|
+
let res = setTime(set(plainDateTime, fields), fields);
|
|
333
|
+
if (res.compare(plainDateTime) === 0) {
|
|
334
|
+
return dateTime;
|
|
335
|
+
}
|
|
336
|
+
let ms = conversion.toAbsolute(res, dateTime.timeZone, disambiguation);
|
|
337
|
+
return conversion.toCalendar(conversion.fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
exports.add = add;
|
|
341
|
+
exports.addZoned = addZoned;
|
|
342
|
+
exports.constrain = constrain;
|
|
343
|
+
exports.constrainTime = constrainTime;
|
|
344
|
+
exports.cycleDate = cycleDate;
|
|
345
|
+
exports.cycleTime = cycleTime;
|
|
346
|
+
exports.cycleZoned = cycleZoned;
|
|
347
|
+
exports.invertDuration = invertDuration;
|
|
348
|
+
exports.set = set;
|
|
349
|
+
exports.setTime = setTime;
|
|
350
|
+
exports.setZoned = setZoned;
|
|
351
|
+
exports.subtract = subtract;
|
|
352
|
+
exports.subtractZoned = subtractZoned;
|