frey-ui 1.1.0 → 1.2.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/dist/cjs/Calendar/calendar.css +216 -0
- package/dist/cjs/Calendar/calendar.module.css.cjs +10 -0
- package/dist/cjs/Calendar/calendar.module.css.cjs.map +1 -0
- package/dist/cjs/Calendar/calendarInteractions.cjs +34 -0
- package/dist/cjs/Calendar/calendarInteractions.cjs.map +1 -0
- package/dist/cjs/Calendar/calendarModel.cjs +232 -0
- package/dist/cjs/Calendar/calendarModel.cjs.map +1 -0
- package/dist/cjs/Calendar/index.cjs +204 -0
- package/dist/cjs/Calendar/index.cjs.map +1 -0
- package/dist/cjs/DateField/DateFieldSegments.cjs +71 -0
- package/dist/cjs/DateField/DateFieldSegments.cjs.map +1 -0
- package/dist/cjs/DateField/DateSegmentInput.cjs +17 -0
- package/dist/cjs/DateField/DateSegmentInput.cjs.map +1 -0
- package/dist/cjs/DateField/dateFieldInteractions.cjs +205 -0
- package/dist/cjs/DateField/dateFieldInteractions.cjs.map +1 -0
- package/dist/cjs/DateField/dateFieldState.cjs +127 -0
- package/dist/cjs/DateField/dateFieldState.cjs.map +1 -0
- package/dist/cjs/DateField/datefield.css +134 -0
- package/dist/cjs/DateField/datefield.module.css.cjs +10 -0
- package/dist/cjs/DateField/datefield.module.css.cjs.map +1 -0
- package/dist/cjs/DateField/index.cjs +203 -0
- package/dist/cjs/DateField/index.cjs.map +1 -0
- package/dist/cjs/DatePicker/datepicker.css +24 -0
- package/dist/cjs/DatePicker/datepicker.module.css.cjs +10 -0
- package/dist/cjs/DatePicker/datepicker.module.css.cjs.map +1 -0
- package/dist/cjs/DatePicker/index.cjs +98 -0
- package/dist/cjs/DatePicker/index.cjs.map +1 -0
- package/dist/cjs/Icons/CalendarIcon.cjs +12 -0
- package/dist/cjs/Icons/CalendarIcon.cjs.map +1 -0
- package/dist/cjs/Popover/index.cjs +2 -2
- package/dist/cjs/Popover/index.cjs.map +1 -1
- package/dist/cjs/date/dateEngine.cjs +591 -0
- package/dist/cjs/date/dateEngine.cjs.map +1 -0
- package/dist/cjs/date/dateLocale.cjs +239 -0
- package/dist/cjs/date/dateLocale.cjs.map +1 -0
- package/dist/cjs/date/japaneseEraData.cjs +252 -0
- package/dist/cjs/date/japaneseEraData.cjs.map +1 -0
- package/dist/cjs/date/useDateLocale.cjs +24 -0
- package/dist/cjs/date/useDateLocale.cjs.map +1 -0
- package/dist/cjs/index.cjs +68 -60
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/theme.css +14 -0
- package/dist/esm/Calendar/calendar.css +216 -0
- package/dist/esm/Calendar/calendar.module.css.mjs +6 -0
- package/dist/esm/Calendar/calendar.module.css.mjs.map +1 -0
- package/dist/esm/Calendar/calendarInteractions.mjs +32 -0
- package/dist/esm/Calendar/calendarInteractions.mjs.map +1 -0
- package/dist/esm/Calendar/calendarModel.mjs +224 -0
- package/dist/esm/Calendar/calendarModel.mjs.map +1 -0
- package/dist/esm/Calendar/index.mjs +200 -0
- package/dist/esm/Calendar/index.mjs.map +1 -0
- package/dist/esm/DateField/DateFieldSegments.mjs +69 -0
- package/dist/esm/DateField/DateFieldSegments.mjs.map +1 -0
- package/dist/esm/DateField/DateSegmentInput.mjs +15 -0
- package/dist/esm/DateField/DateSegmentInput.mjs.map +1 -0
- package/dist/esm/DateField/dateFieldInteractions.mjs +198 -0
- package/dist/esm/DateField/dateFieldInteractions.mjs.map +1 -0
- package/dist/esm/DateField/dateFieldState.mjs +119 -0
- package/dist/esm/DateField/dateFieldState.mjs.map +1 -0
- package/dist/esm/DateField/datefield.css +134 -0
- package/dist/esm/DateField/datefield.module.css.mjs +6 -0
- package/dist/esm/DateField/datefield.module.css.mjs.map +1 -0
- package/dist/esm/DateField/index.mjs +198 -0
- package/dist/esm/DateField/index.mjs.map +1 -0
- package/dist/esm/DatePicker/datepicker.css +24 -0
- package/dist/esm/DatePicker/datepicker.module.css.mjs +6 -0
- package/dist/esm/DatePicker/datepicker.module.css.mjs.map +1 -0
- package/dist/esm/DatePicker/index.mjs +94 -0
- package/dist/esm/DatePicker/index.mjs.map +1 -0
- package/dist/esm/Icons/CalendarIcon.mjs +10 -0
- package/dist/esm/Icons/CalendarIcon.mjs.map +1 -0
- package/dist/esm/Popover/index.mjs +2 -2
- package/dist/esm/Popover/index.mjs.map +1 -1
- package/dist/esm/date/dateEngine.mjs +573 -0
- package/dist/esm/date/dateEngine.mjs.map +1 -0
- package/dist/esm/date/dateLocale.mjs +226 -0
- package/dist/esm/date/dateLocale.mjs.map +1 -0
- package/dist/esm/date/japaneseEraData.mjs +250 -0
- package/dist/esm/date/japaneseEraData.mjs.map +1 -0
- package/dist/esm/date/useDateLocale.mjs +22 -0
- package/dist/esm/date/useDateLocale.mjs.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/theme.css +14 -0
- package/dist/index.d.ts +80 -3
- package/dist/types/src/Calendar/calendarInteractions.d.ts +9 -0
- package/dist/types/src/Calendar/calendarInteractions.d.ts.map +1 -0
- package/dist/types/src/Calendar/calendarModel.d.ts +81 -0
- package/dist/types/src/Calendar/calendarModel.d.ts.map +1 -0
- package/dist/types/src/Calendar/index.d.ts +26 -0
- package/dist/types/src/Calendar/index.d.ts.map +1 -0
- package/dist/types/src/DateField/DateFieldSegments.d.ts +28 -0
- package/dist/types/src/DateField/DateFieldSegments.d.ts.map +1 -0
- package/dist/types/src/DateField/DateSegmentInput.d.ts +23 -0
- package/dist/types/src/DateField/DateSegmentInput.d.ts.map +1 -0
- package/dist/types/src/DateField/dateFieldInteractions.d.ts +66 -0
- package/dist/types/src/DateField/dateFieldInteractions.d.ts.map +1 -0
- package/dist/types/src/DateField/dateFieldState.d.ts +32 -0
- package/dist/types/src/DateField/dateFieldState.d.ts.map +1 -0
- package/dist/types/src/DateField/index.d.ts +42 -0
- package/dist/types/src/DateField/index.d.ts.map +1 -0
- package/dist/types/src/DatePicker/index.d.ts +19 -0
- package/dist/types/src/DatePicker/index.d.ts.map +1 -0
- package/dist/types/src/Icons/CalendarIcon.d.ts +4 -0
- package/dist/types/src/Icons/CalendarIcon.d.ts.map +1 -0
- package/dist/types/src/Icons/index.d.ts +1 -0
- package/dist/types/src/Icons/index.d.ts.map +1 -1
- package/dist/types/src/Popover/index.d.ts +3 -1
- package/dist/types/src/Popover/index.d.ts.map +1 -1
- package/dist/types/src/date/dateEngine.d.ts +22 -0
- package/dist/types/src/date/dateEngine.d.ts.map +1 -0
- package/dist/types/src/date/dateLocale.d.ts +30 -0
- package/dist/types/src/date/dateLocale.d.ts.map +1 -0
- package/dist/types/src/date/japaneseEraData.d.ts +7 -0
- package/dist/types/src/date/japaneseEraData.d.ts.map +1 -0
- package/dist/types/src/date/types.d.ts +23 -0
- package/dist/types/src/date/types.d.ts.map +1 -0
- package/dist/types/src/date/useDateLocale.d.ts +2 -0
- package/dist/types/src/date/useDateLocale.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +8 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var IconSvg = require('./IconSvg.cjs');
|
|
6
|
+
|
|
7
|
+
function CalendarIcon({ size = 'md', strokeWidth = 'regular', title, className, style, }) {
|
|
8
|
+
return (jsxRuntime.jsxs(IconSvg.IconSvg, { size: size, strokeWidth: strokeWidth, title: title, className: className, style: style, children: [jsxRuntime.jsx("path", { d: 'M7 3V6' }), jsxRuntime.jsx("path", { d: 'M17 3V6' }), jsxRuntime.jsx("rect", { x: '3', y: '5', width: '18', height: '16', rx: '2' }), jsxRuntime.jsx("path", { d: 'M3 10H21' })] }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.CalendarIcon = CalendarIcon;
|
|
12
|
+
//# sourceMappingURL=CalendarIcon.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalendarIcon.cjs","sources":["../../../src/Icons/CalendarIcon.tsx"],"sourcesContent":[null],"names":["_jsxs","IconSvg","_jsx"],"mappings":";;;;;;SAGgB,YAAY,CAAC,EAC3B,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,SAAS,EACvB,KAAK,EACL,SAAS,EACT,KAAK,GACe,EAAA;AACpB,IAAA,QACEA,eAAA,CAACC,eAAO,EAAA,EACN,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EAAA,QAAA,EAAA,CAEZC,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,QAAQ,EAAA,CAAG,EACnBA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,SAAS,EAAA,CAAG,EACpBA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAA,CAAG,EAClDA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,UAAU,EAAA,CAAG,CAAA,EAAA,CACb;AAEd;;;;"}
|
|
@@ -114,12 +114,12 @@ const PopoverTrigger = React.forwardRef(function PopoverTrigger({ children, asCh
|
|
|
114
114
|
return (jsxRuntime.jsx("button", { ref: mergedRef, type: type ?? 'button', ...referenceProps, children: children }));
|
|
115
115
|
});
|
|
116
116
|
PopoverTrigger.displayName = 'Popover.Trigger';
|
|
117
|
-
const PopoverContent = React.forwardRef(function PopoverContent({ className, style, children, ...props }, ref) {
|
|
117
|
+
const PopoverContent = React.forwardRef(function PopoverContent({ className, style, children, initialFocusRef, ...props }, ref) {
|
|
118
118
|
const { open, idPrefix, setFloating, floatingStyles, floatingContext, getFloatingProps, } = usePopoverContext();
|
|
119
119
|
const floatingProps = getFloatingProps(props);
|
|
120
120
|
if (!open)
|
|
121
121
|
return null;
|
|
122
|
-
return (jsxRuntime.jsx(Portal.default, { children: jsxRuntime.jsx(react.FloatingFocusManager, { context: floatingContext, modal: true, returnFocus: true, outsideElementsInert: false, initialFocus: 0, children: jsxRuntime.jsx("div", { id: `${idPrefix}-content`, ref: mergeRefs.mergeRefs(ref, setFloating), className: clsx(popover_module.default.popover_content, className), style: {
|
|
122
|
+
return (jsxRuntime.jsx(Portal.default, { children: jsxRuntime.jsx(react.FloatingFocusManager, { context: floatingContext, modal: true, returnFocus: true, outsideElementsInert: false, initialFocus: initialFocusRef ?? 0, children: jsxRuntime.jsx("div", { id: `${idPrefix}-content`, ref: mergeRefs.mergeRefs(ref, setFloating), className: clsx(popover_module.default.popover_content, className), style: {
|
|
123
123
|
...floatingStyles,
|
|
124
124
|
...style,
|
|
125
125
|
}, ...floatingProps, children: children }) }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/Popover/index.tsx"],"sourcesContent":[null],"names":["useId","useRef","useState","useControllableValue","useFloatingRootContext","useFloating","toFloatingPlacement","createFloatingMiddleware","autoUpdate","useDismiss","useInteractions","_jsx","mergeRefs","Slot","Portal","FloatingFocusManager","styles"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAA6B,IAAI,CAAC;AAE5E,SAAS,iBAAiB,GAAA;IACxB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;IACpE;AACA,IAAA,OAAO,OAAO;AAChB;AAkBA,MAAM,WAAW,GAAyB,SAAS,OAAO,CAAC,EACzD,IAAI,EACJ,WAAW,GAAG,KAAK,EACnB,YAAY,EACZ,SAAS,GAAG,QAAQ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,YAEpE,QAAQ,EAAA,CACF;AAEb,CAAC,CAAC;AACF,cAAc,CAAC,WAAW,GAAG,iBAAiB;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/Popover/index.tsx"],"sourcesContent":[null],"names":["useId","useRef","useState","useControllableValue","useFloatingRootContext","useFloating","toFloatingPlacement","createFloatingMiddleware","autoUpdate","useDismiss","useInteractions","_jsx","mergeRefs","Slot","Portal","FloatingFocusManager","styles"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAA6B,IAAI,CAAC;AAE5E,SAAS,iBAAiB,GAAA;IACxB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;IACpE;AACA,IAAA,OAAO,OAAO;AAChB;AAkBA,MAAM,WAAW,GAAyB,SAAS,OAAO,CAAC,EACzD,IAAI,EACJ,WAAW,GAAG,KAAK,EACnB,YAAY,EACZ,SAAS,GAAG,QAAQ,EACpB,MAAM,GAAG,CAAC,EACV,aAAa,GAAG,IAAI,EACpB,mBAAmB,GAAG,IAAI,EAC1B,QAAQ,GACe,EAAA;AACvB,IAAA,MAAM,QAAQ,GAAGA,WAAK,EAAE;AACxB,IAAA,MAAM,UAAU,GAAGC,YAAM,CAAqB,IAAI,CAAC;IACnD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAGC,cAAQ,CACtD,IAAI,CACL;IACD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAGA,cAAQ,CACpD,IAAI,CACL;AACD,IAAA,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,GAAGC,yCAAoB,CAC1D,IAAI,EACJ,WAAW,EACX,YAAY,CACb;AACD,IAAA,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAChD,CAAC,QAAiB,EAAE,MAAc,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AoB,EAAA,EACnB,OAAO,EAAE,eAAe,EACxB,KAAK,QACL,WAAW,EAAA,IAAA,EACX,oBAAoB,EAAE,KAAK,EAC3B,YAAY,EAAE,eAAe,IAAI,CAAC,EAAA,QAAA,EAElCJ,cAAA,CAAA,KAAA,EAAA,EACE,EAAE,EAAE,CAAA,EAAG,QAAQ,CAAA,QAAA,CAAU,EACzB,GAAG,EAAEC,mBAAS,CAAC,GAAG,EAAE,WAAgD,CAAC,EACrE,SAAS,EAAE,IAAI,CAACI,sBAAM,CAAC,eAAe,EAAE,SAAS,CAAC,EAClD,KAAK,EAAE;AACL,oBAAA,GAAG,cAAc;AACjB,oBAAA,GAAG,KAAK;AACT,iBAAA,EAAA,GACG,aAAa,EAAA,QAAA,EAEhB,QAAQ,GACL,EAAA,CACe,EAAA,CAChB;AAEb,CAAC,CAAC;AACF,cAAc,CAAC,WAAW,GAAG,iBAAiB;MAOjC,OAAO,GAAqB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;AAClE,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,OAAO,EAAE,cAAc;AACxB,CAAA;;;;;"}
|
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var japaneseEraData = require('./japaneseEraData.cjs');
|
|
5
|
+
|
|
6
|
+
const ISO_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
7
|
+
const MIN_EPOCH_DAY = -719162;
|
|
8
|
+
const MAX_EPOCH_DAY = 2932896;
|
|
9
|
+
const FIXED_FROM_UNIX_EPOCH = 719163;
|
|
10
|
+
const HEBREW_EPOCH = -1373427;
|
|
11
|
+
const DATE_CALENDARS = [
|
|
12
|
+
'gregory',
|
|
13
|
+
'buddhist',
|
|
14
|
+
'japanese',
|
|
15
|
+
'roc',
|
|
16
|
+
'persian',
|
|
17
|
+
'islamic-civil',
|
|
18
|
+
'hebrew',
|
|
19
|
+
];
|
|
20
|
+
function validateDateCalendar(calendar, propName = 'calendar') {
|
|
21
|
+
if (!DATE_CALENDARS.includes(calendar)) {
|
|
22
|
+
throw new RangeError(`${propName} must be a supported date calendar; received ${String(calendar)}.`);
|
|
23
|
+
}
|
|
24
|
+
return calendar;
|
|
25
|
+
}
|
|
26
|
+
function floorDiv(dividend, divisor) {
|
|
27
|
+
return Math.floor(dividend / divisor);
|
|
28
|
+
}
|
|
29
|
+
function modulo(dividend, divisor) {
|
|
30
|
+
return ((dividend % divisor) + divisor) % divisor;
|
|
31
|
+
}
|
|
32
|
+
function isIsoLeapYear(year) {
|
|
33
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
34
|
+
}
|
|
35
|
+
function getDaysInIsoMonth(year, month) {
|
|
36
|
+
if (month === 2)
|
|
37
|
+
return isIsoLeapYear(year) ? 29 : 28;
|
|
38
|
+
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
39
|
+
}
|
|
40
|
+
function isValidIsoDate(date) {
|
|
41
|
+
return (Number.isInteger(date.year) &&
|
|
42
|
+
date.year >= 1 &&
|
|
43
|
+
date.year <= 9999 &&
|
|
44
|
+
Number.isInteger(date.month) &&
|
|
45
|
+
date.month >= 1 &&
|
|
46
|
+
date.month <= 12 &&
|
|
47
|
+
Number.isInteger(date.day) &&
|
|
48
|
+
date.day >= 1 &&
|
|
49
|
+
date.day <= getDaysInIsoMonth(date.year, date.month));
|
|
50
|
+
}
|
|
51
|
+
function parseDateValue(value, propName = 'value') {
|
|
52
|
+
const match = ISO_PATTERN.exec(value);
|
|
53
|
+
const parsed = match
|
|
54
|
+
? {
|
|
55
|
+
year: Number(match[1]),
|
|
56
|
+
month: Number(match[2]),
|
|
57
|
+
day: Number(match[3]),
|
|
58
|
+
}
|
|
59
|
+
: null;
|
|
60
|
+
if (!parsed || !isValidIsoDate(parsed)) {
|
|
61
|
+
throw new RangeError(`${propName} must be a valid YYYY-MM-DD date; received ${value}.`);
|
|
62
|
+
}
|
|
63
|
+
return parsed;
|
|
64
|
+
}
|
|
65
|
+
function serializeDateValue(date) {
|
|
66
|
+
if (!isValidIsoDate(date)) {
|
|
67
|
+
throw new RangeError('date must be between 0001-01-01 and 9999-12-31.');
|
|
68
|
+
}
|
|
69
|
+
return `${String(date.year).padStart(4, '0')}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`;
|
|
70
|
+
}
|
|
71
|
+
function isoDateToEpochDay(date) {
|
|
72
|
+
if (!isValidIsoDate(date)) {
|
|
73
|
+
throw new RangeError('date must be between 0001-01-01 and 9999-12-31.');
|
|
74
|
+
}
|
|
75
|
+
let year = date.year;
|
|
76
|
+
year -= date.month <= 2 ? 1 : 0;
|
|
77
|
+
const era = floorDiv(year, 400);
|
|
78
|
+
const yearOfEra = year - era * 400;
|
|
79
|
+
const adjustedMonth = date.month + (date.month > 2 ? -3 : 9);
|
|
80
|
+
const dayOfYear = floorDiv(153 * adjustedMonth + 2, 5) + date.day - 1;
|
|
81
|
+
const dayOfEra = yearOfEra * 365 +
|
|
82
|
+
floorDiv(yearOfEra, 4) -
|
|
83
|
+
floorDiv(yearOfEra, 100) +
|
|
84
|
+
dayOfYear;
|
|
85
|
+
return era * 146097 + dayOfEra - 719468;
|
|
86
|
+
}
|
|
87
|
+
function epochDayToIsoDate(epochDay) {
|
|
88
|
+
if (!Number.isInteger(epochDay) ||
|
|
89
|
+
epochDay < MIN_EPOCH_DAY ||
|
|
90
|
+
epochDay > MAX_EPOCH_DAY) {
|
|
91
|
+
throw new RangeError('epochDay is outside the supported ISO date range.');
|
|
92
|
+
}
|
|
93
|
+
const shifted = epochDay + 719468;
|
|
94
|
+
const era = floorDiv(shifted, 146097);
|
|
95
|
+
const dayOfEra = shifted - era * 146097;
|
|
96
|
+
const yearOfEra = floorDiv(dayOfEra -
|
|
97
|
+
floorDiv(dayOfEra, 1460) +
|
|
98
|
+
floorDiv(dayOfEra, 36524) -
|
|
99
|
+
floorDiv(dayOfEra, 146096), 365);
|
|
100
|
+
let year = yearOfEra + era * 400;
|
|
101
|
+
const dayOfYear = dayOfEra -
|
|
102
|
+
(365 * yearOfEra + floorDiv(yearOfEra, 4) - floorDiv(yearOfEra, 100));
|
|
103
|
+
const monthPrime = floorDiv(5 * dayOfYear + 2, 153);
|
|
104
|
+
const day = dayOfYear - floorDiv(153 * monthPrime + 2, 5) + 1;
|
|
105
|
+
const month = monthPrime + (monthPrime < 10 ? 3 : -9);
|
|
106
|
+
year += month <= 2 ? 1 : 0;
|
|
107
|
+
return { year, month, day };
|
|
108
|
+
}
|
|
109
|
+
function addIsoDays(date, amount) {
|
|
110
|
+
return epochDayToIsoDate(isoDateToEpochDay(date) + amount);
|
|
111
|
+
}
|
|
112
|
+
function addIsoMonths(date, amount) {
|
|
113
|
+
const monthIndex = date.year * 12 + date.month - 1 + amount;
|
|
114
|
+
const year = floorDiv(monthIndex, 12);
|
|
115
|
+
const month = modulo(monthIndex, 12) + 1;
|
|
116
|
+
const result = {
|
|
117
|
+
year,
|
|
118
|
+
month,
|
|
119
|
+
day: Math.min(date.day, getDaysInIsoMonth(year, month)),
|
|
120
|
+
};
|
|
121
|
+
if (!isValidIsoDate(result)) {
|
|
122
|
+
throw new RangeError('date arithmetic exceeded the supported ISO range.');
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
function addIsoYears(date, amount) {
|
|
127
|
+
const year = date.year + amount;
|
|
128
|
+
const result = {
|
|
129
|
+
year,
|
|
130
|
+
month: date.month,
|
|
131
|
+
day: Math.min(date.day, getDaysInIsoMonth(year, date.month)),
|
|
132
|
+
};
|
|
133
|
+
if (!isValidIsoDate(result)) {
|
|
134
|
+
throw new RangeError('date arithmetic exceeded the supported ISO range.');
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
function compareIsoDates(left, right) {
|
|
139
|
+
const difference = isoDateToEpochDay(left) - isoDateToEpochDay(right);
|
|
140
|
+
return difference < 0 ? -1 : difference > 0 ? 1 : 0;
|
|
141
|
+
}
|
|
142
|
+
function validateDateConstraints(minValue, maxValue) {
|
|
143
|
+
const minDate = minValue === undefined ? undefined : parseDateValue(minValue, 'minValue');
|
|
144
|
+
const maxDate = maxValue === undefined ? undefined : parseDateValue(maxValue, 'maxValue');
|
|
145
|
+
if (minDate && maxDate && compareIsoDates(minDate, maxDate) > 0) {
|
|
146
|
+
throw new RangeError('minValue must be on or before maxValue.');
|
|
147
|
+
}
|
|
148
|
+
return { minDate, maxDate };
|
|
149
|
+
}
|
|
150
|
+
function isDateWithinConstraints(date, minDate, maxDate) {
|
|
151
|
+
return !((minDate && compareIsoDates(date, minDate) < 0) ||
|
|
152
|
+
(maxDate && compareIsoDates(date, maxDate) > 0));
|
|
153
|
+
}
|
|
154
|
+
function fixedFromIso(date) {
|
|
155
|
+
return isoDateToEpochDay(date) + FIXED_FROM_UNIX_EPOCH;
|
|
156
|
+
}
|
|
157
|
+
function isoFromFixed(fixed) {
|
|
158
|
+
return epochDayToIsoDate(fixed - FIXED_FROM_UNIX_EPOCH);
|
|
159
|
+
}
|
|
160
|
+
function getPersianFixed(year, month, day) {
|
|
161
|
+
const epochBase = year - (year >= 0 ? 474 : 473);
|
|
162
|
+
const epochYear = 474 + modulo(epochBase, 2820);
|
|
163
|
+
const monthDays = month <= 7 ? (month - 1) * 31 : (month - 1) * 30 + 6;
|
|
164
|
+
return (day +
|
|
165
|
+
monthDays +
|
|
166
|
+
floorDiv(epochYear * 682 - 110, 2816) +
|
|
167
|
+
(epochYear - 1) * 365 +
|
|
168
|
+
floorDiv(epochBase, 2820) * 1029983 +
|
|
169
|
+
226895);
|
|
170
|
+
}
|
|
171
|
+
function getPersianDate(fixed) {
|
|
172
|
+
const daysSince475 = fixed - getPersianFixed(475, 1, 1);
|
|
173
|
+
const cycle = floorDiv(daysSince475, 1029983);
|
|
174
|
+
const cycleDay = modulo(daysSince475, 1029983);
|
|
175
|
+
const yearInCycle = cycleDay === 1029982
|
|
176
|
+
? 2820
|
|
177
|
+
: floorDiv(2134 * floorDiv(cycleDay, 366) + 2816 * modulo(cycleDay, 366) + 2815, 1028522) +
|
|
178
|
+
floorDiv(cycleDay, 366) +
|
|
179
|
+
1;
|
|
180
|
+
let year = yearInCycle + 2820 * cycle + 474;
|
|
181
|
+
if (year <= 0)
|
|
182
|
+
year -= 1;
|
|
183
|
+
const dayOfYear = fixed - getPersianFixed(year, 1, 1) + 1;
|
|
184
|
+
const month = dayOfYear <= 186
|
|
185
|
+
? Math.ceil(dayOfYear / 31)
|
|
186
|
+
: Math.ceil((dayOfYear - 6) / 30);
|
|
187
|
+
const day = fixed - getPersianFixed(year, month, 1) + 1;
|
|
188
|
+
const nextYear = year === -1 ? 1 : year + 1;
|
|
189
|
+
const nextYearLength = getPersianFixed(nextYear, 1, 1) - getPersianFixed(year, 1, 1);
|
|
190
|
+
const daysInMonth = month <= 6 ? 31 : month <= 11 ? 30 : nextYearLength === 366 ? 30 : 29;
|
|
191
|
+
const relatedDate = isoFromFixed(fixed);
|
|
192
|
+
return {
|
|
193
|
+
era: year > 0 ? 'ap' : 'before-ap',
|
|
194
|
+
year: Math.abs(year),
|
|
195
|
+
month,
|
|
196
|
+
monthCode: `M${String(month).padStart(2, '0')}`,
|
|
197
|
+
day,
|
|
198
|
+
monthsInYear: 12,
|
|
199
|
+
daysInMonth,
|
|
200
|
+
relatedYear: relatedDate.year,
|
|
201
|
+
relatedMonth: relatedDate.month,
|
|
202
|
+
relatedDay: relatedDate.day,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function getIslamicFixed(year, month, day) {
|
|
206
|
+
return (day +
|
|
207
|
+
Math.ceil(29.5 * (month - 1)) +
|
|
208
|
+
(year - 1) * 354 +
|
|
209
|
+
floorDiv(3 + 11 * year, 30) +
|
|
210
|
+
227014);
|
|
211
|
+
}
|
|
212
|
+
function isIslamicLeapYear(year) {
|
|
213
|
+
return modulo(14 + 11 * year, 30) < 11;
|
|
214
|
+
}
|
|
215
|
+
function getIslamicDate(fixed) {
|
|
216
|
+
const year = floorDiv(30 * (fixed - 227015) + 10646, 10631);
|
|
217
|
+
const month = Math.min(12, Math.max(1, Math.ceil((fixed - (29 + getIslamicFixed(year, 1, 1))) / 29.5) + 1));
|
|
218
|
+
const day = fixed - getIslamicFixed(year, month, 1) + 1;
|
|
219
|
+
const daysInMonth = month % 2 === 1 || (month === 12 && isIslamicLeapYear(year)) ? 30 : 29;
|
|
220
|
+
const relatedDate = isoFromFixed(fixed);
|
|
221
|
+
return {
|
|
222
|
+
era: year > 0 ? 'ah' : 'before-ah',
|
|
223
|
+
year: Math.abs(year),
|
|
224
|
+
month,
|
|
225
|
+
monthCode: `M${String(month).padStart(2, '0')}`,
|
|
226
|
+
day,
|
|
227
|
+
monthsInYear: 12,
|
|
228
|
+
daysInMonth,
|
|
229
|
+
relatedYear: relatedDate.year,
|
|
230
|
+
relatedMonth: relatedDate.month,
|
|
231
|
+
relatedDay: relatedDate.day,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function isHebrewLeapYear(year) {
|
|
235
|
+
return modulo(7 * year + 1, 19) < 7;
|
|
236
|
+
}
|
|
237
|
+
function getHebrewElapsedDays(year) {
|
|
238
|
+
const months = floorDiv(235 * year - 234, 19);
|
|
239
|
+
const parts = 12084 + 13753 * months;
|
|
240
|
+
let day = months * 29 + floorDiv(parts, 25920);
|
|
241
|
+
if (modulo(3 * (day + 1), 7) < 3)
|
|
242
|
+
day += 1;
|
|
243
|
+
return day;
|
|
244
|
+
}
|
|
245
|
+
function getHebrewNewYear(year) {
|
|
246
|
+
const previous = getHebrewElapsedDays(year - 1);
|
|
247
|
+
const current = getHebrewElapsedDays(year);
|
|
248
|
+
const next = getHebrewElapsedDays(year + 1);
|
|
249
|
+
const correction = next - current === 356 ? 2 : current - previous === 382 ? 1 : 0;
|
|
250
|
+
return HEBREW_EPOCH + current + correction;
|
|
251
|
+
}
|
|
252
|
+
function getHebrewYearDays(year) {
|
|
253
|
+
return getHebrewNewYear(year + 1) - getHebrewNewYear(year);
|
|
254
|
+
}
|
|
255
|
+
function getHebrewTraditionalMonthDays(year, month) {
|
|
256
|
+
if ([2, 4, 6, 10, 13].includes(month))
|
|
257
|
+
return 29;
|
|
258
|
+
if (month === 12 && !isHebrewLeapYear(year))
|
|
259
|
+
return 29;
|
|
260
|
+
const yearDays = getHebrewYearDays(year);
|
|
261
|
+
if (month === 8 && modulo(yearDays, 10) !== 5)
|
|
262
|
+
return 29;
|
|
263
|
+
if (month === 9 && modulo(yearDays, 10) === 3)
|
|
264
|
+
return 29;
|
|
265
|
+
return 30;
|
|
266
|
+
}
|
|
267
|
+
function getHebrewFixed(year, month, day) {
|
|
268
|
+
let fixed = getHebrewNewYear(year) + day - 1;
|
|
269
|
+
const lastMonth = isHebrewLeapYear(year) ? 13 : 12;
|
|
270
|
+
if (month < 7) {
|
|
271
|
+
for (let current = 7; current <= lastMonth; current += 1) {
|
|
272
|
+
fixed += getHebrewTraditionalMonthDays(year, current);
|
|
273
|
+
}
|
|
274
|
+
for (let current = 1; current < month; current += 1) {
|
|
275
|
+
fixed += getHebrewTraditionalMonthDays(year, current);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
for (let current = 7; current < month; current += 1) {
|
|
280
|
+
fixed += getHebrewTraditionalMonthDays(year, current);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return fixed;
|
|
284
|
+
}
|
|
285
|
+
function hebrewTraditionalToDisplayMonth(year, traditionalMonth) {
|
|
286
|
+
const leap = isHebrewLeapYear(year);
|
|
287
|
+
if (traditionalMonth >= 7 && traditionalMonth <= 11) {
|
|
288
|
+
return traditionalMonth - 6;
|
|
289
|
+
}
|
|
290
|
+
if (traditionalMonth === 12)
|
|
291
|
+
return 6;
|
|
292
|
+
if (traditionalMonth === 13)
|
|
293
|
+
return 7;
|
|
294
|
+
return traditionalMonth + (leap ? 7 : 6);
|
|
295
|
+
}
|
|
296
|
+
function hebrewDisplayToTraditionalMonth(year, displayMonth) {
|
|
297
|
+
const leap = isHebrewLeapYear(year);
|
|
298
|
+
if (displayMonth <= 5)
|
|
299
|
+
return displayMonth + 6;
|
|
300
|
+
if (displayMonth === 6)
|
|
301
|
+
return 12;
|
|
302
|
+
if (leap && displayMonth === 7)
|
|
303
|
+
return 13;
|
|
304
|
+
return displayMonth - (leap ? 7 : 6);
|
|
305
|
+
}
|
|
306
|
+
function getHebrewDate(fixed) {
|
|
307
|
+
let year = floorDiv((fixed - HEBREW_EPOCH) * 98496, 35975351) + 1;
|
|
308
|
+
while (fixed >= getHebrewNewYear(year + 1))
|
|
309
|
+
year += 1;
|
|
310
|
+
while (fixed < getHebrewNewYear(year))
|
|
311
|
+
year -= 1;
|
|
312
|
+
const firstMonth = fixed < getHebrewFixed(year, 1, 1) ? 7 : 1;
|
|
313
|
+
let traditionalMonth = firstMonth;
|
|
314
|
+
while (fixed >
|
|
315
|
+
getHebrewFixed(year, traditionalMonth, getHebrewTraditionalMonthDays(year, traditionalMonth))) {
|
|
316
|
+
traditionalMonth += 1;
|
|
317
|
+
}
|
|
318
|
+
const day = fixed - getHebrewFixed(year, traditionalMonth, 1) + 1;
|
|
319
|
+
const month = hebrewTraditionalToDisplayMonth(year, traditionalMonth);
|
|
320
|
+
const isLeapAdar = traditionalMonth === 12 && isHebrewLeapYear(year);
|
|
321
|
+
const relatedDate = isoFromFixed(fixed);
|
|
322
|
+
return {
|
|
323
|
+
era: 'am',
|
|
324
|
+
year,
|
|
325
|
+
month,
|
|
326
|
+
monthCode: isLeapAdar ? 'M05L' : `M${String(month).padStart(2, '0')}`,
|
|
327
|
+
day,
|
|
328
|
+
monthsInYear: isHebrewLeapYear(year) ? 13 : 12,
|
|
329
|
+
daysInMonth: getHebrewTraditionalMonthDays(year, traditionalMonth),
|
|
330
|
+
relatedYear: relatedDate.year,
|
|
331
|
+
relatedMonth: relatedDate.month,
|
|
332
|
+
relatedDay: relatedDate.day,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const JAPANESE_ERA_DATES = japaneseEraData.JAPANESE_ERAS.map((era) => ({
|
|
336
|
+
...era,
|
|
337
|
+
startDate: parseDateValue(era.start),
|
|
338
|
+
startEpochDay: isoDateToEpochDay(parseDateValue(era.start)),
|
|
339
|
+
}));
|
|
340
|
+
function getJapaneseEra(date) {
|
|
341
|
+
const epochDay = isoDateToEpochDay(date);
|
|
342
|
+
let low = 0;
|
|
343
|
+
let high = JAPANESE_ERA_DATES.length - 1;
|
|
344
|
+
while (low < high) {
|
|
345
|
+
const middle = Math.ceil((low + high) / 2);
|
|
346
|
+
if (JAPANESE_ERA_DATES[middle].startEpochDay <= epochDay) {
|
|
347
|
+
low = middle;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
high = middle - 1;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return JAPANESE_ERA_DATES[low];
|
|
354
|
+
}
|
|
355
|
+
function getJapaneseDate(date) {
|
|
356
|
+
const era = getJapaneseEra(date);
|
|
357
|
+
return {
|
|
358
|
+
era: era.id,
|
|
359
|
+
year: date.year - era.startDate.year + 1,
|
|
360
|
+
month: date.month,
|
|
361
|
+
monthCode: `M${String(date.month).padStart(2, '0')}`,
|
|
362
|
+
day: date.day,
|
|
363
|
+
monthsInYear: 12,
|
|
364
|
+
daysInMonth: getDaysInIsoMonth(date.year, date.month),
|
|
365
|
+
relatedYear: date.year,
|
|
366
|
+
relatedMonth: date.month,
|
|
367
|
+
relatedDay: date.day,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function getCalendarDate(date, calendar) {
|
|
371
|
+
const fixed = fixedFromIso(date);
|
|
372
|
+
switch (calendar) {
|
|
373
|
+
case 'gregory':
|
|
374
|
+
return {
|
|
375
|
+
era: 'ad',
|
|
376
|
+
year: date.year,
|
|
377
|
+
month: date.month,
|
|
378
|
+
monthCode: `M${String(date.month).padStart(2, '0')}`,
|
|
379
|
+
day: date.day,
|
|
380
|
+
monthsInYear: 12,
|
|
381
|
+
daysInMonth: getDaysInIsoMonth(date.year, date.month),
|
|
382
|
+
relatedYear: date.year,
|
|
383
|
+
relatedMonth: date.month,
|
|
384
|
+
relatedDay: date.day,
|
|
385
|
+
};
|
|
386
|
+
case 'buddhist':
|
|
387
|
+
return {
|
|
388
|
+
era: 'be',
|
|
389
|
+
year: date.year + 543,
|
|
390
|
+
month: date.month,
|
|
391
|
+
monthCode: `M${String(date.month).padStart(2, '0')}`,
|
|
392
|
+
day: date.day,
|
|
393
|
+
monthsInYear: 12,
|
|
394
|
+
daysInMonth: getDaysInIsoMonth(date.year, date.month),
|
|
395
|
+
relatedYear: date.year,
|
|
396
|
+
relatedMonth: date.month,
|
|
397
|
+
relatedDay: date.day,
|
|
398
|
+
};
|
|
399
|
+
case 'roc': {
|
|
400
|
+
const isRoc = date.year >= 1912;
|
|
401
|
+
return {
|
|
402
|
+
era: isRoc ? 'roc' : 'before-roc',
|
|
403
|
+
year: isRoc ? date.year - 1911 : 1912 - date.year,
|
|
404
|
+
month: date.month,
|
|
405
|
+
monthCode: `M${String(date.month).padStart(2, '0')}`,
|
|
406
|
+
day: date.day,
|
|
407
|
+
monthsInYear: 12,
|
|
408
|
+
daysInMonth: getDaysInIsoMonth(date.year, date.month),
|
|
409
|
+
relatedYear: date.year,
|
|
410
|
+
relatedMonth: date.month,
|
|
411
|
+
relatedDay: date.day,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
case 'japanese':
|
|
415
|
+
return getJapaneseDate(date);
|
|
416
|
+
case 'persian':
|
|
417
|
+
return getPersianDate(fixed);
|
|
418
|
+
case 'islamic-civil':
|
|
419
|
+
return getIslamicDate(fixed);
|
|
420
|
+
case 'hebrew':
|
|
421
|
+
return getHebrewDate(fixed);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function validateCalendarRoundTrip(source, calendar, candidate) {
|
|
425
|
+
const converted = getCalendarDate(candidate, calendar);
|
|
426
|
+
if (converted.era !== source.era ||
|
|
427
|
+
converted.year !== source.year ||
|
|
428
|
+
converted.month !== source.month ||
|
|
429
|
+
converted.day !== source.day) {
|
|
430
|
+
throw new RangeError(`date is not valid in the ${calendar} calendar.`);
|
|
431
|
+
}
|
|
432
|
+
return candidate;
|
|
433
|
+
}
|
|
434
|
+
function fromCalendarDate(date, calendar) {
|
|
435
|
+
switch (calendar) {
|
|
436
|
+
case 'gregory':
|
|
437
|
+
return validateCalendarRoundTrip(date, calendar, parseDateValue(serializeDateValue({
|
|
438
|
+
year: date.year,
|
|
439
|
+
month: date.month,
|
|
440
|
+
day: date.day,
|
|
441
|
+
})));
|
|
442
|
+
case 'buddhist':
|
|
443
|
+
return validateCalendarRoundTrip(date, calendar, parseDateValue(serializeDateValue({
|
|
444
|
+
year: date.year - 543,
|
|
445
|
+
month: date.month,
|
|
446
|
+
day: date.day,
|
|
447
|
+
})));
|
|
448
|
+
case 'roc':
|
|
449
|
+
return validateCalendarRoundTrip(date, calendar, parseDateValue(serializeDateValue({
|
|
450
|
+
year: date.era === 'roc' ? date.year + 1911 : 1912 - date.year,
|
|
451
|
+
month: date.month,
|
|
452
|
+
day: date.day,
|
|
453
|
+
})));
|
|
454
|
+
case 'japanese': {
|
|
455
|
+
const era = JAPANESE_ERA_DATES.find((candidate) => candidate.id === date.era);
|
|
456
|
+
if (!era) {
|
|
457
|
+
throw new RangeError(`date.era is not a supported Japanese era: ${date.era}.`);
|
|
458
|
+
}
|
|
459
|
+
const candidate = parseDateValue(serializeDateValue({
|
|
460
|
+
year: era.startDate.year + date.year - 1,
|
|
461
|
+
month: date.month,
|
|
462
|
+
day: date.day,
|
|
463
|
+
}));
|
|
464
|
+
return validateCalendarRoundTrip(date, calendar, candidate);
|
|
465
|
+
}
|
|
466
|
+
case 'persian': {
|
|
467
|
+
const year = date.era === 'before-ap' ? -date.year : date.year;
|
|
468
|
+
return validateCalendarRoundTrip(date, calendar, isoFromFixed(getPersianFixed(year, date.month, date.day)));
|
|
469
|
+
}
|
|
470
|
+
case 'islamic-civil': {
|
|
471
|
+
const year = date.era === 'before-ah' ? -date.year : date.year;
|
|
472
|
+
return validateCalendarRoundTrip(date, calendar, isoFromFixed(getIslamicFixed(year, date.month, date.day)));
|
|
473
|
+
}
|
|
474
|
+
case 'hebrew':
|
|
475
|
+
return validateCalendarRoundTrip(date, calendar, isoFromFixed(getHebrewFixed(date.year, hebrewDisplayToTraditionalMonth(date.year, date.month), date.day)));
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function shiftSignedCalendarYear(year, amount) {
|
|
479
|
+
let result = year;
|
|
480
|
+
const direction = Math.sign(amount);
|
|
481
|
+
for (let step = 0; step < Math.abs(amount); step += 1) {
|
|
482
|
+
result += direction;
|
|
483
|
+
if (result === 0)
|
|
484
|
+
result += direction;
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
function getSignedCalendarYear(date) {
|
|
489
|
+
return date.era.startsWith('before-') ? -date.year : date.year;
|
|
490
|
+
}
|
|
491
|
+
function setSignedCalendarYear(date, calendar, year) {
|
|
492
|
+
const beforeEra = calendar === 'persian' ? 'before-ap' : 'before-ah';
|
|
493
|
+
const afterEra = calendar === 'persian' ? 'ap' : 'ah';
|
|
494
|
+
return {
|
|
495
|
+
...date,
|
|
496
|
+
era: year < 0 ? beforeEra : afterEra,
|
|
497
|
+
year: Math.abs(year),
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function clampCalendarDay(source, target, calendar) {
|
|
501
|
+
const firstDay = fromCalendarDate({ ...target, day: 1 }, calendar);
|
|
502
|
+
const targetMonth = getCalendarDate(firstDay, calendar);
|
|
503
|
+
return fromCalendarDate({ ...targetMonth, day: Math.min(source.day, targetMonth.daysInMonth) }, calendar);
|
|
504
|
+
}
|
|
505
|
+
function stepVariableCalendarMonth(date, calendar, direction) {
|
|
506
|
+
if (direction > 0 && date.month < date.monthsInYear) {
|
|
507
|
+
return { ...date, month: date.month + 1 };
|
|
508
|
+
}
|
|
509
|
+
if (direction < 0 && date.month > 1) {
|
|
510
|
+
return { ...date, month: date.month - 1 };
|
|
511
|
+
}
|
|
512
|
+
if (calendar === 'hebrew') {
|
|
513
|
+
const nextYear = date.year + direction;
|
|
514
|
+
const firstDay = fromCalendarDate({ ...date, year: nextYear, month: 1, day: 1 }, calendar);
|
|
515
|
+
const nextYearDate = getCalendarDate(firstDay, calendar);
|
|
516
|
+
return {
|
|
517
|
+
...nextYearDate,
|
|
518
|
+
month: direction > 0 ? 1 : nextYearDate.monthsInYear,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
const nextYear = shiftSignedCalendarYear(getSignedCalendarYear(date), direction);
|
|
522
|
+
return {
|
|
523
|
+
...setSignedCalendarYear(date, calendar, nextYear),
|
|
524
|
+
month: direction > 0 ? 1 : 12,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function addCalendarMonths(date, calendar, amount) {
|
|
528
|
+
if (!Number.isInteger(amount)) {
|
|
529
|
+
throw new RangeError('amount must be an integer number of calendar months.');
|
|
530
|
+
}
|
|
531
|
+
if (calendar === 'gregory' ||
|
|
532
|
+
calendar === 'buddhist' ||
|
|
533
|
+
calendar === 'roc' ||
|
|
534
|
+
calendar === 'japanese') {
|
|
535
|
+
return addIsoMonths(date, amount);
|
|
536
|
+
}
|
|
537
|
+
const source = getCalendarDate(date, calendar);
|
|
538
|
+
let target = source;
|
|
539
|
+
const direction = Math.sign(amount);
|
|
540
|
+
for (let step = 0; step < Math.abs(amount); step += 1) {
|
|
541
|
+
target = stepVariableCalendarMonth(target, calendar, direction);
|
|
542
|
+
const targetFirstDay = fromCalendarDate({ ...target, day: 1 }, calendar);
|
|
543
|
+
target = getCalendarDate(targetFirstDay, calendar);
|
|
544
|
+
}
|
|
545
|
+
return direction === 0 ? date : clampCalendarDay(source, target, calendar);
|
|
546
|
+
}
|
|
547
|
+
function addCalendarYears(date, calendar, amount) {
|
|
548
|
+
if (!Number.isInteger(amount)) {
|
|
549
|
+
throw new RangeError('amount must be an integer number of calendar years.');
|
|
550
|
+
}
|
|
551
|
+
if (calendar === 'gregory' ||
|
|
552
|
+
calendar === 'buddhist' ||
|
|
553
|
+
calendar === 'roc' ||
|
|
554
|
+
calendar === 'japanese') {
|
|
555
|
+
return addIsoYears(date, amount);
|
|
556
|
+
}
|
|
557
|
+
const source = getCalendarDate(date, calendar);
|
|
558
|
+
let target;
|
|
559
|
+
if (calendar === 'hebrew') {
|
|
560
|
+
const firstDay = fromCalendarDate({ ...source, year: source.year + amount, month: 1, day: 1 }, calendar);
|
|
561
|
+
const targetYear = getCalendarDate(firstDay, calendar);
|
|
562
|
+
target = {
|
|
563
|
+
...targetYear,
|
|
564
|
+
month: Math.min(source.month, targetYear.monthsInYear),
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
const targetYear = shiftSignedCalendarYear(getSignedCalendarYear(source), amount);
|
|
569
|
+
target = setSignedCalendarYear(source, calendar, targetYear);
|
|
570
|
+
}
|
|
571
|
+
return amount === 0 ? date : clampCalendarDay(source, target, calendar);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
exports.addCalendarMonths = addCalendarMonths;
|
|
575
|
+
exports.addCalendarYears = addCalendarYears;
|
|
576
|
+
exports.addIsoDays = addIsoDays;
|
|
577
|
+
exports.addIsoMonths = addIsoMonths;
|
|
578
|
+
exports.addIsoYears = addIsoYears;
|
|
579
|
+
exports.compareIsoDates = compareIsoDates;
|
|
580
|
+
exports.epochDayToIsoDate = epochDayToIsoDate;
|
|
581
|
+
exports.fromCalendarDate = fromCalendarDate;
|
|
582
|
+
exports.getCalendarDate = getCalendarDate;
|
|
583
|
+
exports.getDaysInIsoMonth = getDaysInIsoMonth;
|
|
584
|
+
exports.isDateWithinConstraints = isDateWithinConstraints;
|
|
585
|
+
exports.isIsoLeapYear = isIsoLeapYear;
|
|
586
|
+
exports.isoDateToEpochDay = isoDateToEpochDay;
|
|
587
|
+
exports.parseDateValue = parseDateValue;
|
|
588
|
+
exports.serializeDateValue = serializeDateValue;
|
|
589
|
+
exports.validateDateCalendar = validateDateCalendar;
|
|
590
|
+
exports.validateDateConstraints = validateDateConstraints;
|
|
591
|
+
//# sourceMappingURL=dateEngine.cjs.map
|