@servicetitan/anvil2 1.46.1 → 1.46.2
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/CHANGELOG.md +24 -0
- package/dist/{Alert-BNGvfMAV.js → Alert-CPOBY6O5.js} +2 -2
- package/dist/{Alert-BNGvfMAV.js.map → Alert-CPOBY6O5.js.map} +1 -1
- package/dist/Alert.js +1 -1
- package/dist/{Announcement-CoheCP1i.js → Announcement-BvzAEdx8.js} +2 -2
- package/dist/{Announcement-CoheCP1i.js.map → Announcement-BvzAEdx8.js.map} +1 -1
- package/dist/Announcement.js +1 -1
- package/dist/AnvilProvider-C_qRQnE6.js.map +1 -1
- package/dist/Avatar-CyGjhToG.js.map +1 -1
- package/dist/Avatar-D07f9NH_.js.map +1 -1
- package/dist/Badge-DCA9mfc2.js.map +1 -1
- package/dist/Breadcrumbs-C4_PEolS.js.map +1 -1
- package/dist/{Button-BxFXQ0-n.js → Button-VNQQgZ45.js} +2 -2
- package/dist/{Button-BxFXQ0-n.js.map → Button-VNQQgZ45.js.map} +1 -1
- package/dist/Button.css +48 -48
- package/dist/Button.js +1 -1
- package/dist/Button.module-C1g9rrJs.js +25 -0
- package/dist/Button.module-C1g9rrJs.js.map +1 -0
- package/dist/{ButtonCompound-BF2Q6gGX.js → ButtonCompound-BbPK-Xjj.js} +2 -2
- package/dist/{ButtonCompound-BF2Q6gGX.js.map → ButtonCompound-BbPK-Xjj.js.map} +1 -1
- package/dist/ButtonCompound.js +1 -1
- package/dist/{ButtonLink-CXv65WVV.js → ButtonLink-CqR1F5Wn.js} +3 -3
- package/dist/{ButtonLink-CXv65WVV.js.map → ButtonLink-CqR1F5Wn.js.map} +1 -1
- package/dist/ButtonLink.js +1 -1
- package/dist/{ButtonToggle-pSwg7NvT.js → ButtonToggle-PCeSG-5D.js} +3 -3
- package/dist/{ButtonToggle-pSwg7NvT.js.map → ButtonToggle-PCeSG-5D.js.map} +1 -1
- package/dist/ButtonToggle.js +1 -1
- package/dist/{Calendar-BQ5F2ENO.js → Calendar-X9qUi6Vx.js} +269 -123
- package/dist/Calendar-X9qUi6Vx.js.map +1 -0
- package/dist/Calendar.js +1 -1
- package/dist/Card-vTYeSkxt.js.map +1 -1
- package/dist/{Checkbox-DDrmVC-u.js → Checkbox-BDohwHXQ.js} +2 -2
- package/dist/{Checkbox-DDrmVC-u.js.map → Checkbox-BDohwHXQ.js.map} +1 -1
- package/dist/{Checkbox-Dl4KTwEJ.js → Checkbox-CcYtto5f.js} +2 -2
- package/dist/{Checkbox-Dl4KTwEJ.js.map → Checkbox-CcYtto5f.js.map} +1 -1
- package/dist/Checkbox.js +2 -2
- package/dist/Chip-Bz-vlQ4D.js.map +1 -1
- package/dist/{Combobox-B9nesJuc.js → Combobox-DQmW8Tyl.js} +144 -53
- package/dist/Combobox-DQmW8Tyl.js.map +1 -0
- package/dist/Combobox.js +1 -1
- package/dist/{DateField-DXxPsRtf.js → DateField-C43nfkbx.js} +7 -7
- package/dist/{DateField-DXxPsRtf.js.map → DateField-C43nfkbx.js.map} +1 -1
- package/dist/DateField.js +1 -1
- package/dist/{DateFieldRange-Xauviu1w.js → DateFieldRange-g7n5QYww.js} +8 -8
- package/dist/{DateFieldRange-Xauviu1w.js.map → DateFieldRange-g7n5QYww.js.map} +1 -1
- package/dist/DateFieldRange.js +1 -1
- package/dist/{DateFieldSingle-yLnwpVzd.js → DateFieldSingle-D3tneqeG.js} +8 -8
- package/dist/{DateFieldSingle-yLnwpVzd.js.map → DateFieldSingle-D3tneqeG.js.map} +1 -1
- package/dist/DateFieldSingle.js +1 -1
- package/dist/{DateFieldYearless-Ba7HiTiI.js → DateFieldYearless-3JBVj3wn.js} +4 -4
- package/dist/{DateFieldYearless-Ba7HiTiI.js.map → DateFieldYearless-3JBVj3wn.js.map} +1 -1
- package/dist/DateFieldYearless.js +1 -1
- package/dist/{DaysOfTheWeek-BYSYZySH.js → DaysOfTheWeek-RcPgDoM3.js} +4 -4
- package/dist/{DaysOfTheWeek-BYSYZySH.js.map → DaysOfTheWeek-RcPgDoM3.js.map} +1 -1
- package/dist/DaysOfTheWeek.js +1 -1
- package/dist/Details-CF8DImjw.js.map +1 -1
- package/dist/{Dialog-CgkrvrQu.js → Dialog-FNJ16gY6.js} +6 -6
- package/dist/{Dialog-CgkrvrQu.js.map → Dialog-FNJ16gY6.js.map} +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/Divider-DJe8kLf2.js.map +1 -1
- package/dist/Dnd.js +1 -1
- package/dist/DndSort.js +2 -2
- package/dist/DndSort.js.map +1 -1
- package/dist/{Drawer-CM4ZbAro.js → Drawer-DT31CMRd.js} +6 -6
- package/dist/{Drawer-CM4ZbAro.js.map → Drawer-DT31CMRd.js.map} +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{DrawerContext-DboTgTmo.js → DrawerContext-D4tWTLVf.js} +27 -10
- package/dist/DrawerContext-D4tWTLVf.js.map +1 -0
- package/dist/{EditCard-WKzZ2XCz.js → EditCard-CZzL0nx7.js} +2 -2
- package/dist/{EditCard-WKzZ2XCz.js.map → EditCard-CZzL0nx7.js.map} +1 -1
- package/dist/EditCard.js +1 -1
- package/dist/{FieldLabel-BsbTTyom.js → FieldLabel-BP8QK5UR.js} +2 -2
- package/dist/{FieldLabel-BsbTTyom.js.map → FieldLabel-BP8QK5UR.js.map} +1 -1
- package/dist/FieldLabel.js +1 -1
- package/dist/FieldMessage-B7uQ8vmr.js.map +1 -1
- package/dist/Flex-BdQMekvA.js.map +1 -1
- package/dist/Grid-MGUC698u.js.map +1 -1
- package/dist/Helper-BkIDJqgA.js.map +1 -1
- package/dist/Icon-D8SPKeO4.js.map +1 -1
- package/dist/{InputMask-_F139qFu.js → InputMask-CPuYMcw9.js} +3 -3
- package/dist/{InputMask-_F139qFu.js.map → InputMask-CPuYMcw9.js.map} +1 -1
- package/dist/InputMask.js +1 -1
- package/dist/Layout-CUUb2PVr.js.map +1 -1
- package/dist/Link-eRsLWPaQ.js.map +1 -1
- package/dist/LinkButton-2lXfrVoU.js.map +1 -1
- package/dist/{ListView-pb3rIcze.js → ListView-BJI8BQJ-.js} +2 -2
- package/dist/{ListView-pb3rIcze.js.map → ListView-BJI8BQJ-.js.map} +1 -1
- package/dist/ListView.js +1 -1
- package/dist/Listbox-CUhMbFm2.js.map +1 -1
- package/dist/LocalizationContext-UsmB5mnR.js.map +1 -1
- package/dist/LocalizationProvider-DEZyjW5d.js.map +1 -1
- package/dist/{Menu-DEVZz9xZ.js → Menu-t_11BIhU.js} +3 -3
- package/dist/{Menu-DEVZz9xZ.js.map → Menu-t_11BIhU.js.map} +1 -1
- package/dist/Menu.js +1 -1
- package/dist/{NumberField-CkZZrkYC.js → NumberField-Bjf9Tyvf.js} +6 -6
- package/dist/{NumberField-CkZZrkYC.js.map → NumberField-Bjf9Tyvf.js.map} +1 -1
- package/dist/NumberField.js +1 -1
- package/dist/Overflow.js.map +1 -1
- package/dist/{Page-BMDkbDcU.js → Page-BAyXnhz2.js} +9 -9
- package/dist/Page-BAyXnhz2.js.map +1 -0
- package/dist/Page.js +1 -1
- package/dist/{Pagination-BJsCppgW.js → Pagination-DCBic619.js} +47 -23
- package/dist/Pagination-DCBic619.js.map +1 -0
- package/dist/Pagination.css +6 -6
- package/dist/Pagination.js +1 -1
- package/dist/{Popover-r26xMIfm.js → Popover-CrksxqKk.js} +11 -5
- package/dist/Popover-CrksxqKk.js.map +1 -0
- package/dist/Popover.js +1 -1
- package/dist/PortalProvider-9lXkQ0xY.js.map +1 -1
- package/dist/{ProgressBar-DXcXZEJ2.js → ProgressBar-CgsAW2d8.js} +2 -2
- package/dist/{ProgressBar-DXcXZEJ2.js.map → ProgressBar-CgsAW2d8.js.map} +1 -1
- package/dist/ProgressBar.js +1 -1
- package/dist/{Radio-C89VCMXd.js → Radio-C_rvxw74.js} +2 -2
- package/dist/{Radio-C89VCMXd.js.map → Radio-C_rvxw74.js.map} +1 -1
- package/dist/Radio.js +2 -2
- package/dist/{RadioGroup-C_4buUtG.js → RadioGroup-DxBblSrx.js} +2 -2
- package/dist/{RadioGroup-C_4buUtG.js.map → RadioGroup-DxBblSrx.js.map} +1 -1
- package/dist/SearchField-Bb0uObwG.js.map +1 -1
- package/dist/{SegmentedControl-CsjjV1Dz.js → SegmentedControl-DC4BpdH5.js} +3 -3
- package/dist/{SegmentedControl-CsjjV1Dz.js.map → SegmentedControl-DC4BpdH5.js.map} +1 -1
- package/dist/SegmentedControl.js +1 -1
- package/dist/{SelectCard-BTYZg9TG.js → SelectCard-DunNE9R3.js} +3 -3
- package/dist/{SelectCard-BTYZg9TG.js.map → SelectCard-DunNE9R3.js.map} +1 -1
- package/dist/SelectCard.js +1 -1
- package/dist/{SelectTrigger-f1hvRrSC.js → SelectTrigger-BYysLREL.js} +2 -2
- package/dist/{SelectTrigger-f1hvRrSC.js.map → SelectTrigger-BYysLREL.js.map} +1 -1
- package/dist/SelectTrigger.js +1 -1
- package/dist/{SelectTriggerBase-DP9fmRSo.js → SelectTriggerBase-DqUpJgzk.js} +3 -3
- package/dist/{SelectTriggerBase-DP9fmRSo.js.map → SelectTriggerBase-DqUpJgzk.js.map} +1 -1
- package/dist/{SideNav-CBAzYyML.js → SideNav-B9AWmF_H.js} +2 -2
- package/dist/SideNav-B9AWmF_H.js.map +1 -0
- package/dist/SideNav.js +1 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/Spinner-wmO8Epw0.js.map +1 -1
- package/dist/SrOnly-CTsYSuby.js.map +1 -1
- package/dist/{Stepper-D-fOH9TF.js → Stepper-DHTrvfXw.js} +3 -3
- package/dist/{Stepper-D-fOH9TF.js.map → Stepper-DHTrvfXw.js.map} +1 -1
- package/dist/Stepper.js +1 -1
- package/dist/Switch-C2ddZcr9.js.map +1 -1
- package/dist/{Tab-wNucMTgo.js → Tab-0zx9hsw8.js} +44 -36
- package/dist/Tab-0zx9hsw8.js.map +1 -0
- package/dist/Tab.js +1 -1
- package/dist/Text-BqvcbXyp.js.map +1 -1
- package/dist/{TextField-D8fow9j7.js → TextField-CFWs3lm9.js} +2 -2
- package/dist/{TextField-D8fow9j7.js.map → TextField-CFWs3lm9.js.map} +1 -1
- package/dist/{TextField-BiHxlzE3.js → TextField-Cge6IRo5.js} +2 -2
- package/dist/{TextField-BiHxlzE3.js.map → TextField-Cge6IRo5.js.map} +1 -1
- package/dist/TextField.js +1 -1
- package/dist/{Textarea-BdVJJlbP.js → Textarea-CXd3NKkW.js} +2 -2
- package/dist/{Textarea-BdVJJlbP.js.map → Textarea-CXd3NKkW.js.map} +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/ThemeProvider-Be3Pvtpz.js.map +1 -1
- package/dist/ThemeProviderContext-l52GohYT.js.map +1 -1
- package/dist/{TimeField-CmbErrsZ.js → TimeField-4v5aCwiG.js} +345 -355
- package/dist/TimeField-4v5aCwiG.js.map +1 -0
- package/dist/TimeField.js +1 -1
- package/dist/Toast.js +2 -2
- package/dist/{Toaster-9cpG_tWR.js → Toaster-D-rNSLTq.js} +17 -17
- package/dist/{Toaster-9cpG_tWR.js.map → Toaster-D-rNSLTq.js.map} +1 -1
- package/dist/{Toaster-B7zUwJOt.js → Toaster-bON5Xc1P.js} +2 -2
- package/dist/{Toaster-B7zUwJOt.js.map → Toaster-bON5Xc1P.js.map} +1 -1
- package/dist/{Toolbar-D4zuUFhb.js → Toolbar-B2Jsuptz.js} +14 -14
- package/dist/{Toolbar-D4zuUFhb.js.map → Toolbar-B2Jsuptz.js.map} +1 -1
- package/dist/Toolbar.js +1 -1
- package/dist/{Tooltip-BI3Xs75X.js → Tooltip-CtCLw_vx.js} +8 -2
- package/dist/{Tooltip-BI3Xs75X.js.map → Tooltip-CtCLw_vx.js.map} +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/TrackingProvider-BtSjkmpM.js.map +1 -1
- package/dist/beta.js +1 -1
- package/dist/childrenToString-Bz9MqbHb.js.map +1 -1
- package/dist/components/Combobox/ComboboxTypes.d.ts +10 -5
- package/dist/components/Combobox/internal/ComboboxGroupContext.d.ts +1 -1
- package/dist/components/Combobox/internal/useGroups.d.ts +2 -2
- package/dist/components/DndSort/internal/test-utils.d.ts +1 -1
- package/dist/components/TimeField/TimeField.d.ts +4 -1
- package/dist/extends-Bg2s_OKl.js.map +1 -1
- package/dist/getActiveElement-BcSyVE7S.js.map +1 -1
- package/dist/getKeyboardFocusableElements-QqcABz0D.js.map +1 -1
- package/dist/{index-V5Ez2gq_.js → index-DrM3iid4.js} +2 -2
- package/dist/{index-V5Ez2gq_.js.map → index-DrM3iid4.js.map} +1 -1
- package/dist/index-tZvMCc77.js.map +1 -1
- package/dist/{index.esm-D889iexm.js → index.esm-BwMVvxTV.js} +199 -144
- package/dist/index.esm-BwMVvxTV.js.map +1 -0
- package/dist/index.js +45 -45
- package/dist/index.js.map +1 -1
- package/dist/makeZeroShortcutPreprocessor-CxsiGTRW.js.map +1 -1
- package/dist/{proxy-CreWmH-e.js → proxy-BbFHSE6L.js} +8631 -8680
- package/dist/proxy-BbFHSE6L.js.map +1 -0
- package/dist/{use-reduced-motion-znCm41qB.js → use-reduced-motion-DSpxmqyT.js} +3 -3
- package/dist/use-reduced-motion-DSpxmqyT.js.map +1 -0
- package/dist/useAccessibleColor-BYKjkGRg.js.map +1 -1
- package/dist/useBreakpoint-Cv5fnZxs.js.map +1 -1
- package/dist/{useDateFieldOrchestration-BNJCsRkS.js → useDateFieldOrchestration-DyAc3gPJ.js} +3 -3
- package/dist/{useDateFieldOrchestration-BNJCsRkS.js.map → useDateFieldOrchestration-DyAc3gPJ.js.map} +1 -1
- package/dist/{useDialogTransitionStates-2NaE_noq.js → useDialogTransitionStates-C1TtiwA_.js} +3 -3
- package/dist/{useDialogTransitionStates-2NaE_noq.js.map → useDialogTransitionStates-C1TtiwA_.js.map} +1 -1
- package/dist/useFocusWithin-BhhgRXdZ.js.map +1 -1
- package/dist/useInfiniteCombobox-WcRgC9p6.js.map +1 -1
- package/dist/useIntersectionObserver-BEmMDO3P.js.map +1 -1
- package/dist/useLayoutPropsUtil-DjD5IMh0.js.map +1 -1
- package/dist/useMergeRefs-Bde85AWI.js.map +1 -1
- package/dist/{useOnClickOutside-BHEWMLa9.js → useOnClickOutside-B1ddwORK.js} +5 -2
- package/dist/useOnClickOutside-B1ddwORK.js.map +1 -0
- package/dist/useOptionallyControlledState-DbDuos5L.js.map +1 -1
- package/dist/usePopoverCloseDelayWorkaround-BZcjPkvT.js.map +1 -1
- package/dist/{usePopoverSupport-DIjjfodl.js → usePopoverSupport-CWTCDfN2.js} +2 -2
- package/dist/{usePopoverSupport-DIjjfodl.js.map → usePopoverSupport-CWTCDfN2.js.map} +1 -1
- package/dist/usePrefersColorScheme-_hT7dK7_.js.map +1 -1
- package/dist/usePrevious-Bvq-5auG.js.map +1 -1
- package/dist/useSize.js.map +1 -1
- package/dist/{useSwipe-CULmVQEk.js → useSwipe-Cp-CJxLU.js} +2 -2
- package/dist/{useSwipe-CULmVQEk.js.map → useSwipe-Cp-CJxLU.js.map} +1 -1
- package/dist/useSwipe.js +1 -1
- package/dist/useTrackingContext-DRwDL8DE.js.map +1 -1
- package/dist/useTrackingId.js.map +1 -1
- package/package.json +12 -18
- package/dist/Button.module-pUNSKoVC.js +0 -25
- package/dist/Button.module-pUNSKoVC.js.map +0 -1
- package/dist/Calendar-BQ5F2ENO.js.map +0 -1
- package/dist/Combobox-B9nesJuc.js.map +0 -1
- package/dist/DrawerContext-DboTgTmo.js.map +0 -1
- package/dist/Page-BMDkbDcU.js.map +0 -1
- package/dist/Pagination-BJsCppgW.js.map +0 -1
- package/dist/Popover-r26xMIfm.js.map +0 -1
- package/dist/SideNav-CBAzYyML.js.map +0 -1
- package/dist/Tab-wNucMTgo.js.map +0 -1
- package/dist/TimeField-CmbErrsZ.js.map +0 -1
- package/dist/index.esm-D889iexm.js.map +0 -1
- package/dist/proxy-CreWmH-e.js.map +0 -1
- package/dist/use-reduced-motion-znCm41qB.js.map +0 -1
- package/dist/useOnClickOutside-BHEWMLa9.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { createContext, useContext, forwardRef, useState, useEffect, useRef, useCallback, useMemo, useId } from 'react';
|
|
4
|
-
import { B as Button } from './Button-
|
|
4
|
+
import { B as Button } from './Button-VNQQgZ45.js';
|
|
5
5
|
import { S as SvgKeyboardArrowDown } from './keyboard_arrow_down-C8WQ38p1.js';
|
|
6
6
|
import { S as SvgKeyboardArrowUp } from './keyboard_arrow_up-CxzK6LAl.js';
|
|
7
7
|
import { S as SvgKeyboardArrowLeft, a as SvgKeyboardArrowRight } from './keyboard_arrow_right-DZWNVytH.js';
|
|
8
8
|
import { c as cx } from './index-tZvMCc77.js';
|
|
9
9
|
import { S as SrOnly } from './SrOnly-CTsYSuby.js';
|
|
10
|
-
import { u as useSwipe } from './useSwipe-
|
|
10
|
+
import { u as useSwipe } from './useSwipe-Cp-CJxLU.js';
|
|
11
11
|
import { G as Grid } from './Grid-MGUC698u.js';
|
|
12
|
-
import { S as SelectCard } from './SelectCard-
|
|
12
|
+
import { S as SelectCard } from './SelectCard-DunNE9R3.js';
|
|
13
13
|
import { u as useMergeRefs } from './useMergeRefs-Bde85AWI.js';
|
|
14
14
|
import { flushSync } from 'react-dom';
|
|
15
15
|
import { u as useOptionallyControlledState } from './useOptionallyControlledState-DbDuos5L.js';
|
|
@@ -410,12 +410,13 @@ class SystemZone extends Zone {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
|
|
414
|
-
function makeDTF(
|
|
415
|
-
|
|
416
|
-
|
|
413
|
+
const dtfCache = new Map();
|
|
414
|
+
function makeDTF(zoneName) {
|
|
415
|
+
let dtf = dtfCache.get(zoneName);
|
|
416
|
+
if (dtf === undefined) {
|
|
417
|
+
dtf = new Intl.DateTimeFormat("en-US", {
|
|
417
418
|
hour12: false,
|
|
418
|
-
timeZone:
|
|
419
|
+
timeZone: zoneName,
|
|
419
420
|
year: "numeric",
|
|
420
421
|
month: "2-digit",
|
|
421
422
|
day: "2-digit",
|
|
@@ -424,8 +425,9 @@ function makeDTF(zone) {
|
|
|
424
425
|
second: "2-digit",
|
|
425
426
|
era: "short",
|
|
426
427
|
});
|
|
428
|
+
dtfCache.set(zoneName, dtf);
|
|
427
429
|
}
|
|
428
|
-
return
|
|
430
|
+
return dtf;
|
|
429
431
|
}
|
|
430
432
|
|
|
431
433
|
const typeToPos = {
|
|
@@ -461,7 +463,7 @@ function partsOffset(dtf, date) {
|
|
|
461
463
|
return filled;
|
|
462
464
|
}
|
|
463
465
|
|
|
464
|
-
|
|
466
|
+
const ianaZoneCache = new Map();
|
|
465
467
|
/**
|
|
466
468
|
* A zone identified by an IANA identifier, like America/New_York
|
|
467
469
|
* @implements {Zone}
|
|
@@ -472,10 +474,11 @@ class IANAZone extends Zone {
|
|
|
472
474
|
* @return {IANAZone}
|
|
473
475
|
*/
|
|
474
476
|
static create(name) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
+
let zone = ianaZoneCache.get(name);
|
|
478
|
+
if (zone === undefined) {
|
|
479
|
+
ianaZoneCache.set(name, (zone = new IANAZone(name)));
|
|
477
480
|
}
|
|
478
|
-
return
|
|
481
|
+
return zone;
|
|
479
482
|
}
|
|
480
483
|
|
|
481
484
|
/**
|
|
@@ -483,8 +486,8 @@ class IANAZone extends Zone {
|
|
|
483
486
|
* @return {void}
|
|
484
487
|
*/
|
|
485
488
|
static resetCache() {
|
|
486
|
-
ianaZoneCache
|
|
487
|
-
dtfCache
|
|
489
|
+
ianaZoneCache.clear();
|
|
490
|
+
dtfCache.clear();
|
|
488
491
|
}
|
|
489
492
|
|
|
490
493
|
/**
|
|
@@ -587,6 +590,7 @@ class IANAZone extends Zone {
|
|
|
587
590
|
* @return {number}
|
|
588
591
|
*/
|
|
589
592
|
offset(ts) {
|
|
593
|
+
if (!this.valid) return NaN;
|
|
590
594
|
const date = new Date(ts);
|
|
591
595
|
|
|
592
596
|
if (isNaN(date)) return NaN;
|
|
@@ -652,36 +656,36 @@ function getCachedLF(locString, opts = {}) {
|
|
|
652
656
|
return dtf;
|
|
653
657
|
}
|
|
654
658
|
|
|
655
|
-
|
|
659
|
+
const intlDTCache = new Map();
|
|
656
660
|
function getCachedDTF(locString, opts = {}) {
|
|
657
661
|
const key = JSON.stringify([locString, opts]);
|
|
658
|
-
let dtf = intlDTCache
|
|
659
|
-
if (
|
|
662
|
+
let dtf = intlDTCache.get(key);
|
|
663
|
+
if (dtf === undefined) {
|
|
660
664
|
dtf = new Intl.DateTimeFormat(locString, opts);
|
|
661
|
-
intlDTCache
|
|
665
|
+
intlDTCache.set(key, dtf);
|
|
662
666
|
}
|
|
663
667
|
return dtf;
|
|
664
668
|
}
|
|
665
669
|
|
|
666
|
-
|
|
670
|
+
const intlNumCache = new Map();
|
|
667
671
|
function getCachedINF(locString, opts = {}) {
|
|
668
672
|
const key = JSON.stringify([locString, opts]);
|
|
669
|
-
let inf = intlNumCache
|
|
670
|
-
if (
|
|
673
|
+
let inf = intlNumCache.get(key);
|
|
674
|
+
if (inf === undefined) {
|
|
671
675
|
inf = new Intl.NumberFormat(locString, opts);
|
|
672
|
-
intlNumCache
|
|
676
|
+
intlNumCache.set(key, inf);
|
|
673
677
|
}
|
|
674
678
|
return inf;
|
|
675
679
|
}
|
|
676
680
|
|
|
677
|
-
|
|
681
|
+
const intlRelCache = new Map();
|
|
678
682
|
function getCachedRTF(locString, opts = {}) {
|
|
679
683
|
const { base, ...cacheKeyOpts } = opts; // exclude `base` from the options
|
|
680
684
|
const key = JSON.stringify([locString, cacheKeyOpts]);
|
|
681
|
-
let inf = intlRelCache
|
|
682
|
-
if (
|
|
685
|
+
let inf = intlRelCache.get(key);
|
|
686
|
+
if (inf === undefined) {
|
|
683
687
|
inf = new Intl.RelativeTimeFormat(locString, opts);
|
|
684
|
-
intlRelCache
|
|
688
|
+
intlRelCache.set(key, inf);
|
|
685
689
|
}
|
|
686
690
|
return inf;
|
|
687
691
|
}
|
|
@@ -696,14 +700,28 @@ function systemLocale() {
|
|
|
696
700
|
}
|
|
697
701
|
}
|
|
698
702
|
|
|
699
|
-
|
|
703
|
+
const intlResolvedOptionsCache = new Map();
|
|
704
|
+
function getCachedIntResolvedOptions(locString) {
|
|
705
|
+
let opts = intlResolvedOptionsCache.get(locString);
|
|
706
|
+
if (opts === undefined) {
|
|
707
|
+
opts = new Intl.DateTimeFormat(locString).resolvedOptions();
|
|
708
|
+
intlResolvedOptionsCache.set(locString, opts);
|
|
709
|
+
}
|
|
710
|
+
return opts;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const weekInfoCache = new Map();
|
|
700
714
|
function getCachedWeekInfo(locString) {
|
|
701
|
-
let data = weekInfoCache
|
|
715
|
+
let data = weekInfoCache.get(locString);
|
|
702
716
|
if (!data) {
|
|
703
717
|
const locale = new Intl.Locale(locString);
|
|
704
718
|
// browsers currently implement this as a property, but spec says it should be a getter function
|
|
705
719
|
data = "getWeekInfo" in locale ? locale.getWeekInfo() : locale.weekInfo;
|
|
706
|
-
|
|
720
|
+
// minimalDays was removed from WeekInfo: https://github.com/tc39/proposal-intl-locale-info/issues/86
|
|
721
|
+
if (!("minimalDays" in data)) {
|
|
722
|
+
data = { ...fallbackWeekSettings, ...data };
|
|
723
|
+
}
|
|
724
|
+
weekInfoCache.set(locString, data);
|
|
707
725
|
}
|
|
708
726
|
return data;
|
|
709
727
|
}
|
|
@@ -802,7 +820,7 @@ function supportsFastNumbers(loc) {
|
|
|
802
820
|
loc.numberingSystem === "latn" ||
|
|
803
821
|
!loc.locale ||
|
|
804
822
|
loc.locale.startsWith("en") ||
|
|
805
|
-
|
|
823
|
+
getCachedIntResolvedOptions(loc.locale).numberingSystem === "latn"
|
|
806
824
|
);
|
|
807
825
|
}
|
|
808
826
|
}
|
|
@@ -961,7 +979,6 @@ const fallbackWeekSettings = {
|
|
|
961
979
|
/**
|
|
962
980
|
* @private
|
|
963
981
|
*/
|
|
964
|
-
|
|
965
982
|
class Locale {
|
|
966
983
|
static fromOpts(opts) {
|
|
967
984
|
return Locale.create(
|
|
@@ -985,9 +1002,11 @@ class Locale {
|
|
|
985
1002
|
|
|
986
1003
|
static resetCache() {
|
|
987
1004
|
sysLocaleCache = null;
|
|
988
|
-
intlDTCache
|
|
989
|
-
intlNumCache
|
|
990
|
-
intlRelCache
|
|
1005
|
+
intlDTCache.clear();
|
|
1006
|
+
intlNumCache.clear();
|
|
1007
|
+
intlRelCache.clear();
|
|
1008
|
+
intlResolvedOptionsCache.clear();
|
|
1009
|
+
weekInfoCache.clear();
|
|
991
1010
|
}
|
|
992
1011
|
|
|
993
1012
|
static fromObject({ locale, numberingSystem, outputCalendar, weekSettings } = {}) {
|
|
@@ -1052,10 +1071,18 @@ class Locale {
|
|
|
1052
1071
|
|
|
1053
1072
|
months(length, format = false) {
|
|
1054
1073
|
return listStuff(this, length, months, () => {
|
|
1074
|
+
// Workaround for "ja" locale: formatToParts does not label all parts of the month
|
|
1075
|
+
// as "month" and for this locale there is no difference between "format" and "non-format".
|
|
1076
|
+
// As such, just use format() instead of formatToParts() and take the whole string
|
|
1077
|
+
const monthSpecialCase = this.intl === "ja" || this.intl.startsWith("ja-");
|
|
1078
|
+
format &= !monthSpecialCase;
|
|
1055
1079
|
const intl = format ? { month: length, day: "numeric" } : { month: length },
|
|
1056
1080
|
formatStr = format ? "format" : "standalone";
|
|
1057
1081
|
if (!this.monthsCache[formatStr][length]) {
|
|
1058
|
-
|
|
1082
|
+
const mapper = !monthSpecialCase
|
|
1083
|
+
? (dt) => this.extract(dt, intl, "month")
|
|
1084
|
+
: (dt) => this.dtFormatter(dt, intl).format();
|
|
1085
|
+
this.monthsCache[formatStr][length] = mapMonths(mapper);
|
|
1059
1086
|
}
|
|
1060
1087
|
return this.monthsCache[formatStr][length];
|
|
1061
1088
|
});
|
|
@@ -1141,7 +1168,7 @@ class Locale {
|
|
|
1141
1168
|
return (
|
|
1142
1169
|
this.locale === "en" ||
|
|
1143
1170
|
this.locale.toLowerCase() === "en-us" ||
|
|
1144
|
-
|
|
1171
|
+
getCachedIntResolvedOptions(this.intl).locale.startsWith("en-us")
|
|
1145
1172
|
);
|
|
1146
1173
|
}
|
|
1147
1174
|
|
|
@@ -1384,7 +1411,6 @@ class InvalidZone extends Zone {
|
|
|
1384
1411
|
* @private
|
|
1385
1412
|
*/
|
|
1386
1413
|
|
|
1387
|
-
|
|
1388
1414
|
function normalizeZone(input, defaultZone) {
|
|
1389
1415
|
if (isUndefined(input) || input === null) {
|
|
1390
1416
|
return defaultZone;
|
|
@@ -1480,22 +1506,26 @@ function parseDigits(str) {
|
|
|
1480
1506
|
}
|
|
1481
1507
|
|
|
1482
1508
|
// cache of {numberingSystem: {append: regex}}
|
|
1483
|
-
|
|
1509
|
+
const digitRegexCache = new Map();
|
|
1484
1510
|
function resetDigitRegexCache() {
|
|
1485
|
-
digitRegexCache
|
|
1511
|
+
digitRegexCache.clear();
|
|
1486
1512
|
}
|
|
1487
1513
|
|
|
1488
1514
|
function digitRegex({ numberingSystem }, append = "") {
|
|
1489
1515
|
const ns = numberingSystem || "latn";
|
|
1490
1516
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1517
|
+
let appendCache = digitRegexCache.get(ns);
|
|
1518
|
+
if (appendCache === undefined) {
|
|
1519
|
+
appendCache = new Map();
|
|
1520
|
+
digitRegexCache.set(ns, appendCache);
|
|
1493
1521
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1522
|
+
let regex = appendCache.get(append);
|
|
1523
|
+
if (regex === undefined) {
|
|
1524
|
+
regex = new RegExp(`${numberingSystems[ns]}${append}`);
|
|
1525
|
+
appendCache.set(append, regex);
|
|
1496
1526
|
}
|
|
1497
1527
|
|
|
1498
|
-
return
|
|
1528
|
+
return regex;
|
|
1499
1529
|
}
|
|
1500
1530
|
|
|
1501
1531
|
let now = () => Date.now(),
|
|
@@ -1885,7 +1915,6 @@ function hasInvalidTimeData(obj) {
|
|
|
1885
1915
|
it up into, say, parsingUtil.js and basicUtil.js and so on. But they are divided up by feature area.
|
|
1886
1916
|
*/
|
|
1887
1917
|
|
|
1888
|
-
|
|
1889
1918
|
/**
|
|
1890
1919
|
* @private
|
|
1891
1920
|
*/
|
|
@@ -2037,10 +2066,24 @@ function parseMillis(fraction) {
|
|
|
2037
2066
|
}
|
|
2038
2067
|
}
|
|
2039
2068
|
|
|
2040
|
-
function roundTo(number, digits,
|
|
2041
|
-
const factor = 10 ** digits
|
|
2042
|
-
|
|
2043
|
-
|
|
2069
|
+
function roundTo(number, digits, rounding = "round") {
|
|
2070
|
+
const factor = 10 ** digits;
|
|
2071
|
+
switch (rounding) {
|
|
2072
|
+
case "expand":
|
|
2073
|
+
return number > 0
|
|
2074
|
+
? Math.ceil(number * factor) / factor
|
|
2075
|
+
: Math.floor(number * factor) / factor;
|
|
2076
|
+
case "trunc":
|
|
2077
|
+
return Math.trunc(number * factor) / factor;
|
|
2078
|
+
case "round":
|
|
2079
|
+
return Math.round(number * factor) / factor;
|
|
2080
|
+
case "floor":
|
|
2081
|
+
return Math.floor(number * factor) / factor;
|
|
2082
|
+
case "ceil":
|
|
2083
|
+
return Math.ceil(number * factor) / factor;
|
|
2084
|
+
default:
|
|
2085
|
+
throw new RangeError(`Value rounding ${rounding} is out of range`);
|
|
2086
|
+
}
|
|
2044
2087
|
}
|
|
2045
2088
|
|
|
2046
2089
|
// DATE BASICS
|
|
@@ -2148,7 +2191,7 @@ function signedOffset(offHourStr, offMinuteStr) {
|
|
|
2148
2191
|
|
|
2149
2192
|
function asNumber(value) {
|
|
2150
2193
|
const numericValue = Number(value);
|
|
2151
|
-
if (typeof value === "boolean" || value === "" || Number.
|
|
2194
|
+
if (typeof value === "boolean" || value === "" || !Number.isFinite(numericValue))
|
|
2152
2195
|
throw new InvalidArgumentError(`Invalid unit value ${value}`);
|
|
2153
2196
|
return numericValue;
|
|
2154
2197
|
}
|
|
@@ -2407,8 +2450,12 @@ class Formatter {
|
|
|
2407
2450
|
for (let i = 0; i < fmt.length; i++) {
|
|
2408
2451
|
const c = fmt.charAt(i);
|
|
2409
2452
|
if (c === "'") {
|
|
2410
|
-
|
|
2411
|
-
|
|
2453
|
+
// turn '' into a literal signal quote instead of just skipping the empty literal
|
|
2454
|
+
if (currentFull.length > 0 || bracketed) {
|
|
2455
|
+
splits.push({
|
|
2456
|
+
literal: bracketed || /^\s+$/.test(currentFull),
|
|
2457
|
+
val: currentFull === "" ? "'" : currentFull,
|
|
2458
|
+
});
|
|
2412
2459
|
}
|
|
2413
2460
|
current = null;
|
|
2414
2461
|
currentFull = "";
|
|
@@ -2472,7 +2519,7 @@ class Formatter {
|
|
|
2472
2519
|
return this.dtFormatter(dt, opts).resolvedOptions();
|
|
2473
2520
|
}
|
|
2474
2521
|
|
|
2475
|
-
num(n, p = 0) {
|
|
2522
|
+
num(n, p = 0, signDisplay = undefined) {
|
|
2476
2523
|
// we get some perf out of doing this here, annoyingly
|
|
2477
2524
|
if (this.opts.forceSimple) {
|
|
2478
2525
|
return padStart(n, p);
|
|
@@ -2483,6 +2530,9 @@ class Formatter {
|
|
|
2483
2530
|
if (p > 0) {
|
|
2484
2531
|
opts.padTo = p;
|
|
2485
2532
|
}
|
|
2533
|
+
if (signDisplay) {
|
|
2534
|
+
opts.signDisplay = signDisplay;
|
|
2535
|
+
}
|
|
2486
2536
|
|
|
2487
2537
|
return this.loc.numberFormatter(opts).format(n);
|
|
2488
2538
|
}
|
|
@@ -2718,32 +2768,44 @@ class Formatter {
|
|
|
2718
2768
|
}
|
|
2719
2769
|
|
|
2720
2770
|
formatDurationFromString(dur, fmt) {
|
|
2771
|
+
const invertLargest = this.opts.signMode === "negativeLargestOnly" ? -1 : 1;
|
|
2721
2772
|
const tokenToField = (token) => {
|
|
2722
2773
|
switch (token[0]) {
|
|
2723
2774
|
case "S":
|
|
2724
|
-
return "
|
|
2775
|
+
return "milliseconds";
|
|
2725
2776
|
case "s":
|
|
2726
|
-
return "
|
|
2777
|
+
return "seconds";
|
|
2727
2778
|
case "m":
|
|
2728
|
-
return "
|
|
2779
|
+
return "minutes";
|
|
2729
2780
|
case "h":
|
|
2730
|
-
return "
|
|
2781
|
+
return "hours";
|
|
2731
2782
|
case "d":
|
|
2732
|
-
return "
|
|
2783
|
+
return "days";
|
|
2733
2784
|
case "w":
|
|
2734
|
-
return "
|
|
2785
|
+
return "weeks";
|
|
2735
2786
|
case "M":
|
|
2736
|
-
return "
|
|
2787
|
+
return "months";
|
|
2737
2788
|
case "y":
|
|
2738
|
-
return "
|
|
2789
|
+
return "years";
|
|
2739
2790
|
default:
|
|
2740
2791
|
return null;
|
|
2741
2792
|
}
|
|
2742
2793
|
},
|
|
2743
|
-
tokenToString = (lildur) => (token) => {
|
|
2794
|
+
tokenToString = (lildur, info) => (token) => {
|
|
2744
2795
|
const mapped = tokenToField(token);
|
|
2745
2796
|
if (mapped) {
|
|
2746
|
-
|
|
2797
|
+
const inversionFactor =
|
|
2798
|
+
info.isNegativeDuration && mapped !== info.largestUnit ? invertLargest : 1;
|
|
2799
|
+
let signDisplay;
|
|
2800
|
+
if (this.opts.signMode === "negativeLargestOnly" && mapped !== info.largestUnit) {
|
|
2801
|
+
signDisplay = "never";
|
|
2802
|
+
} else if (this.opts.signMode === "all") {
|
|
2803
|
+
signDisplay = "always";
|
|
2804
|
+
} else {
|
|
2805
|
+
// "auto" and "negative" are the same, but "auto" has better support
|
|
2806
|
+
signDisplay = "auto";
|
|
2807
|
+
}
|
|
2808
|
+
return this.num(lildur.get(mapped) * inversionFactor, token.length, signDisplay);
|
|
2747
2809
|
} else {
|
|
2748
2810
|
return token;
|
|
2749
2811
|
}
|
|
@@ -2753,8 +2815,14 @@ class Formatter {
|
|
|
2753
2815
|
(found, { literal, val }) => (literal ? found : found.concat(val)),
|
|
2754
2816
|
[]
|
|
2755
2817
|
),
|
|
2756
|
-
collapsed = dur.shiftTo(...realTokens.map(tokenToField).filter((t) => t))
|
|
2757
|
-
|
|
2818
|
+
collapsed = dur.shiftTo(...realTokens.map(tokenToField).filter((t) => t)),
|
|
2819
|
+
durationInfo = {
|
|
2820
|
+
isNegativeDuration: collapsed < 0,
|
|
2821
|
+
// this relies on "collapsed" being based on "shiftTo", which builds up the object
|
|
2822
|
+
// in order
|
|
2823
|
+
largestUnit: Object.keys(collapsed.values)[0],
|
|
2824
|
+
};
|
|
2825
|
+
return stringifyTokens(tokens, tokenToString(collapsed, durationInfo));
|
|
2758
2826
|
}
|
|
2759
2827
|
}
|
|
2760
2828
|
|
|
@@ -2815,11 +2883,11 @@ function simpleParse(...keys) {
|
|
|
2815
2883
|
}
|
|
2816
2884
|
|
|
2817
2885
|
// ISO and SQL parsing
|
|
2818
|
-
const offsetRegex = /(?:(
|
|
2886
|
+
const offsetRegex = /(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/;
|
|
2819
2887
|
const isoExtendedZone = `(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`;
|
|
2820
2888
|
const isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
|
|
2821
2889
|
const isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`);
|
|
2822
|
-
const isoTimeExtensionRegex = RegExp(`(?:
|
|
2890
|
+
const isoTimeExtensionRegex = RegExp(`(?:[Tt]${isoTimeRegex.source})?`);
|
|
2823
2891
|
const isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
|
|
2824
2892
|
const isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
|
|
2825
2893
|
const isoOrdinalRegex = /(\d{4})-?(\d{3})/;
|
|
@@ -3534,9 +3602,13 @@ class Duration {
|
|
|
3534
3602
|
* @param {string} fmt - the format string
|
|
3535
3603
|
* @param {Object} opts - options
|
|
3536
3604
|
* @param {boolean} [opts.floor=true] - floor numerical values
|
|
3605
|
+
* @param {'negative'|'all'|'negativeLargestOnly'} [opts.signMode=negative] - How to handle signs
|
|
3537
3606
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"
|
|
3538
3607
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"
|
|
3539
3608
|
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"
|
|
3609
|
+
* @example Duration.fromObject({ days: 6, seconds: 2 }).toFormat("d s", { signMode: "all" }) //=> "+6 +2"
|
|
3610
|
+
* @example Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "all" }) //=> "-6 -2"
|
|
3611
|
+
* @example Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "negativeLargestOnly" }) //=> "-6 2"
|
|
3540
3612
|
* @return {string}
|
|
3541
3613
|
*/
|
|
3542
3614
|
toFormat(fmt, opts = {}) {
|
|
@@ -3556,21 +3628,25 @@ class Duration {
|
|
|
3556
3628
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
3557
3629
|
* @param {Object} opts - Formatting options. Accepts the same keys as the options parameter of the native `Intl.NumberFormat` constructor, as well as `listStyle`.
|
|
3558
3630
|
* @param {string} [opts.listStyle='narrow'] - How to format the merged list. Corresponds to the `style` property of the options parameter of the native `Intl.ListFormat` constructor.
|
|
3631
|
+
* @param {boolean} [opts.showZeros=true] - Show all units previously used by the duration even if they are zero
|
|
3559
3632
|
* @example
|
|
3560
3633
|
* ```js
|
|
3561
|
-
* var dur = Duration.fromObject({
|
|
3562
|
-
* dur.toHuman() //=> '1
|
|
3563
|
-
* dur.toHuman({ listStyle: "long" }) //=> '1
|
|
3564
|
-
* dur.toHuman({ unitDisplay: "short" }) //=> '1
|
|
3634
|
+
* var dur = Duration.fromObject({ months: 1, weeks: 0, hours: 5, minutes: 6 })
|
|
3635
|
+
* dur.toHuman() //=> '1 month, 0 weeks, 5 hours, 6 minutes'
|
|
3636
|
+
* dur.toHuman({ listStyle: "long" }) //=> '1 month, 0 weeks, 5 hours, and 6 minutes'
|
|
3637
|
+
* dur.toHuman({ unitDisplay: "short" }) //=> '1 mth, 0 wks, 5 hr, 6 min'
|
|
3638
|
+
* dur.toHuman({ showZeros: false }) //=> '1 month, 5 hours, 6 minutes'
|
|
3565
3639
|
* ```
|
|
3566
3640
|
*/
|
|
3567
3641
|
toHuman(opts = {}) {
|
|
3568
3642
|
if (!this.isValid) return INVALID$2;
|
|
3569
3643
|
|
|
3644
|
+
const showZeros = opts.showZeros !== false;
|
|
3645
|
+
|
|
3570
3646
|
const l = orderedUnits$1
|
|
3571
3647
|
.map((unit) => {
|
|
3572
3648
|
const val = this.values[unit];
|
|
3573
|
-
if (isUndefined(val)) {
|
|
3649
|
+
if (isUndefined(val) || (val === 0 && !showZeros)) {
|
|
3574
3650
|
return null;
|
|
3575
3651
|
}
|
|
3576
3652
|
return this.loc
|
|
@@ -3930,6 +4006,17 @@ class Duration {
|
|
|
3930
4006
|
return clone$1(this, { values: negated }, true);
|
|
3931
4007
|
}
|
|
3932
4008
|
|
|
4009
|
+
/**
|
|
4010
|
+
* Removes all units with values equal to 0 from this Duration.
|
|
4011
|
+
* @example Duration.fromObject({ years: 2, days: 0, hours: 0, minutes: 0 }).removeZeros().toObject() //=> { years: 2 }
|
|
4012
|
+
* @return {Duration}
|
|
4013
|
+
*/
|
|
4014
|
+
removeZeros() {
|
|
4015
|
+
if (!this.isValid) return this;
|
|
4016
|
+
const vals = removeZeroes(this.values);
|
|
4017
|
+
return clone$1(this, { values: vals }, true);
|
|
4018
|
+
}
|
|
4019
|
+
|
|
3933
4020
|
/**
|
|
3934
4021
|
* Get the years.
|
|
3935
4022
|
* @type {number}
|
|
@@ -4240,13 +4327,22 @@ class Interval {
|
|
|
4240
4327
|
}
|
|
4241
4328
|
|
|
4242
4329
|
/**
|
|
4243
|
-
* Returns the end of the Interval
|
|
4330
|
+
* Returns the end of the Interval. This is the first instant which is not part of the interval
|
|
4331
|
+
* (Interval is half-open).
|
|
4244
4332
|
* @type {DateTime}
|
|
4245
4333
|
*/
|
|
4246
4334
|
get end() {
|
|
4247
4335
|
return this.isValid ? this.e : null;
|
|
4248
4336
|
}
|
|
4249
4337
|
|
|
4338
|
+
/**
|
|
4339
|
+
* Returns the last DateTime included in the interval (since end is not part of the interval)
|
|
4340
|
+
* @type {DateTime}
|
|
4341
|
+
*/
|
|
4342
|
+
get lastDateTime() {
|
|
4343
|
+
return this.isValid ? (this.e ? this.e.minus(1) : null) : null;
|
|
4344
|
+
}
|
|
4345
|
+
|
|
4250
4346
|
/**
|
|
4251
4347
|
* Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
|
|
4252
4348
|
* @type {boolean}
|
|
@@ -4511,8 +4607,11 @@ class Interval {
|
|
|
4511
4607
|
}
|
|
4512
4608
|
|
|
4513
4609
|
/**
|
|
4514
|
-
* Merge an array of Intervals into
|
|
4610
|
+
* Merge an array of Intervals into an equivalent minimal set of Intervals.
|
|
4515
4611
|
* Combines overlapping and adjacent Intervals.
|
|
4612
|
+
* The resulting array will contain the Intervals in ascending order, that is, starting with the earliest Interval
|
|
4613
|
+
* and ending with the latest.
|
|
4614
|
+
*
|
|
4516
4615
|
* @param {Array} intervals
|
|
4517
4616
|
* @return {Array}
|
|
4518
4617
|
*/
|
|
@@ -5660,21 +5759,22 @@ function toTechFormat(dt, format, allowZ = true) {
|
|
|
5660
5759
|
: null;
|
|
5661
5760
|
}
|
|
5662
5761
|
|
|
5663
|
-
function toISODate(o, extended) {
|
|
5762
|
+
function toISODate(o, extended, precision) {
|
|
5664
5763
|
const longFormat = o.c.year > 9999 || o.c.year < 0;
|
|
5665
5764
|
let c = "";
|
|
5666
5765
|
if (longFormat && o.c.year >= 0) c += "+";
|
|
5667
5766
|
c += padStart(o.c.year, longFormat ? 6 : 4);
|
|
5668
|
-
|
|
5767
|
+
if (precision === "year") return c;
|
|
5669
5768
|
if (extended) {
|
|
5670
5769
|
c += "-";
|
|
5671
5770
|
c += padStart(o.c.month);
|
|
5771
|
+
if (precision === "month") return c;
|
|
5672
5772
|
c += "-";
|
|
5673
|
-
c += padStart(o.c.day);
|
|
5674
5773
|
} else {
|
|
5675
5774
|
c += padStart(o.c.month);
|
|
5676
|
-
|
|
5775
|
+
if (precision === "month") return c;
|
|
5677
5776
|
}
|
|
5777
|
+
c += padStart(o.c.day);
|
|
5678
5778
|
return c;
|
|
5679
5779
|
}
|
|
5680
5780
|
|
|
@@ -5684,26 +5784,39 @@ function toISOTime(
|
|
|
5684
5784
|
suppressSeconds,
|
|
5685
5785
|
suppressMilliseconds,
|
|
5686
5786
|
includeOffset,
|
|
5687
|
-
extendedZone
|
|
5787
|
+
extendedZone,
|
|
5788
|
+
precision
|
|
5688
5789
|
) {
|
|
5689
|
-
let
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5790
|
+
let showSeconds = !suppressSeconds || o.c.millisecond !== 0 || o.c.second !== 0,
|
|
5791
|
+
c = "";
|
|
5792
|
+
switch (precision) {
|
|
5793
|
+
case "day":
|
|
5794
|
+
case "month":
|
|
5795
|
+
case "year":
|
|
5796
|
+
break;
|
|
5797
|
+
default:
|
|
5798
|
+
c += padStart(o.c.hour);
|
|
5799
|
+
if (precision === "hour") break;
|
|
5800
|
+
if (extended) {
|
|
5801
|
+
c += ":";
|
|
5802
|
+
c += padStart(o.c.minute);
|
|
5803
|
+
if (precision === "minute") break;
|
|
5804
|
+
if (showSeconds) {
|
|
5805
|
+
c += ":";
|
|
5806
|
+
c += padStart(o.c.second);
|
|
5807
|
+
}
|
|
5808
|
+
} else {
|
|
5809
|
+
c += padStart(o.c.minute);
|
|
5810
|
+
if (precision === "minute") break;
|
|
5811
|
+
if (showSeconds) {
|
|
5812
|
+
c += padStart(o.c.second);
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
if (precision === "second") break;
|
|
5816
|
+
if (showSeconds && (!suppressMilliseconds || o.c.millisecond !== 0)) {
|
|
5817
|
+
c += ".";
|
|
5818
|
+
c += padStart(o.c.millisecond, 3);
|
|
5819
|
+
}
|
|
5707
5820
|
}
|
|
5708
5821
|
|
|
5709
5822
|
if (includeOffset) {
|
|
@@ -5835,15 +5948,27 @@ function normalizeUnitWithLocalWeeks(unit) {
|
|
|
5835
5948
|
// This is safe for quickDT (used by local() and utc()) because we don't fill in
|
|
5836
5949
|
// higher-order units from tsNow (as we do in fromObject, this requires that
|
|
5837
5950
|
// offset is calculated from tsNow).
|
|
5951
|
+
/**
|
|
5952
|
+
* @param {Zone} zone
|
|
5953
|
+
* @return {number}
|
|
5954
|
+
*/
|
|
5838
5955
|
function guessOffsetForZone(zone) {
|
|
5839
|
-
if (
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
}
|
|
5956
|
+
if (zoneOffsetTs === undefined) {
|
|
5957
|
+
zoneOffsetTs = Settings.now();
|
|
5958
|
+
}
|
|
5843
5959
|
|
|
5844
|
-
|
|
5960
|
+
// Do not cache anything but IANA zones, because it is not safe to do so.
|
|
5961
|
+
// Guessing an offset which is not present in the zone can cause wrong results from fixOffset
|
|
5962
|
+
if (zone.type !== "iana") {
|
|
5963
|
+
return zone.offset(zoneOffsetTs);
|
|
5964
|
+
}
|
|
5965
|
+
const zoneName = zone.name;
|
|
5966
|
+
let offsetGuess = zoneOffsetGuessCache.get(zoneName);
|
|
5967
|
+
if (offsetGuess === undefined) {
|
|
5968
|
+
offsetGuess = zone.offset(zoneOffsetTs);
|
|
5969
|
+
zoneOffsetGuessCache.set(zoneName, offsetGuess);
|
|
5845
5970
|
}
|
|
5846
|
-
return
|
|
5971
|
+
return offsetGuess;
|
|
5847
5972
|
}
|
|
5848
5973
|
|
|
5849
5974
|
// this is a dumbed down version of fromObject() that runs about 60% faster
|
|
@@ -5883,8 +6008,9 @@ function quickDT(obj, opts) {
|
|
|
5883
6008
|
|
|
5884
6009
|
function diffRelative(start, end, opts) {
|
|
5885
6010
|
const round = isUndefined(opts.round) ? true : opts.round,
|
|
6011
|
+
rounding = isUndefined(opts.rounding) ? "trunc" : opts.rounding,
|
|
5886
6012
|
format = (c, unit) => {
|
|
5887
|
-
c = roundTo(c, round || opts.calendary ? 0 : 2,
|
|
6013
|
+
c = roundTo(c, round || opts.calendary ? 0 : 2, opts.calendary ? "round" : rounding);
|
|
5888
6014
|
const formatter = end.loc.clone(opts).relFormatter(opts);
|
|
5889
6015
|
return formatter.format(c, unit);
|
|
5890
6016
|
},
|
|
@@ -5933,7 +6059,7 @@ let zoneOffsetTs;
|
|
|
5933
6059
|
* This optimizes quickDT via guessOffsetForZone to avoid repeated calls of
|
|
5934
6060
|
* zone.offset().
|
|
5935
6061
|
*/
|
|
5936
|
-
|
|
6062
|
+
const zoneOffsetGuessCache = new Map();
|
|
5937
6063
|
|
|
5938
6064
|
/**
|
|
5939
6065
|
* A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
|
|
@@ -6137,7 +6263,7 @@ class DateTime {
|
|
|
6137
6263
|
throw new InvalidArgumentError(
|
|
6138
6264
|
`fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
|
|
6139
6265
|
);
|
|
6140
|
-
} else if (milliseconds < -
|
|
6266
|
+
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
|
|
6141
6267
|
// this isn't perfect because we can still end up out of range because of additional shifting, but it's a start
|
|
6142
6268
|
return DateTime.invalid("Timestamp out of range");
|
|
6143
6269
|
} else {
|
|
@@ -6498,7 +6624,7 @@ class DateTime {
|
|
|
6498
6624
|
|
|
6499
6625
|
static resetCache() {
|
|
6500
6626
|
zoneOffsetTs = undefined;
|
|
6501
|
-
zoneOffsetGuessCache
|
|
6627
|
+
zoneOffsetGuessCache.clear();
|
|
6502
6628
|
}
|
|
6503
6629
|
|
|
6504
6630
|
// INFO
|
|
@@ -7263,11 +7389,14 @@ class DateTime {
|
|
|
7263
7389
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|
7264
7390
|
* @param {boolean} [opts.extendedZone=false] - add the time zone format extension
|
|
7265
7391
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
7392
|
+
* @param {string} [opts.precision='milliseconds'] - truncate output to desired presicion: 'years', 'months', 'days', 'hours', 'minutes', 'seconds' or 'milliseconds'. When precision and suppressSeconds or suppressMilliseconds are used together, precision sets the maximum unit shown in the output, however seconds or milliseconds will still be suppressed if they are 0.
|
|
7266
7393
|
* @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
|
7267
7394
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|
7268
7395
|
* @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
|
|
7269
7396
|
* @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
|
|
7270
|
-
* @
|
|
7397
|
+
* @example DateTime.now().toISO({ precision: 'day' }) //=> '2017-04-22Z'
|
|
7398
|
+
* @example DateTime.now().toISO({ precision: 'minute' }) //=> '2017-04-22T20:47Z'
|
|
7399
|
+
* @return {string|null}
|
|
7271
7400
|
*/
|
|
7272
7401
|
toISO({
|
|
7273
7402
|
format = "extended",
|
|
@@ -7275,16 +7404,26 @@ class DateTime {
|
|
|
7275
7404
|
suppressMilliseconds = false,
|
|
7276
7405
|
includeOffset = true,
|
|
7277
7406
|
extendedZone = false,
|
|
7407
|
+
precision = "milliseconds",
|
|
7278
7408
|
} = {}) {
|
|
7279
7409
|
if (!this.isValid) {
|
|
7280
7410
|
return null;
|
|
7281
7411
|
}
|
|
7282
7412
|
|
|
7413
|
+
precision = normalizeUnit(precision);
|
|
7283
7414
|
const ext = format === "extended";
|
|
7284
7415
|
|
|
7285
|
-
let c = toISODate(this, ext);
|
|
7286
|
-
c += "T";
|
|
7287
|
-
c += toISOTime(
|
|
7416
|
+
let c = toISODate(this, ext, precision);
|
|
7417
|
+
if (orderedUnits.indexOf(precision) >= 3) c += "T";
|
|
7418
|
+
c += toISOTime(
|
|
7419
|
+
this,
|
|
7420
|
+
ext,
|
|
7421
|
+
suppressSeconds,
|
|
7422
|
+
suppressMilliseconds,
|
|
7423
|
+
includeOffset,
|
|
7424
|
+
extendedZone,
|
|
7425
|
+
precision
|
|
7426
|
+
);
|
|
7288
7427
|
return c;
|
|
7289
7428
|
}
|
|
7290
7429
|
|
|
@@ -7292,16 +7431,17 @@ class DateTime {
|
|
|
7292
7431
|
* Returns an ISO 8601-compliant string representation of this DateTime's date component
|
|
7293
7432
|
* @param {Object} opts - options
|
|
7294
7433
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
7434
|
+
* @param {string} [opts.precision='day'] - truncate output to desired precision: 'years', 'months', or 'days'.
|
|
7295
7435
|
* @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
|
|
7296
7436
|
* @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
|
|
7297
|
-
* @
|
|
7437
|
+
* @example DateTime.utc(1982, 5, 25).toISODate({ precision: 'month' }) //=> '1982-05'
|
|
7438
|
+
* @return {string|null}
|
|
7298
7439
|
*/
|
|
7299
|
-
toISODate({ format = "extended" } = {}) {
|
|
7440
|
+
toISODate({ format = "extended", precision = "day" } = {}) {
|
|
7300
7441
|
if (!this.isValid) {
|
|
7301
7442
|
return null;
|
|
7302
7443
|
}
|
|
7303
|
-
|
|
7304
|
-
return toISODate(this, format === "extended");
|
|
7444
|
+
return toISODate(this, format === "extended", normalizeUnit(precision));
|
|
7305
7445
|
}
|
|
7306
7446
|
|
|
7307
7447
|
/**
|
|
@@ -7322,10 +7462,12 @@ class DateTime {
|
|
|
7322
7462
|
* @param {boolean} [opts.extendedZone=true] - add the time zone format extension
|
|
7323
7463
|
* @param {boolean} [opts.includePrefix=false] - include the `T` prefix
|
|
7324
7464
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
7465
|
+
* @param {string} [opts.precision='milliseconds'] - truncate output to desired presicion: 'hours', 'minutes', 'seconds' or 'milliseconds'. When precision and suppressSeconds or suppressMilliseconds are used together, precision sets the maximum unit shown in the output, however seconds or milliseconds will still be suppressed if they are 0.
|
|
7325
7466
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
|
|
7326
7467
|
* @example DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
|
|
7327
7468
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'
|
|
7328
7469
|
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'
|
|
7470
|
+
* @example DateTime.utc().set({ hour: 7, minute: 34, second: 56 }).toISOTime({ precision: 'minute' }) //=> '07:34Z'
|
|
7329
7471
|
* @return {string}
|
|
7330
7472
|
*/
|
|
7331
7473
|
toISOTime({
|
|
@@ -7335,12 +7477,14 @@ class DateTime {
|
|
|
7335
7477
|
includePrefix = false,
|
|
7336
7478
|
extendedZone = false,
|
|
7337
7479
|
format = "extended",
|
|
7480
|
+
precision = "milliseconds",
|
|
7338
7481
|
} = {}) {
|
|
7339
7482
|
if (!this.isValid) {
|
|
7340
7483
|
return null;
|
|
7341
7484
|
}
|
|
7342
7485
|
|
|
7343
|
-
|
|
7486
|
+
precision = normalizeUnit(precision);
|
|
7487
|
+
let c = includePrefix && orderedUnits.indexOf(precision) >= 3 ? "T" : "";
|
|
7344
7488
|
return (
|
|
7345
7489
|
c +
|
|
7346
7490
|
toISOTime(
|
|
@@ -7349,7 +7493,8 @@ class DateTime {
|
|
|
7349
7493
|
suppressSeconds,
|
|
7350
7494
|
suppressMilliseconds,
|
|
7351
7495
|
includeOffset,
|
|
7352
|
-
extendedZone
|
|
7496
|
+
extendedZone,
|
|
7497
|
+
precision
|
|
7353
7498
|
)
|
|
7354
7499
|
);
|
|
7355
7500
|
}
|
|
@@ -7379,7 +7524,7 @@ class DateTime {
|
|
|
7379
7524
|
/**
|
|
7380
7525
|
* Returns a string representation of this DateTime appropriate for use in SQL Date
|
|
7381
7526
|
* @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
|
|
7382
|
-
* @return {string}
|
|
7527
|
+
* @return {string|null}
|
|
7383
7528
|
*/
|
|
7384
7529
|
toSQLDate() {
|
|
7385
7530
|
if (!this.isValid) {
|
|
@@ -7474,7 +7619,7 @@ class DateTime {
|
|
|
7474
7619
|
}
|
|
7475
7620
|
|
|
7476
7621
|
/**
|
|
7477
|
-
* Returns the epoch seconds of this DateTime.
|
|
7622
|
+
* Returns the epoch seconds (including milliseconds in the fractional part) of this DateTime.
|
|
7478
7623
|
* @return {number}
|
|
7479
7624
|
*/
|
|
7480
7625
|
toSeconds() {
|
|
@@ -7581,7 +7726,7 @@ class DateTime {
|
|
|
7581
7726
|
/**
|
|
7582
7727
|
* Return an Interval spanning between this DateTime and another DateTime
|
|
7583
7728
|
* @param {DateTime} otherDateTime - the other end point of the Interval
|
|
7584
|
-
* @return {Interval}
|
|
7729
|
+
* @return {Interval|DateTime}
|
|
7585
7730
|
*/
|
|
7586
7731
|
until(otherDateTime) {
|
|
7587
7732
|
return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
|
|
@@ -7627,12 +7772,13 @@ class DateTime {
|
|
|
7627
7772
|
|
|
7628
7773
|
/**
|
|
7629
7774
|
* Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
|
|
7630
|
-
* platform supports Intl.RelativeTimeFormat. Rounds
|
|
7775
|
+
* platform supports Intl.RelativeTimeFormat. Rounds towards zero by default.
|
|
7631
7776
|
* @param {Object} options - options that affect the output
|
|
7632
7777
|
* @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
|
|
7633
7778
|
* @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow"
|
|
7634
7779
|
* @param {string|string[]} options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"
|
|
7635
7780
|
* @param {boolean} [options.round=true] - whether to round the numbers in the output.
|
|
7781
|
+
* @param {string} [options.rounding="trunc"] - rounding method to use when rounding the numbers in the output. Can be "trunc" (toward zero), "expand" (away from zero), "round", "floor", or "ceil".
|
|
7636
7782
|
* @param {number} [options.padding=0] - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding.
|
|
7637
7783
|
* @param {string} options.locale - override the locale of this DateTime
|
|
7638
7784
|
* @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
|
|
@@ -10635,4 +10781,4 @@ const Calendar = Object.assign(CalendarElement, {
|
|
|
10635
10781
|
});
|
|
10636
10782
|
|
|
10637
10783
|
export { Calendar as C, DateTime as D, CalendarNow as a, CalendarYearButton as b, CalendarPrev as c, CalendarNext as d, CalendarMonthButton as e, CalendarMonth as f, isValidDate as i, toDateString as t };
|
|
10638
|
-
//# sourceMappingURL=Calendar-
|
|
10784
|
+
//# sourceMappingURL=Calendar-X9qUi6Vx.js.map
|