ivt 0.5.5 → 0.5.7
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/accordion/index.mjs +15 -15
- package/dist/accordion-table/index.mjs +27 -27
- package/dist/accordion-table/index.mjs.map +1 -1
- package/dist/alert/index.mjs +2 -2
- package/dist/alert/index.mjs.map +1 -1
- package/dist/alert-dialog/index.mjs +17 -17
- package/dist/aspect-ratio/index.mjs +1 -1
- package/dist/avatar/index.mjs +7 -7
- package/dist/badge/index.d.ts +1 -1
- package/dist/badge/index.mjs +3 -3
- package/dist/base/index.d.ts +42 -42
- package/dist/base/index.mjs +156 -156
- package/dist/base/index.mjs.map +1 -1
- package/dist/breadcrumb/index.mjs +5 -5
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.mjs +3 -3
- package/dist/button-group/index.d.ts +17 -4
- package/dist/button-group/index.mjs +50 -6
- package/dist/button-group/index.mjs.map +1 -1
- package/dist/calendar/index.mjs +9 -9
- package/dist/card/index.mjs +3 -3
- package/dist/carousel/index.mjs +7 -6
- package/dist/carousel/index.mjs.map +1 -1
- package/dist/chart/index.mjs +8 -8
- package/dist/chart/index.mjs.map +1 -1
- package/dist/checkbox/index.mjs +14 -14
- package/dist/chunks/{CalendarRange-BVXhHs-f.mjs → CalendarRange-B6J1x7Yy.mjs} +8 -8
- package/dist/chunks/CalendarRange-B6J1x7Yy.mjs.map +1 -0
- package/dist/chunks/{ComboboxField-D_0Y0A5H.mjs → ComboboxField-DKuq1AKZ.mjs} +9 -9
- package/dist/chunks/{ComboboxField-D_0Y0A5H.mjs.map → ComboboxField-DKuq1AKZ.mjs.map} +1 -1
- package/dist/chunks/{Container-D6PR2Pu_.mjs → Container-BxlDXTcp.mjs} +2 -2
- package/dist/chunks/{Container-D6PR2Pu_.mjs.map → Container-BxlDXTcp.mjs.map} +1 -1
- package/dist/chunks/{DeleteConfirmationModal-CVSYDAin.mjs → DeleteConfirmationModal-e65HVv-S.mjs} +4 -4
- package/dist/chunks/{DeleteConfirmationModal-CVSYDAin.mjs.map → DeleteConfirmationModal-e65HVv-S.mjs.map} +1 -1
- package/dist/chunks/{TooltipIndicator-BlKtr3wZ.mjs → TooltipIndicator-CN_auquL.mjs} +4 -4
- package/dist/chunks/{TooltipIndicator-BlKtr3wZ.mjs.map → TooltipIndicator-CN_auquL.mjs.map} +1 -1
- package/dist/chunks/{_commonjsHelpers-Re7bJArt.mjs → _commonjsHelpers-Dj8Kr2rQ.mjs} +1 -1
- package/dist/chunks/_commonjsHelpers-Dj8Kr2rQ.mjs.map +1 -0
- package/dist/chunks/{accordion-rwuuJZWp.mjs → accordion-ymmOEBfQ.mjs} +11 -11
- package/dist/chunks/{accordion-rwuuJZWp.mjs.map → accordion-ymmOEBfQ.mjs.map} +1 -1
- package/dist/chunks/{badge-CLlfU-QT.mjs → badge-Bdwyxw3I.mjs} +2 -2
- package/dist/chunks/{badge-CLlfU-QT.mjs.map → badge-Bdwyxw3I.mjs.map} +1 -1
- package/dist/chunks/{bundle-mjs-CWQvHGtg.mjs → bundle-mjs-CwF_jj9z.mjs} +1 -1
- package/dist/chunks/{bundle-mjs-CWQvHGtg.mjs.map → bundle-mjs-CwF_jj9z.mjs.map} +1 -1
- package/dist/chunks/{button-BOgyLhzN.mjs → button-BtNSgexc.mjs} +2 -2
- package/dist/chunks/{button-BOgyLhzN.mjs.map → button-BtNSgexc.mjs.map} +1 -1
- package/dist/chunks/{calendar-DVKfgF9Z.mjs → calendar-BzT7glLL.mjs} +476 -476
- package/dist/chunks/{calendar-DVKfgF9Z.mjs.map → calendar-BzT7glLL.mjs.map} +1 -1
- package/dist/chunks/{calendar-days-BbieAMGy.mjs → calendar-days-Dn7rqkMk.mjs} +2 -2
- package/dist/chunks/{calendar-days-BbieAMGy.mjs.map → calendar-days-Dn7rqkMk.mjs.map} +1 -1
- package/dist/chunks/{card-Dtdqzv51.mjs → card-CV6kQohd.mjs} +2 -2
- package/dist/chunks/{card-Dtdqzv51.mjs.map → card-CV6kQohd.mjs.map} +1 -1
- package/dist/chunks/{check-C2JQIEoK.mjs → check-TyRJdtqa.mjs} +2 -2
- package/dist/chunks/{check-C2JQIEoK.mjs.map → check-TyRJdtqa.mjs.map} +1 -1
- package/dist/chunks/{checkbox-CAeH5mYv.mjs → checkbox-2okt3zhD.mjs} +11 -11
- package/dist/chunks/{checkbox-CAeH5mYv.mjs.map → checkbox-2okt3zhD.mjs.map} +1 -1
- package/dist/chunks/{chevron-down-GNWj-PsJ.mjs → chevron-down-DPe3wUSx.mjs} +2 -2
- package/dist/chunks/{chevron-down-GNWj-PsJ.mjs.map → chevron-down-DPe3wUSx.mjs.map} +1 -1
- package/dist/chunks/{chevron-left-Ciw_Gg5L.mjs → chevron-left-Dr2znK-e.mjs} +2 -2
- package/dist/chunks/{chevron-left-Ciw_Gg5L.mjs.map → chevron-left-Dr2znK-e.mjs.map} +1 -1
- package/dist/chunks/{chevron-right-bGT4BvYz.mjs → chevron-right-DmVvAueL.mjs} +2 -2
- package/dist/chunks/{chevron-right-bGT4BvYz.mjs.map → chevron-right-DmVvAueL.mjs.map} +1 -1
- package/dist/chunks/{chevrons-up-down-BzxB-PsI.mjs → chevrons-up-down-Clez-9zt.mjs} +2 -2
- package/dist/chunks/{chevrons-up-down-BzxB-PsI.mjs.map → chevrons-up-down-Clez-9zt.mjs.map} +1 -1
- package/dist/chunks/{command-DgZmCZLh.mjs → command-EU3dDbf_.mjs} +8 -8
- package/dist/chunks/{command-DgZmCZLh.mjs.map → command-EU3dDbf_.mjs.map} +1 -1
- package/dist/chunks/{createLucideIcon-CHz-fHlL.mjs → createLucideIcon-PuoJamGs.mjs} +1 -1
- package/dist/chunks/{createLucideIcon-CHz-fHlL.mjs.map → createLucideIcon-PuoJamGs.mjs.map} +1 -1
- package/dist/chunks/{date-CQyUFwrr.mjs → date-BWzlXmaG.mjs} +2 -2
- package/dist/chunks/{date-CQyUFwrr.mjs.map → date-BWzlXmaG.mjs.map} +1 -1
- package/dist/chunks/{dialog-eFe5WShu.mjs → dialog-BMq_EiaM.mjs} +4 -4
- package/dist/chunks/{dialog-eFe5WShu.mjs.map → dialog-BMq_EiaM.mjs.map} +1 -1
- package/dist/chunks/{ellipsis-CVES-umj.mjs → ellipsis-D5nNS0KK.mjs} +2 -2
- package/dist/chunks/{ellipsis-CVES-umj.mjs.map → ellipsis-D5nNS0KK.mjs.map} +1 -1
- package/dist/chunks/{form-BDm5CO1Z.mjs → form-CfJLpjew.mjs} +3 -3
- package/dist/chunks/{form-BDm5CO1Z.mjs.map → form-CfJLpjew.mjs.map} +1 -1
- package/dist/chunks/{format-KTl_MBo2.mjs → format-Bkb4ydYM.mjs} +1 -1
- package/dist/chunks/{format-KTl_MBo2.mjs.map → format-Bkb4ydYM.mjs.map} +1 -1
- package/dist/chunks/{format-numbers-Drbc33yW.mjs → format-numbers-DY98wgq_.mjs} +1 -1
- package/dist/chunks/{format-numbers-Drbc33yW.mjs.map → format-numbers-DY98wgq_.mjs.map} +1 -1
- package/dist/chunks/{hover-card-B3lwPW8k.mjs → hover-card-gTAgs7UB.mjs} +11 -11
- package/dist/chunks/{hover-card-B3lwPW8k.mjs.map → hover-card-gTAgs7UB.mjs.map} +1 -1
- package/dist/chunks/{index-BbX-6yhg.mjs → index-B2rYWtDF.mjs} +3 -3
- package/dist/chunks/{index-BbX-6yhg.mjs.map → index-B2rYWtDF.mjs.map} +1 -1
- package/dist/chunks/{index-gnBADg3r.mjs → index-B3qNg03Q.mjs} +9 -9
- package/dist/chunks/{index-gnBADg3r.mjs.map → index-B3qNg03Q.mjs.map} +1 -1
- package/dist/chunks/{index-Dvmx4xV6.mjs → index-BRYOOGYt.mjs} +1 -1
- package/dist/chunks/{index-Dvmx4xV6.mjs.map → index-BRYOOGYt.mjs.map} +1 -1
- package/dist/chunks/{index-CH4hzQx8.mjs → index-B_Y9pqrY.mjs} +1 -1
- package/dist/chunks/{index-CH4hzQx8.mjs.map → index-B_Y9pqrY.mjs.map} +1 -1
- package/dist/chunks/{index-Dmxf1tuE.mjs → index-BdP_9M8C.mjs} +1 -1
- package/dist/chunks/{index-Dmxf1tuE.mjs.map → index-BdP_9M8C.mjs.map} +1 -1
- package/dist/chunks/{index-DEO2kkpO.mjs → index-BmNJQBZT.mjs} +1 -1
- package/dist/chunks/{index-DEO2kkpO.mjs.map → index-BmNJQBZT.mjs.map} +1 -1
- package/dist/chunks/{index-BKTFHAlc.mjs → index-C0_rzV0O.mjs} +1 -1
- package/dist/chunks/{index-BKTFHAlc.mjs.map → index-C0_rzV0O.mjs.map} +1 -1
- package/dist/chunks/{index-CJmlDCYz.mjs → index-C1gfRtpW.mjs} +1 -1
- package/dist/chunks/{index-CJmlDCYz.mjs.map → index-C1gfRtpW.mjs.map} +1 -1
- package/dist/chunks/{index-Bfr3QSR6.mjs → index-C9_8aC95.mjs} +7 -7
- package/dist/chunks/{index-Bfr3QSR6.mjs.map → index-C9_8aC95.mjs.map} +1 -1
- package/dist/chunks/{index-DsKPgtIv.mjs → index-CBE_CuM0.mjs} +5 -5
- package/dist/chunks/{index-DsKPgtIv.mjs.map → index-CBE_CuM0.mjs.map} +1 -1
- package/dist/chunks/{index-BYLxYdaE.mjs → index-CQlPyAtR.mjs} +15 -15
- package/dist/chunks/{index-BYLxYdaE.mjs.map → index-CQlPyAtR.mjs.map} +1 -1
- package/dist/chunks/{index-DbTcqBW_.mjs → index-CWjsfCPV.mjs} +2 -2
- package/dist/chunks/{index-DbTcqBW_.mjs.map → index-CWjsfCPV.mjs.map} +1 -1
- package/dist/chunks/{index-B9X_JCGT.mjs → index-CY7rSsKT.mjs} +2 -2
- package/dist/chunks/{index-B9X_JCGT.mjs.map → index-CY7rSsKT.mjs.map} +1 -1
- package/dist/chunks/{index-CeGdyziS.mjs → index-CZgLnzan.mjs} +1 -1
- package/dist/chunks/{index-CeGdyziS.mjs.map → index-CZgLnzan.mjs.map} +1 -1
- package/dist/chunks/{index-tRp8REyd.mjs → index-CjsV2E2h.mjs} +11 -11
- package/dist/chunks/{index-tRp8REyd.mjs.map → index-CjsV2E2h.mjs.map} +1 -1
- package/dist/chunks/{index-Cu3VwLIM.mjs → index-DH87EZ4W.mjs} +1 -1
- package/dist/chunks/{index-Cu3VwLIM.mjs.map → index-DH87EZ4W.mjs.map} +1 -1
- package/dist/chunks/{index-BQDEr8RX.mjs → index-DPl20FvM.mjs} +2 -2
- package/dist/chunks/{index-BQDEr8RX.mjs.map → index-DPl20FvM.mjs.map} +1 -1
- package/dist/chunks/{Combination-D2wzO_UG.mjs → index-DRuAMnOw.mjs} +168 -168
- package/dist/chunks/index-DRuAMnOw.mjs.map +1 -0
- package/dist/chunks/{index-eKeyN0nu.mjs → index-KLdt0FXh.mjs} +3 -3
- package/dist/chunks/{index-eKeyN0nu.mjs.map → index-KLdt0FXh.mjs.map} +1 -1
- package/dist/chunks/{index-CurKYqyH.mjs → index-O_vhyjqe.mjs} +1 -1
- package/dist/chunks/{index-CurKYqyH.mjs.map → index-O_vhyjqe.mjs.map} +1 -1
- package/dist/chunks/{index-BAW1lHJl.mjs → index-ZFl1NRtT.mjs} +9 -9
- package/dist/chunks/{index-BAW1lHJl.mjs.map → index-ZFl1NRtT.mjs.map} +1 -1
- package/dist/chunks/{index-Rj7dd-Qd.mjs → index-bkyl4p2E.mjs} +1 -1
- package/dist/chunks/{index-Rj7dd-Qd.mjs.map → index-bkyl4p2E.mjs.map} +1 -1
- package/dist/chunks/{index-D1-1o3ca.mjs → index-t0_4qi-T.mjs} +2 -2
- package/dist/chunks/{index-D1-1o3ca.mjs.map → index-t0_4qi-T.mjs.map} +1 -1
- package/dist/chunks/{input-BK_g0H-A.mjs → input-C3fkPeG_.mjs} +2 -2
- package/dist/chunks/{input-BK_g0H-A.mjs.map → input-C3fkPeG_.mjs.map} +1 -1
- package/dist/chunks/{label-Dh5EXQG3.mjs → label-ClO7_a3V.mjs} +3 -3
- package/dist/chunks/{label-Dh5EXQG3.mjs.map → label-ClO7_a3V.mjs.map} +1 -1
- package/dist/chunks/{loader-circle-HdVl9gTK.mjs → loader-circle-BqBrcqkQ.mjs} +2 -2
- package/dist/chunks/{loader-circle-HdVl9gTK.mjs.map → loader-circle-BqBrcqkQ.mjs.map} +1 -1
- package/dist/chunks/{multi-select-zxgO9_FK.mjs → multi-select-DljYuXa4.mjs} +12 -12
- package/dist/chunks/{multi-select-zxgO9_FK.mjs.map → multi-select-DljYuXa4.mjs.map} +1 -1
- package/dist/chunks/{pagination-Cotft18P.mjs → pagination-D7L2vbck.mjs} +6 -6
- package/dist/chunks/{pagination-Cotft18P.mjs.map → pagination-D7L2vbck.mjs.map} +1 -1
- package/dist/chunks/{popover-BGTLw9yg.mjs → popover-C1aNGeey.mjs} +13 -13
- package/dist/chunks/{popover-BGTLw9yg.mjs.map → popover-C1aNGeey.mjs.map} +1 -1
- package/dist/chunks/{progress-DBlI7uQi.mjs → progress-D0vzug-J.mjs} +4 -4
- package/dist/chunks/{progress-DBlI7uQi.mjs.map → progress-D0vzug-J.mjs.map} +1 -1
- package/dist/chunks/{react-number-format.es-CMk_daKs.mjs → react-number-format.es-BebBtQNl.mjs} +1 -1
- package/dist/chunks/{react-number-format.es-CMk_daKs.mjs.map → react-number-format.es-BebBtQNl.mjs.map} +1 -1
- package/dist/chunks/{scroll-area-WahR-NAJ.mjs → scroll-area-DnOrBNhw.mjs} +11 -11
- package/dist/chunks/{scroll-area-WahR-NAJ.mjs.map → scroll-area-DnOrBNhw.mjs.map} +1 -1
- package/dist/chunks/{select-B9KImN17.mjs → select-DZFrWKa9.mjs} +5 -5
- package/dist/chunks/{select-B9KImN17.mjs.map → select-DZFrWKa9.mjs.map} +1 -1
- package/dist/chunks/{separator-Nw9XSF7S.mjs → separator-Cy1u4QGj.mjs} +3 -3
- package/dist/chunks/{separator-Nw9XSF7S.mjs.map → separator-Cy1u4QGj.mjs.map} +1 -1
- package/dist/chunks/{sheet-BUhlccXr.mjs → sheet-UhlywLCQ.mjs} +4 -4
- package/dist/chunks/{sheet-BUhlccXr.mjs.map → sheet-UhlywLCQ.mjs.map} +1 -1
- package/dist/chunks/{skeleton-DJUPQDI3.mjs → skeleton-CAkZfLJU.mjs} +2 -2
- package/dist/chunks/skeleton-CAkZfLJU.mjs.map +1 -0
- package/dist/chunks/{sortable-BbcW1b3f.mjs → sortable-CqaoTR3I.mjs} +14 -8
- package/dist/chunks/{sortable-BbcW1b3f.mjs.map → sortable-CqaoTR3I.mjs.map} +1 -1
- package/dist/chunks/{table-CPHEPhht.mjs → table-DtYzDvg1.mjs} +3 -3
- package/dist/chunks/{table-CPHEPhht.mjs.map → table-DtYzDvg1.mjs.map} +1 -1
- package/dist/chunks/{textarea-IsazgcBS.mjs → textarea-DnLcBKio.mjs} +2 -2
- package/dist/chunks/{textarea-IsazgcBS.mjs.map → textarea-DnLcBKio.mjs.map} +1 -1
- package/dist/chunks/{toggle-DIVWhWr_.mjs → toggle-DCO007-l.mjs} +5 -5
- package/dist/chunks/{toggle-DIVWhWr_.mjs.map → toggle-DCO007-l.mjs.map} +1 -1
- package/dist/chunks/{tooltip-BlwaLQuC.mjs → tooltip-Dyp4dubr.mjs} +13 -13
- package/dist/chunks/{tooltip-BlwaLQuC.mjs.map → tooltip-Dyp4dubr.mjs.map} +1 -1
- package/dist/chunks/{trash-2-CWR4QHjL.mjs → trash-2-ImUsqVCq.mjs} +2 -2
- package/dist/chunks/{trash-2-CWR4QHjL.mjs.map → trash-2-ImUsqVCq.mjs.map} +1 -1
- package/dist/chunks/{triangle-alert-CQ6V4_pV.mjs → triangle-alert-gCMT5OAG.mjs} +2 -2
- package/dist/chunks/{triangle-alert-CQ6V4_pV.mjs.map → triangle-alert-gCMT5OAG.mjs.map} +1 -1
- package/dist/chunks/{tslib.es6-BqS_Tuh7.mjs → tslib.es6-SGuOiL7t.mjs} +1 -1
- package/dist/chunks/{tslib.es6-BqS_Tuh7.mjs.map → tslib.es6-SGuOiL7t.mjs.map} +1 -1
- package/dist/chunks/{utils-DbWlhojh.mjs → utils-Cbs-uxBq.mjs} +2 -2
- package/dist/chunks/{utils-DbWlhojh.mjs.map → utils-Cbs-uxBq.mjs.map} +1 -1
- package/dist/chunks/{x-BvNSIFOu.mjs → x-dyn358tn.mjs} +2 -2
- package/dist/chunks/{x-BvNSIFOu.mjs.map → x-dyn358tn.mjs.map} +1 -1
- package/dist/collapsible/index.mjs +9 -9
- package/dist/combobox/index.mjs +26 -26
- package/dist/command/index.mjs +20 -20
- package/dist/context-menu/index.mjs +23 -23
- package/dist/dash/index.d.ts +6 -6
- package/dist/dash/index.mjs +34 -34
- package/dist/dash/index.mjs.map +1 -1
- package/dist/data-table/index.d.ts +50 -40
- package/dist/data-table/index.mjs +328 -214
- package/dist/data-table/index.mjs.map +1 -1
- package/dist/date-picker/index.d.ts +1 -1
- package/dist/date-picker/index.mjs +27 -27
- package/dist/date-picker/index.mjs.map +1 -1
- package/dist/dialog/index.mjs +19 -19
- package/dist/drawer/index.mjs +16 -16
- package/dist/dropdown-menu/index.mjs +23 -23
- package/dist/dropdown-menu/index.mjs.map +1 -1
- package/dist/dropzone/index.mjs +193 -193
- package/dist/dropzone/index.mjs.map +1 -1
- package/dist/editable-table/index.mjs +12 -10
- package/dist/editable-table/index.mjs.map +1 -1
- package/dist/empty/index.mjs +2 -2
- package/dist/empty/index.mjs.map +1 -1
- package/dist/field/index.mjs +8 -7
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/index.mjs +5 -5
- package/dist/form-fields/index.mjs +28 -28
- package/dist/hover-card/index.mjs +15 -15
- package/dist/icon/index.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/input/index.mjs +3 -3
- package/dist/input-group/index.mjs +12 -9
- package/dist/input-group/index.mjs.map +1 -1
- package/dist/input-otp/index.mjs +3 -3
- package/dist/item/index.mjs +7 -6
- package/dist/item/index.mjs.map +1 -1
- package/dist/ivt.css +1 -1
- package/dist/kbd/index.mjs +2 -2
- package/dist/kbd/index.mjs.map +1 -1
- package/dist/label/index.mjs +4 -4
- package/dist/layout/index.mjs +6 -6
- package/dist/layout/index.mjs.map +1 -1
- package/dist/menubar/index.mjs +23 -23
- package/dist/multi-select/index.mjs +31 -31
- package/dist/navigation-menu/index.mjs +17 -17
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.mjs +8 -8
- package/dist/popover/index.mjs +18 -18
- package/dist/progress/index.mjs +5 -5
- package/dist/radio-group/index.mjs +17 -17
- package/dist/resizable/index.mjs +3 -3
- package/dist/scroll-area/index.mjs +12 -12
- package/dist/select/index.mjs +6 -6
- package/dist/separator/index.mjs +4 -4
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.mjs +6 -6
- package/dist/shared/index.mjs.map +1 -1
- package/dist/sheet/index.mjs +19 -19
- package/dist/sidebar/index.mjs +28 -28
- package/dist/sidebar/index.mjs.map +1 -1
- package/dist/skeleton/index.mjs +3 -3
- package/dist/skeleton-component/index.mjs +4 -4
- package/dist/skeleton-component/index.mjs.map +1 -1
- package/dist/slider/index.mjs +12 -12
- package/dist/sortable/index.d.ts +7 -1
- package/dist/sortable/index.mjs +4 -4
- package/dist/spinner/index.mjs +4 -4
- package/dist/switch/index.mjs +10 -10
- package/dist/table/index.mjs +3 -3
- package/dist/table-filter/index.d.ts +1 -1
- package/dist/table-filter/index.mjs +52 -52
- package/dist/table-filter/index.mjs.map +1 -1
- package/dist/tabs/index.mjs +13 -13
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.mjs +3 -3
- package/dist/toast/index.mjs +15 -15
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toggle/index.mjs +7 -7
- package/dist/toggle-group/index.mjs +13 -13
- package/dist/tooltip/index.mjs +17 -17
- package/package.json +462 -462
- package/dist/chunks/CalendarRange-BVXhHs-f.mjs.map +0 -1
- package/dist/chunks/Combination-D2wzO_UG.mjs.map +0 -1
- package/dist/chunks/_commonjsHelpers-Re7bJArt.mjs.map +0 -1
- package/dist/chunks/skeleton-DJUPQDI3.mjs.map +0 -1
|
@@ -1,523 +1,183 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { createContext, useContext, useCallback, useRef, useLayoutEffect, useState, useEffect, useMemo } from 'react';
|
|
3
|
-
import { c as cn } from './utils-
|
|
4
|
-
import { t as toDate, c as constructFrom, j as addDays, y as normalizeDates, z as startOfDay, g as getDefaultOptions, A as differenceInCalendarDays, f as format, i as getISOWeek, h as getWeek, B as isDate, e as startOfISOWeek, s as startOfWeek, C as startOfYear, l as enUS } from './format-
|
|
5
|
-
import { C as ChevronLeft } from './chevron-left-
|
|
6
|
-
import { C as ChevronRight } from './chevron-right-
|
|
7
|
-
import { C as ChevronDown } from './chevron-down-
|
|
8
|
-
import { b as buttonVariants, B as Button$1 } from './button-
|
|
3
|
+
import { c as cn } from './utils-Cbs-uxBq.mjs';
|
|
4
|
+
import { t as toDate, c as constructFrom, j as addDays, y as normalizeDates, z as startOfDay, g as getDefaultOptions, A as differenceInCalendarDays, f as format, i as getISOWeek, h as getWeek, B as isDate, e as startOfISOWeek, s as startOfWeek, C as startOfYear, l as enUS } from './format-Bkb4ydYM.mjs';
|
|
5
|
+
import { C as ChevronLeft } from './chevron-left-Dr2znK-e.mjs';
|
|
6
|
+
import { C as ChevronRight } from './chevron-right-DmVvAueL.mjs';
|
|
7
|
+
import { C as ChevronDown } from './chevron-down-DPe3wUSx.mjs';
|
|
8
|
+
import { b as buttonVariants, B as Button$1 } from './button-BtNSgexc.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The {@link addMonths} function options.
|
|
12
12
|
*/ /**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* @name addMonths
|
|
14
|
+
* @category Month Helpers
|
|
15
|
+
* @summary Add the specified number of months to the given date.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* "Singapore Standard Time".
|
|
17
|
+
* @description
|
|
18
|
+
* Add the specified number of months to the given date.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
21
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
21
22
|
*
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
*
|
|
25
|
-
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
|
23
|
+
* @param date - The date to be changed
|
|
24
|
+
* @param amount - The amount of months to be added.
|
|
25
|
+
* @param options - The options object
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* @returns The new date with the months added
|
|
28
28
|
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Add 5 months to 1 September 2014:
|
|
31
|
+
* const result = addMonths(new Date(2014, 8, 1), 5)
|
|
32
|
+
* //=> Sun Feb 01 2015 00:00:00
|
|
32
33
|
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
* // Add one month to 30 January 2023:
|
|
35
|
+
* const result = addMonths(new Date(2023, 0, 30), 1)
|
|
36
|
+
* //=> Tue Feb 28 2023 00:00:00
|
|
37
|
+
*/ function addMonths(date, amount, options) {
|
|
38
|
+
const _date = toDate(date, options?.in);
|
|
39
|
+
if (isNaN(amount)) return constructFrom(date, NaN);
|
|
40
|
+
if (!amount) {
|
|
41
|
+
// If 0 months, no-op to avoid changing times in the hour before end of DST
|
|
42
|
+
return _date;
|
|
43
|
+
}
|
|
44
|
+
const dayOfMonth = _date.getDate();
|
|
45
|
+
// The JS Date object supports date math by accepting out-of-bounds values for
|
|
46
|
+
// month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
|
|
47
|
+
// new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
|
|
48
|
+
// want except that dates will wrap around the end of a month, meaning that
|
|
49
|
+
// new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
|
|
50
|
+
// we'll default to the end of the desired month by adding 1 to the desired
|
|
51
|
+
// month and using a date of 0 to back up one day to the end of the desired
|
|
52
|
+
// month.
|
|
53
|
+
const endOfDesiredMonth = constructFrom(date, _date.getTime());
|
|
54
|
+
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
55
|
+
const daysInMonth = endOfDesiredMonth.getDate();
|
|
56
|
+
if (dayOfMonth >= daysInMonth) {
|
|
57
|
+
// If we're already at the end of the month, then this is the correct date
|
|
58
|
+
// and we're done.
|
|
59
|
+
return endOfDesiredMonth;
|
|
60
|
+
} else {
|
|
61
|
+
// Otherwise, we now know that setting the original day-of-month value won't
|
|
62
|
+
// cause an overflow, so set the desired day-of-month. Note that we can't
|
|
63
|
+
// just set the date of `endOfDesiredMonth` because that object may have had
|
|
64
|
+
// its time changed in the unusual case where where a DST transition was on
|
|
65
|
+
// the last day of the month and its local time was in the hour skipped or
|
|
66
|
+
// repeated next to a DST transition. So we use `date` instead which is
|
|
67
|
+
// guaranteed to still have the original time.
|
|
68
|
+
_date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
|
|
69
|
+
return _date;
|
|
70
|
+
}
|
|
43
71
|
}
|
|
44
72
|
|
|
45
|
-
const offsetFormatCache = {};
|
|
46
|
-
const offsetCache = {};
|
|
47
73
|
/**
|
|
48
|
-
* The
|
|
49
|
-
|
|
74
|
+
* The {@link addWeeks} function options.
|
|
75
|
+
*/ /**
|
|
76
|
+
* @name addWeeks
|
|
77
|
+
* @category Week Helpers
|
|
78
|
+
* @summary Add the specified number of weeks to the given date.
|
|
50
79
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
|
80
|
+
* @description
|
|
81
|
+
* Add the specified number of weeks to the given date.
|
|
54
82
|
*
|
|
55
|
-
* @
|
|
56
|
-
* @
|
|
83
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
84
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
57
85
|
*
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
|
71
|
-
// See: https://github.com/nodejs/node/issues/53419
|
|
72
|
-
if (timeZone in offsetCache) return offsetCache[timeZone];
|
|
73
|
-
const captures = timeZone?.match(offsetRe);
|
|
74
|
-
if (captures) return calcOffset(timeZone, captures.slice(1));
|
|
75
|
-
return NaN;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
|
79
|
-
function calcOffset(cacheStr, values) {
|
|
80
|
-
const hours = +(values[0] || 0);
|
|
81
|
-
const minutes = +(values[1] || 0);
|
|
82
|
-
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
|
83
|
-
const seconds = +(values[2] || 0) / 60;
|
|
84
|
-
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
|
86
|
+
* @param date - The date to be changed
|
|
87
|
+
* @param amount - The amount of weeks to be added.
|
|
88
|
+
* @param options - An object with options
|
|
89
|
+
*
|
|
90
|
+
* @returns The new date with the weeks added
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Add 4 weeks to 1 September 2014:
|
|
94
|
+
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
95
|
+
* //=> Mon Sep 29 2014 00:00:00
|
|
96
|
+
*/ function addWeeks(date, amount, options) {
|
|
97
|
+
return addDays(date, amount * 7, options);
|
|
85
98
|
}
|
|
86
99
|
|
|
87
|
-
class TZDateMini extends Date {
|
|
88
|
-
static tz(tz, ...args) {
|
|
89
|
-
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region time zone
|
|
93
|
-
withTimeZone(timeZone) {
|
|
94
|
-
return new TZDateMini(+this, timeZone);
|
|
95
|
-
}
|
|
96
|
-
getTimezoneOffset() {
|
|
97
|
-
const offset = -tzOffset(this.timeZone, this);
|
|
98
|
-
// Remove the seconds offset
|
|
99
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
100
|
-
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region time
|
|
104
|
-
setTime(time) {
|
|
105
|
-
Date.prototype.setTime.apply(this, arguments);
|
|
106
|
-
syncToInternal(this);
|
|
107
|
-
return +this;
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region date-fns integration
|
|
111
|
-
[Symbol.for("constructDateFrom")](date) {
|
|
112
|
-
return new TZDateMini(+new Date(date), this.timeZone);
|
|
113
|
-
}
|
|
114
|
-
//#region static
|
|
115
|
-
constructor(...args){
|
|
116
|
-
super();
|
|
117
|
-
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
|
118
|
-
this.timeZone = args.pop();
|
|
119
|
-
}
|
|
120
|
-
this.internal = new Date();
|
|
121
|
-
if (isNaN(tzOffset(this.timeZone, this))) {
|
|
122
|
-
this.setTime(NaN);
|
|
123
|
-
} else {
|
|
124
|
-
if (!args.length) {
|
|
125
|
-
this.setTime(Date.now());
|
|
126
|
-
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
|
127
|
-
this.setTime(args[0]);
|
|
128
|
-
} else if (typeof args[0] === "string") {
|
|
129
|
-
this.setTime(+new Date(args[0]));
|
|
130
|
-
} else if (args[0] instanceof Date) {
|
|
131
|
-
this.setTime(+args[0]);
|
|
132
|
-
} else {
|
|
133
|
-
this.setTime(+new Date(...args));
|
|
134
|
-
adjustToSystemTZ(this);
|
|
135
|
-
syncToInternal(this);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Assign getters and setters
|
|
141
|
-
const re = /^(get|set)(?!UTC)/;
|
|
142
|
-
Object.getOwnPropertyNames(Date.prototype).forEach((method)=>{
|
|
143
|
-
if (!re.test(method)) return;
|
|
144
|
-
const utcMethod = method.replace(re, "$1UTC");
|
|
145
|
-
// Filter out methods without UTC counterparts
|
|
146
|
-
if (!TZDateMini.prototype[utcMethod]) return;
|
|
147
|
-
if (method.startsWith("get")) {
|
|
148
|
-
// Delegate to internal date's UTC method
|
|
149
|
-
TZDateMini.prototype[method] = function() {
|
|
150
|
-
return this.internal[utcMethod]();
|
|
151
|
-
};
|
|
152
|
-
} else {
|
|
153
|
-
// Assign regular setter
|
|
154
|
-
TZDateMini.prototype[method] = function() {
|
|
155
|
-
Date.prototype[utcMethod].apply(this.internal, arguments);
|
|
156
|
-
syncFromInternal(this);
|
|
157
|
-
return +this;
|
|
158
|
-
};
|
|
159
|
-
// Assign UTC setter
|
|
160
|
-
TZDateMini.prototype[utcMethod] = function() {
|
|
161
|
-
Date.prototype[utcMethod].apply(this, arguments);
|
|
162
|
-
syncToInternal(this);
|
|
163
|
-
return +this;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
100
|
/**
|
|
168
|
-
*
|
|
101
|
+
* The {@link addYears} function options.
|
|
102
|
+
*/ /**
|
|
103
|
+
* @name addYears
|
|
104
|
+
* @category Year Helpers
|
|
105
|
+
* @summary Add the specified number of years to the given date.
|
|
169
106
|
*
|
|
170
|
-
* @
|
|
171
|
-
|
|
172
|
-
date.internal.setTime(+date);
|
|
173
|
-
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Function syncs the internal date UTC values to the date. It allows to get
|
|
177
|
-
* accurate timestamp value.
|
|
107
|
+
* @description
|
|
108
|
+
* Add the specified number of years to the given date.
|
|
178
109
|
*
|
|
179
|
-
* @
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
110
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
111
|
+
* @typeParam ResultDate - The result `Date` type.
|
|
112
|
+
*
|
|
113
|
+
* @param date - The date to be changed
|
|
114
|
+
* @param amount - The amount of years to be added.
|
|
115
|
+
* @param options - The options
|
|
116
|
+
*
|
|
117
|
+
* @returns The new date with the years added
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* // Add 5 years to 1 September 2014:
|
|
121
|
+
* const result = addYears(new Date(2014, 8, 1), 5)
|
|
122
|
+
* //=> Sun Sep 01 2019 00:00:00
|
|
123
|
+
*/ function addYears(date, amount, options) {
|
|
124
|
+
return addMonths(date, amount * 12, options);
|
|
186
125
|
}
|
|
126
|
+
|
|
187
127
|
/**
|
|
188
|
-
*
|
|
189
|
-
* differences to calculate the offset and adjust the date.
|
|
190
|
-
*
|
|
191
|
-
* @param {Date} date - Date to adjust
|
|
192
|
-
*/ function adjustToSystemTZ(date) {
|
|
193
|
-
// Save the time zone offset before all the adjustments
|
|
194
|
-
const baseOffset = tzOffset(date.timeZone, date);
|
|
195
|
-
// Remove the seconds offset
|
|
196
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
197
|
-
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
|
198
|
-
//#region System DST adjustment
|
|
199
|
-
// The biggest problem with using the system time zone is that when we create
|
|
200
|
-
// a date from internal values stored in UTC, the system time zone might end
|
|
201
|
-
// up on the DST hour:
|
|
202
|
-
//
|
|
203
|
-
// $ TZ=America/New_York node
|
|
204
|
-
// > new Date(2020, 2, 8, 1).toString()
|
|
205
|
-
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
|
206
|
-
// > new Date(2020, 2, 8, 2).toString()
|
|
207
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
208
|
-
// > new Date(2020, 2, 8, 3).toString()
|
|
209
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
210
|
-
// > new Date(2020, 2, 8, 4).toString()
|
|
211
|
-
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
212
|
-
//
|
|
213
|
-
// Here we get the same hour for both 2 and 3, because the system time zone
|
|
214
|
-
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
|
215
|
-
// to adjust the internal date to reflect that.
|
|
216
|
-
//
|
|
217
|
-
// However we want to adjust only if that's the DST hour the change happenes,
|
|
218
|
-
// not the hour where DST moves to.
|
|
219
|
-
// We calculate the previous hour to see if the time zone offset has changed
|
|
220
|
-
// and we have landed on the DST hour.
|
|
221
|
-
const prevHour = new Date(+date);
|
|
222
|
-
// We use UTC methods here as we don't want to land on the same hour again
|
|
223
|
-
// in case of DST.
|
|
224
|
-
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
|
225
|
-
// Calculate if we are on the system DST hour.
|
|
226
|
-
const systemOffset = -new Date(+date).getTimezoneOffset();
|
|
227
|
-
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
|
228
|
-
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
|
229
|
-
// Detect the DST shift. System DST change will occur both on
|
|
230
|
-
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
|
231
|
-
// Move the internal date when we are on the system DST hour.
|
|
232
|
-
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region System diff adjustment
|
|
235
|
-
// Now we need to adjust the date, since we just applied internal values.
|
|
236
|
-
// We need to calculate the difference between the system and date time zones
|
|
237
|
-
// and apply it to the date.
|
|
238
|
-
const offsetDiff = systemOffset - offset;
|
|
239
|
-
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region Seconds System diff adjustment
|
|
242
|
-
const systemDate = new Date(+date);
|
|
243
|
-
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
|
244
|
-
systemDate.setUTCSeconds(0);
|
|
245
|
-
// For negative systemOffset, invert the seconds.
|
|
246
|
-
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
|
247
|
-
// Calculate the seconds offset based on the timezone offset.
|
|
248
|
-
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
|
249
|
-
if (secondsOffset || systemSecondsOffset) {
|
|
250
|
-
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
|
251
|
-
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region Post-adjustment DST fix
|
|
255
|
-
const postBaseOffset = tzOffset(date.timeZone, date);
|
|
256
|
-
// Remove the seconds offset
|
|
257
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
258
|
-
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
|
259
|
-
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
|
260
|
-
const postOffsetDiff = postSystemOffset - postOffset;
|
|
261
|
-
const offsetChanged = postOffset !== offset;
|
|
262
|
-
const postDiff = postOffsetDiff - offsetDiff;
|
|
263
|
-
if (offsetChanged && postDiff) {
|
|
264
|
-
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
|
265
|
-
// Now we need to check if got offset change during the post-adjustment.
|
|
266
|
-
// If so, we also need both dates to reflect that.
|
|
267
|
-
const newBaseOffset = tzOffset(date.timeZone, date);
|
|
268
|
-
// Remove the seconds offset
|
|
269
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
270
|
-
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
|
271
|
-
const offsetChange = postOffset - newOffset;
|
|
272
|
-
if (offsetChange) {
|
|
273
|
-
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
|
274
|
-
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
//#endregion
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
class TZDate extends TZDateMini {
|
|
281
|
-
//#region static
|
|
282
|
-
static tz(tz, ...args) {
|
|
283
|
-
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
|
284
|
-
}
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region representation
|
|
287
|
-
toISOString() {
|
|
288
|
-
const [sign, hours, minutes] = this.tzComponents();
|
|
289
|
-
const tz = `${sign}${hours}:${minutes}`;
|
|
290
|
-
return this.internal.toISOString().slice(0, -1) + tz;
|
|
291
|
-
}
|
|
292
|
-
toString() {
|
|
293
|
-
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
|
294
|
-
return `${this.toDateString()} ${this.toTimeString()}`;
|
|
295
|
-
}
|
|
296
|
-
toDateString() {
|
|
297
|
-
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
298
|
-
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
|
299
|
-
// "Tue Aug 13 2024"
|
|
300
|
-
return `${day?.slice(0, -1)} ${month} ${date} ${year}`;
|
|
301
|
-
}
|
|
302
|
-
toTimeString() {
|
|
303
|
-
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
304
|
-
const time = this.internal.toUTCString().split(" ")[4];
|
|
305
|
-
const [sign, hours, minutes] = this.tzComponents();
|
|
306
|
-
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
|
307
|
-
return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
|
|
308
|
-
}
|
|
309
|
-
toLocaleString(locales, options) {
|
|
310
|
-
return Date.prototype.toLocaleString.call(this, locales, {
|
|
311
|
-
...options,
|
|
312
|
-
timeZone: options?.timeZone || this.timeZone
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
toLocaleDateString(locales, options) {
|
|
316
|
-
return Date.prototype.toLocaleDateString.call(this, locales, {
|
|
317
|
-
...options,
|
|
318
|
-
timeZone: options?.timeZone || this.timeZone
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
toLocaleTimeString(locales, options) {
|
|
322
|
-
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
|
323
|
-
...options,
|
|
324
|
-
timeZone: options?.timeZone || this.timeZone
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region private
|
|
329
|
-
tzComponents() {
|
|
330
|
-
const offset = this.getTimezoneOffset();
|
|
331
|
-
const sign = offset > 0 ? "-" : "+";
|
|
332
|
-
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
|
333
|
-
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
|
334
|
-
return [
|
|
335
|
-
sign,
|
|
336
|
-
hours,
|
|
337
|
-
minutes
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
//#endregion
|
|
341
|
-
withTimeZone(timeZone) {
|
|
342
|
-
return new TZDate(+this, timeZone);
|
|
343
|
-
}
|
|
344
|
-
//#region date-fns integration
|
|
345
|
-
[Symbol.for("constructDateFrom")](date) {
|
|
346
|
-
return new TZDate(+new Date(date), this.timeZone);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* The {@link addMonths} function options.
|
|
128
|
+
* The {@link max} function options.
|
|
352
129
|
*/ /**
|
|
353
|
-
* @name
|
|
354
|
-
* @category
|
|
355
|
-
* @summary
|
|
130
|
+
* @name max
|
|
131
|
+
* @category Common Helpers
|
|
132
|
+
* @summary Return the latest of the given dates.
|
|
356
133
|
*
|
|
357
134
|
* @description
|
|
358
|
-
*
|
|
135
|
+
* Return the latest of the given dates.
|
|
359
136
|
*
|
|
360
137
|
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
361
138
|
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
362
139
|
*
|
|
363
|
-
* @param
|
|
364
|
-
* @param amount - The amount of months to be added.
|
|
365
|
-
* @param options - The options object
|
|
140
|
+
* @param dates - The dates to compare
|
|
366
141
|
*
|
|
367
|
-
* @returns The
|
|
142
|
+
* @returns The latest of the dates
|
|
368
143
|
*
|
|
369
144
|
* @example
|
|
370
|
-
* //
|
|
371
|
-
* const result =
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
// want except that dates will wrap around the end of a month, meaning that
|
|
389
|
-
// new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
|
|
390
|
-
// we'll default to the end of the desired month by adding 1 to the desired
|
|
391
|
-
// month and using a date of 0 to back up one day to the end of the desired
|
|
392
|
-
// month.
|
|
393
|
-
const endOfDesiredMonth = constructFrom(date, _date.getTime());
|
|
394
|
-
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
395
|
-
const daysInMonth = endOfDesiredMonth.getDate();
|
|
396
|
-
if (dayOfMonth >= daysInMonth) {
|
|
397
|
-
// If we're already at the end of the month, then this is the correct date
|
|
398
|
-
// and we're done.
|
|
399
|
-
return endOfDesiredMonth;
|
|
400
|
-
} else {
|
|
401
|
-
// Otherwise, we now know that setting the original day-of-month value won't
|
|
402
|
-
// cause an overflow, so set the desired day-of-month. Note that we can't
|
|
403
|
-
// just set the date of `endOfDesiredMonth` because that object may have had
|
|
404
|
-
// its time changed in the unusual case where where a DST transition was on
|
|
405
|
-
// the last day of the month and its local time was in the hour skipped or
|
|
406
|
-
// repeated next to a DST transition. So we use `date` instead which is
|
|
407
|
-
// guaranteed to still have the original time.
|
|
408
|
-
_date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
|
|
409
|
-
return _date;
|
|
410
|
-
}
|
|
145
|
+
* // Which of these dates is the latest?
|
|
146
|
+
* const result = max([
|
|
147
|
+
* new Date(1989, 6, 10),
|
|
148
|
+
* new Date(1987, 1, 11),
|
|
149
|
+
* new Date(1995, 6, 2),
|
|
150
|
+
* new Date(1990, 0, 1)
|
|
151
|
+
* ])
|
|
152
|
+
* //=> Sun Jul 02 1995 00:00:00
|
|
153
|
+
*/ function max(dates, options) {
|
|
154
|
+
let result;
|
|
155
|
+
let context = options?.in;
|
|
156
|
+
dates.forEach((date)=>{
|
|
157
|
+
// Use the first date object as the context function
|
|
158
|
+
if (!context && typeof date === "object") context = constructFrom.bind(null, date);
|
|
159
|
+
const date_ = toDate(date, context);
|
|
160
|
+
if (!result || result < date_ || isNaN(+date_)) result = date_;
|
|
161
|
+
});
|
|
162
|
+
return constructFrom(context, result || NaN);
|
|
411
163
|
}
|
|
412
164
|
|
|
413
165
|
/**
|
|
414
|
-
* The {@link
|
|
166
|
+
* The {@link min} function options.
|
|
415
167
|
*/ /**
|
|
416
|
-
* @name
|
|
417
|
-
* @category
|
|
418
|
-
* @summary
|
|
168
|
+
* @name min
|
|
169
|
+
* @category Common Helpers
|
|
170
|
+
* @summary Returns the earliest of the given dates.
|
|
419
171
|
*
|
|
420
172
|
* @description
|
|
421
|
-
*
|
|
173
|
+
* Returns the earliest of the given dates.
|
|
422
174
|
*
|
|
423
175
|
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
424
176
|
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
425
177
|
*
|
|
426
|
-
* @param
|
|
427
|
-
* @param amount - The amount of weeks to be added.
|
|
428
|
-
* @param options - An object with options
|
|
178
|
+
* @param dates - The dates to compare
|
|
429
179
|
*
|
|
430
|
-
* @returns The
|
|
431
|
-
*
|
|
432
|
-
* @example
|
|
433
|
-
* // Add 4 weeks to 1 September 2014:
|
|
434
|
-
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
435
|
-
* //=> Mon Sep 29 2014 00:00:00
|
|
436
|
-
*/ function addWeeks(date, amount, options) {
|
|
437
|
-
return addDays(date, amount * 7, options);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* The {@link addYears} function options.
|
|
442
|
-
*/ /**
|
|
443
|
-
* @name addYears
|
|
444
|
-
* @category Year Helpers
|
|
445
|
-
* @summary Add the specified number of years to the given date.
|
|
446
|
-
*
|
|
447
|
-
* @description
|
|
448
|
-
* Add the specified number of years to the given date.
|
|
449
|
-
*
|
|
450
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
451
|
-
* @typeParam ResultDate - The result `Date` type.
|
|
452
|
-
*
|
|
453
|
-
* @param date - The date to be changed
|
|
454
|
-
* @param amount - The amount of years to be added.
|
|
455
|
-
* @param options - The options
|
|
456
|
-
*
|
|
457
|
-
* @returns The new date with the years added
|
|
458
|
-
*
|
|
459
|
-
* @example
|
|
460
|
-
* // Add 5 years to 1 September 2014:
|
|
461
|
-
* const result = addYears(new Date(2014, 8, 1), 5)
|
|
462
|
-
* //=> Sun Sep 01 2019 00:00:00
|
|
463
|
-
*/ function addYears(date, amount, options) {
|
|
464
|
-
return addMonths(date, amount * 12, options);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* The {@link max} function options.
|
|
469
|
-
*/ /**
|
|
470
|
-
* @name max
|
|
471
|
-
* @category Common Helpers
|
|
472
|
-
* @summary Return the latest of the given dates.
|
|
473
|
-
*
|
|
474
|
-
* @description
|
|
475
|
-
* Return the latest of the given dates.
|
|
476
|
-
*
|
|
477
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
478
|
-
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
479
|
-
*
|
|
480
|
-
* @param dates - The dates to compare
|
|
481
|
-
*
|
|
482
|
-
* @returns The latest of the dates
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* // Which of these dates is the latest?
|
|
486
|
-
* const result = max([
|
|
487
|
-
* new Date(1989, 6, 10),
|
|
488
|
-
* new Date(1987, 1, 11),
|
|
489
|
-
* new Date(1995, 6, 2),
|
|
490
|
-
* new Date(1990, 0, 1)
|
|
491
|
-
* ])
|
|
492
|
-
* //=> Sun Jul 02 1995 00:00:00
|
|
493
|
-
*/ function max(dates, options) {
|
|
494
|
-
let result;
|
|
495
|
-
let context = options?.in;
|
|
496
|
-
dates.forEach((date)=>{
|
|
497
|
-
// Use the first date object as the context function
|
|
498
|
-
if (!context && typeof date === "object") context = constructFrom.bind(null, date);
|
|
499
|
-
const date_ = toDate(date, context);
|
|
500
|
-
if (!result || result < date_ || isNaN(+date_)) result = date_;
|
|
501
|
-
});
|
|
502
|
-
return constructFrom(context, result || NaN);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* The {@link min} function options.
|
|
507
|
-
*/ /**
|
|
508
|
-
* @name min
|
|
509
|
-
* @category Common Helpers
|
|
510
|
-
* @summary Returns the earliest of the given dates.
|
|
511
|
-
*
|
|
512
|
-
* @description
|
|
513
|
-
* Returns the earliest of the given dates.
|
|
514
|
-
*
|
|
515
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
516
|
-
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
517
|
-
*
|
|
518
|
-
* @param dates - The dates to compare
|
|
519
|
-
*
|
|
520
|
-
* @returns The earliest of the dates
|
|
180
|
+
* @returns The earliest of the dates
|
|
521
181
|
*
|
|
522
182
|
* @example
|
|
523
183
|
* // Which of these dates is the earliest?
|
|
@@ -1118,6 +778,346 @@ function normalizeInterval(context, interval) {
|
|
|
1118
778
|
return date_;
|
|
1119
779
|
}
|
|
1120
780
|
|
|
781
|
+
/**
|
|
782
|
+
* Time zone name format.
|
|
783
|
+
*/ /**
|
|
784
|
+
* The function returns the time zone name for the given date in the specified
|
|
785
|
+
* time zone.
|
|
786
|
+
*
|
|
787
|
+
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
|
788
|
+
* name in a long format, e.g. "Pacific Standard Time" or
|
|
789
|
+
* "Singapore Standard Time".
|
|
790
|
+
*
|
|
791
|
+
* It is possible to specify the format as the third argument using one of the following options
|
|
792
|
+
*
|
|
793
|
+
* - "short": e.g. "EDT" or "GMT+8".
|
|
794
|
+
* - "long": e.g. "Eastern Daylight Time".
|
|
795
|
+
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
|
796
|
+
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
|
797
|
+
*
|
|
798
|
+
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
|
799
|
+
*
|
|
800
|
+
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
801
|
+
* @param date - Date object to get the time zone name for
|
|
802
|
+
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
|
803
|
+
*
|
|
804
|
+
* @returns Time zone name (e.g. "Singapore Standard Time")
|
|
805
|
+
*/ function tzName(timeZone, date, format = "long") {
|
|
806
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
807
|
+
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
|
|
808
|
+
hour: "numeric",
|
|
809
|
+
timeZone: timeZone,
|
|
810
|
+
timeZoneName: format
|
|
811
|
+
}).format(date).split(/\s/g) // Format.JS uses non-breaking spaces
|
|
812
|
+
.slice(2) // Skip the hour and AM/PM parts
|
|
813
|
+
.join(" ");
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const offsetFormatCache = {};
|
|
817
|
+
const offsetCache = {};
|
|
818
|
+
/**
|
|
819
|
+
* The function extracts UTC offset in minutes from the given date in specified
|
|
820
|
+
* time zone.
|
|
821
|
+
*
|
|
822
|
+
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
|
823
|
+
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
|
824
|
+
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
|
825
|
+
*
|
|
826
|
+
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
827
|
+
* @param date - Date to check the offset for
|
|
828
|
+
*
|
|
829
|
+
* @returns UTC offset in minutes
|
|
830
|
+
*/ function tzOffset(timeZone, date) {
|
|
831
|
+
try {
|
|
832
|
+
var _offsetFormatCache, _timeZone;
|
|
833
|
+
const format = (_offsetFormatCache = offsetFormatCache)[_timeZone = timeZone] || (_offsetFormatCache[_timeZone] = new Intl.DateTimeFormat("en-US", {
|
|
834
|
+
timeZone,
|
|
835
|
+
timeZoneName: "longOffset"
|
|
836
|
+
}).format);
|
|
837
|
+
const offsetStr = format(date).split("GMT")[1];
|
|
838
|
+
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
|
839
|
+
return calcOffset(offsetStr, offsetStr.split(":"));
|
|
840
|
+
} catch {
|
|
841
|
+
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
|
842
|
+
// See: https://github.com/nodejs/node/issues/53419
|
|
843
|
+
if (timeZone in offsetCache) return offsetCache[timeZone];
|
|
844
|
+
const captures = timeZone?.match(offsetRe);
|
|
845
|
+
if (captures) return calcOffset(timeZone, captures.slice(1));
|
|
846
|
+
return NaN;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
|
850
|
+
function calcOffset(cacheStr, values) {
|
|
851
|
+
const hours = +(values[0] || 0);
|
|
852
|
+
const minutes = +(values[1] || 0);
|
|
853
|
+
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
|
854
|
+
const seconds = +(values[2] || 0) / 60;
|
|
855
|
+
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
class TZDateMini extends Date {
|
|
859
|
+
static tz(tz, ...args) {
|
|
860
|
+
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
|
861
|
+
}
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region time zone
|
|
864
|
+
withTimeZone(timeZone) {
|
|
865
|
+
return new TZDateMini(+this, timeZone);
|
|
866
|
+
}
|
|
867
|
+
getTimezoneOffset() {
|
|
868
|
+
const offset = -tzOffset(this.timeZone, this);
|
|
869
|
+
// Remove the seconds offset
|
|
870
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
871
|
+
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
|
872
|
+
}
|
|
873
|
+
//#endregion
|
|
874
|
+
//#region time
|
|
875
|
+
setTime(time) {
|
|
876
|
+
Date.prototype.setTime.apply(this, arguments);
|
|
877
|
+
syncToInternal(this);
|
|
878
|
+
return +this;
|
|
879
|
+
}
|
|
880
|
+
//#endregion
|
|
881
|
+
//#region date-fns integration
|
|
882
|
+
[Symbol.for("constructDateFrom")](date) {
|
|
883
|
+
return new TZDateMini(+new Date(date), this.timeZone);
|
|
884
|
+
}
|
|
885
|
+
//#region static
|
|
886
|
+
constructor(...args){
|
|
887
|
+
super();
|
|
888
|
+
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
|
889
|
+
this.timeZone = args.pop();
|
|
890
|
+
}
|
|
891
|
+
this.internal = new Date();
|
|
892
|
+
if (isNaN(tzOffset(this.timeZone, this))) {
|
|
893
|
+
this.setTime(NaN);
|
|
894
|
+
} else {
|
|
895
|
+
if (!args.length) {
|
|
896
|
+
this.setTime(Date.now());
|
|
897
|
+
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
|
898
|
+
this.setTime(args[0]);
|
|
899
|
+
} else if (typeof args[0] === "string") {
|
|
900
|
+
this.setTime(+new Date(args[0]));
|
|
901
|
+
} else if (args[0] instanceof Date) {
|
|
902
|
+
this.setTime(+args[0]);
|
|
903
|
+
} else {
|
|
904
|
+
this.setTime(+new Date(...args));
|
|
905
|
+
adjustToSystemTZ(this);
|
|
906
|
+
syncToInternal(this);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
// Assign getters and setters
|
|
912
|
+
const re = /^(get|set)(?!UTC)/;
|
|
913
|
+
Object.getOwnPropertyNames(Date.prototype).forEach((method)=>{
|
|
914
|
+
if (!re.test(method)) return;
|
|
915
|
+
const utcMethod = method.replace(re, "$1UTC");
|
|
916
|
+
// Filter out methods without UTC counterparts
|
|
917
|
+
if (!TZDateMini.prototype[utcMethod]) return;
|
|
918
|
+
if (method.startsWith("get")) {
|
|
919
|
+
// Delegate to internal date's UTC method
|
|
920
|
+
TZDateMini.prototype[method] = function() {
|
|
921
|
+
return this.internal[utcMethod]();
|
|
922
|
+
};
|
|
923
|
+
} else {
|
|
924
|
+
// Assign regular setter
|
|
925
|
+
TZDateMini.prototype[method] = function() {
|
|
926
|
+
Date.prototype[utcMethod].apply(this.internal, arguments);
|
|
927
|
+
syncFromInternal(this);
|
|
928
|
+
return +this;
|
|
929
|
+
};
|
|
930
|
+
// Assign UTC setter
|
|
931
|
+
TZDateMini.prototype[utcMethod] = function() {
|
|
932
|
+
Date.prototype[utcMethod].apply(this, arguments);
|
|
933
|
+
syncToInternal(this);
|
|
934
|
+
return +this;
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
/**
|
|
939
|
+
* Function syncs time to internal date, applying the time zone offset.
|
|
940
|
+
*
|
|
941
|
+
* @param {Date} date - Date to sync
|
|
942
|
+
*/ function syncToInternal(date) {
|
|
943
|
+
date.internal.setTime(+date);
|
|
944
|
+
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Function syncs the internal date UTC values to the date. It allows to get
|
|
948
|
+
* accurate timestamp value.
|
|
949
|
+
*
|
|
950
|
+
* @param {Date} date - The date to sync
|
|
951
|
+
*/ function syncFromInternal(date) {
|
|
952
|
+
// First we transpose the internal values
|
|
953
|
+
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
|
954
|
+
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
|
955
|
+
// Now we have to adjust the date to the system time zone
|
|
956
|
+
adjustToSystemTZ(date);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Function adjusts the date to the system time zone. It uses the time zone
|
|
960
|
+
* differences to calculate the offset and adjust the date.
|
|
961
|
+
*
|
|
962
|
+
* @param {Date} date - Date to adjust
|
|
963
|
+
*/ function adjustToSystemTZ(date) {
|
|
964
|
+
// Save the time zone offset before all the adjustments
|
|
965
|
+
const baseOffset = tzOffset(date.timeZone, date);
|
|
966
|
+
// Remove the seconds offset
|
|
967
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
968
|
+
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
|
969
|
+
//#region System DST adjustment
|
|
970
|
+
// The biggest problem with using the system time zone is that when we create
|
|
971
|
+
// a date from internal values stored in UTC, the system time zone might end
|
|
972
|
+
// up on the DST hour:
|
|
973
|
+
//
|
|
974
|
+
// $ TZ=America/New_York node
|
|
975
|
+
// > new Date(2020, 2, 8, 1).toString()
|
|
976
|
+
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
|
977
|
+
// > new Date(2020, 2, 8, 2).toString()
|
|
978
|
+
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
979
|
+
// > new Date(2020, 2, 8, 3).toString()
|
|
980
|
+
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
981
|
+
// > new Date(2020, 2, 8, 4).toString()
|
|
982
|
+
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
983
|
+
//
|
|
984
|
+
// Here we get the same hour for both 2 and 3, because the system time zone
|
|
985
|
+
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
|
986
|
+
// to adjust the internal date to reflect that.
|
|
987
|
+
//
|
|
988
|
+
// However we want to adjust only if that's the DST hour the change happenes,
|
|
989
|
+
// not the hour where DST moves to.
|
|
990
|
+
// We calculate the previous hour to see if the time zone offset has changed
|
|
991
|
+
// and we have landed on the DST hour.
|
|
992
|
+
const prevHour = new Date(+date);
|
|
993
|
+
// We use UTC methods here as we don't want to land on the same hour again
|
|
994
|
+
// in case of DST.
|
|
995
|
+
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
|
996
|
+
// Calculate if we are on the system DST hour.
|
|
997
|
+
const systemOffset = -new Date(+date).getTimezoneOffset();
|
|
998
|
+
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
|
999
|
+
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
|
1000
|
+
// Detect the DST shift. System DST change will occur both on
|
|
1001
|
+
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
|
1002
|
+
// Move the internal date when we are on the system DST hour.
|
|
1003
|
+
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region System diff adjustment
|
|
1006
|
+
// Now we need to adjust the date, since we just applied internal values.
|
|
1007
|
+
// We need to calculate the difference between the system and date time zones
|
|
1008
|
+
// and apply it to the date.
|
|
1009
|
+
const offsetDiff = systemOffset - offset;
|
|
1010
|
+
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
|
1011
|
+
//#endregion
|
|
1012
|
+
//#region Seconds System diff adjustment
|
|
1013
|
+
const systemDate = new Date(+date);
|
|
1014
|
+
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
|
1015
|
+
systemDate.setUTCSeconds(0);
|
|
1016
|
+
// For negative systemOffset, invert the seconds.
|
|
1017
|
+
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
|
1018
|
+
// Calculate the seconds offset based on the timezone offset.
|
|
1019
|
+
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
|
1020
|
+
if (secondsOffset || systemSecondsOffset) {
|
|
1021
|
+
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
|
1022
|
+
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region Post-adjustment DST fix
|
|
1026
|
+
const postBaseOffset = tzOffset(date.timeZone, date);
|
|
1027
|
+
// Remove the seconds offset
|
|
1028
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
1029
|
+
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
|
1030
|
+
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
|
1031
|
+
const postOffsetDiff = postSystemOffset - postOffset;
|
|
1032
|
+
const offsetChanged = postOffset !== offset;
|
|
1033
|
+
const postDiff = postOffsetDiff - offsetDiff;
|
|
1034
|
+
if (offsetChanged && postDiff) {
|
|
1035
|
+
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
|
1036
|
+
// Now we need to check if got offset change during the post-adjustment.
|
|
1037
|
+
// If so, we also need both dates to reflect that.
|
|
1038
|
+
const newBaseOffset = tzOffset(date.timeZone, date);
|
|
1039
|
+
// Remove the seconds offset
|
|
1040
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
1041
|
+
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
|
1042
|
+
const offsetChange = postOffset - newOffset;
|
|
1043
|
+
if (offsetChange) {
|
|
1044
|
+
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
|
1045
|
+
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
//#endregion
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
class TZDate extends TZDateMini {
|
|
1052
|
+
//#region static
|
|
1053
|
+
static tz(tz, ...args) {
|
|
1054
|
+
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
|
1055
|
+
}
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region representation
|
|
1058
|
+
toISOString() {
|
|
1059
|
+
const [sign, hours, minutes] = this.tzComponents();
|
|
1060
|
+
const tz = `${sign}${hours}:${minutes}`;
|
|
1061
|
+
return this.internal.toISOString().slice(0, -1) + tz;
|
|
1062
|
+
}
|
|
1063
|
+
toString() {
|
|
1064
|
+
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
|
1065
|
+
return `${this.toDateString()} ${this.toTimeString()}`;
|
|
1066
|
+
}
|
|
1067
|
+
toDateString() {
|
|
1068
|
+
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
1069
|
+
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
|
1070
|
+
// "Tue Aug 13 2024"
|
|
1071
|
+
return `${day?.slice(0, -1)} ${month} ${date} ${year}`;
|
|
1072
|
+
}
|
|
1073
|
+
toTimeString() {
|
|
1074
|
+
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
1075
|
+
const time = this.internal.toUTCString().split(" ")[4];
|
|
1076
|
+
const [sign, hours, minutes] = this.tzComponents();
|
|
1077
|
+
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
|
1078
|
+
return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
|
|
1079
|
+
}
|
|
1080
|
+
toLocaleString(locales, options) {
|
|
1081
|
+
return Date.prototype.toLocaleString.call(this, locales, {
|
|
1082
|
+
...options,
|
|
1083
|
+
timeZone: options?.timeZone || this.timeZone
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
toLocaleDateString(locales, options) {
|
|
1087
|
+
return Date.prototype.toLocaleDateString.call(this, locales, {
|
|
1088
|
+
...options,
|
|
1089
|
+
timeZone: options?.timeZone || this.timeZone
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
toLocaleTimeString(locales, options) {
|
|
1093
|
+
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
|
1094
|
+
...options,
|
|
1095
|
+
timeZone: options?.timeZone || this.timeZone
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region private
|
|
1100
|
+
tzComponents() {
|
|
1101
|
+
const offset = this.getTimezoneOffset();
|
|
1102
|
+
const sign = offset > 0 ? "-" : "+";
|
|
1103
|
+
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
|
1104
|
+
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
|
1105
|
+
return [
|
|
1106
|
+
sign,
|
|
1107
|
+
hours,
|
|
1108
|
+
minutes
|
|
1109
|
+
];
|
|
1110
|
+
}
|
|
1111
|
+
//#endregion
|
|
1112
|
+
withTimeZone(timeZone) {
|
|
1113
|
+
return new TZDate(+this, timeZone);
|
|
1114
|
+
}
|
|
1115
|
+
//#region date-fns integration
|
|
1116
|
+
[Symbol.for("constructDateFrom")](date) {
|
|
1117
|
+
return new TZDate(+new Date(date), this.timeZone);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
1121
|
const FIVE_WEEKS = 5;
|
|
1122
1122
|
const FOUR_WEEKS = 4;
|
|
1123
1123
|
/**
|
|
@@ -4635,4 +4635,4 @@ function CalendarDayButton({ className, day, modifiers, ...props }) {
|
|
|
4635
4635
|
}
|
|
4636
4636
|
|
|
4637
4637
|
export { Calendar as C, CalendarDayButton as a, addMonths as b };
|
|
4638
|
-
//# sourceMappingURL=calendar-
|
|
4638
|
+
//# sourceMappingURL=calendar-BzT7glLL.mjs.map
|