@gobrand/tiempo 2.8.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addDays.js +3 -2
- package/dist/addHours.js +3 -2
- package/dist/addMicroseconds.js +3 -2
- package/dist/addMilliseconds.js +3 -2
- package/dist/addMinutes.js +3 -2
- package/dist/addMonths.js +3 -2
- package/dist/addNanoseconds.js +3 -2
- package/dist/addSeconds.js +3 -2
- package/dist/addWeeks.js +3 -2
- package/dist/addYears.js +3 -2
- package/dist/{chunk-OLEOU3XE.js → chunk-2J434XZJ.js} +5 -3
- package/dist/chunk-2J434XZJ.js.map +1 -0
- package/dist/{chunk-RW3C2677.js → chunk-3QC5YINX.js} +2 -3
- package/dist/chunk-3QC5YINX.js.map +1 -0
- package/dist/{chunk-YIT6EMBC.js → chunk-3WWRI3NR.js} +2 -3
- package/dist/chunk-3WWRI3NR.js.map +1 -0
- package/dist/{chunk-X26WIJ6L.js → chunk-46EP6MO2.js} +7 -5
- package/dist/chunk-46EP6MO2.js.map +1 -0
- package/dist/{chunk-UBY22QWM.js → chunk-4ZRJ3EHQ.js} +4 -4
- package/dist/{chunk-Q2F3HEXB.js → chunk-5HVHKQTJ.js} +2 -2
- package/dist/{chunk-BV6CLVSI.js → chunk-76RCTVBW.js} +3 -4
- package/dist/chunk-76RCTVBW.js.map +1 -0
- package/dist/{chunk-O6RIN7K3.js → chunk-7LZPFGGV.js} +5 -2
- package/dist/chunk-7LZPFGGV.js.map +1 -0
- package/dist/{chunk-5C3TQSWA.js → chunk-7NQ76UHP.js} +4 -5
- package/dist/chunk-7NQ76UHP.js.map +1 -0
- package/dist/{chunk-52NEOY34.js → chunk-7XVPK2AV.js} +2 -2
- package/dist/{chunk-PVAOUYXF.js → chunk-AAORAX74.js} +5 -5
- package/dist/chunk-AAORAX74.js.map +1 -0
- package/dist/{chunk-776JOVV6.js → chunk-ADAN2I34.js} +2 -3
- package/dist/chunk-ADAN2I34.js.map +1 -0
- package/dist/{chunk-WUAIUEH7.js → chunk-BIH6JETG.js} +5 -2
- package/dist/chunk-BIH6JETG.js.map +1 -0
- package/dist/{chunk-DT2EWLHU.js → chunk-BOGN7JC3.js} +2 -2
- package/dist/{chunk-WY63VEXE.js → chunk-C5HDCIRV.js} +5 -2
- package/dist/chunk-C5HDCIRV.js.map +1 -0
- package/dist/{chunk-WVHAYLBW.js → chunk-CP4JNCMO.js} +2 -2
- package/dist/{chunk-HFQUXON5.js → chunk-DGRZ6HO3.js} +10 -5
- package/dist/chunk-DGRZ6HO3.js.map +1 -0
- package/dist/{chunk-MMI2HHT7.js → chunk-DHJ353HR.js} +2 -2
- package/dist/{chunk-4NJMCCUM.js → chunk-DJRIH2PX.js} +2 -2
- package/dist/{chunk-YKBP3G7L.js → chunk-DN3V4IZC.js} +2 -2
- package/dist/{chunk-EYO2ZJLH.js → chunk-DOGZ2WBH.js} +2 -2
- package/dist/{chunk-QFNGYTTH.js → chunk-DTZPE5PM.js} +5 -3
- package/dist/chunk-DTZPE5PM.js.map +1 -0
- package/dist/chunk-ERCE3YCO.js +19 -0
- package/dist/chunk-ERCE3YCO.js.map +1 -0
- package/dist/{chunk-6IP245MS.js → chunk-ESTLMF2X.js} +5 -5
- package/dist/chunk-ESTLMF2X.js.map +1 -0
- package/dist/chunk-F6EWMA4K.js +13 -0
- package/dist/chunk-F6EWMA4K.js.map +1 -0
- package/dist/{chunk-7VLSSOVC.js → chunk-FEUIZJOV.js} +3 -4
- package/dist/chunk-FEUIZJOV.js.map +1 -0
- package/dist/{chunk-ZGR4NZTS.js → chunk-FIX6LQG5.js} +2 -3
- package/dist/chunk-FIX6LQG5.js.map +1 -0
- package/dist/{chunk-L4SVABDH.js → chunk-G4COVQ5S.js} +2 -2
- package/dist/{chunk-LDO6PRNJ.js → chunk-GEMTHX5S.js} +2 -2
- package/dist/{chunk-3TSFIPUR.js → chunk-GS3J5YVW.js} +2 -3
- package/dist/chunk-GS3J5YVW.js.map +1 -0
- package/dist/{chunk-DKYVFYWM.js → chunk-GVZOCS7O.js} +5 -3
- package/dist/chunk-GVZOCS7O.js.map +1 -0
- package/dist/{chunk-BIAPE4MR.js → chunk-HHPXUFZP.js} +5 -5
- package/dist/chunk-HHPXUFZP.js.map +1 -0
- package/dist/{chunk-S63QUP4W.js → chunk-I3RXBZP5.js} +2 -2
- package/dist/{chunk-ADQTZVMH.js → chunk-IPWSPA4H.js} +2 -2
- package/dist/chunk-JVB5IARQ.js +19 -0
- package/dist/chunk-JVB5IARQ.js.map +1 -0
- package/dist/{chunk-JOD4ATPE.js → chunk-JXBC2VU2.js} +2 -2
- package/dist/{chunk-V27NUBXQ.js → chunk-KKMM6HYC.js} +2 -2
- package/dist/{chunk-A5VVBYNT.js → chunk-KONRPZXK.js} +2 -2
- package/dist/{chunk-CY746ZUQ.js → chunk-L2CNUS43.js} +2 -2
- package/dist/{chunk-KZB6NERH.js → chunk-LGLV7RIC.js} +5 -2
- package/dist/chunk-LGLV7RIC.js.map +1 -0
- package/dist/{chunk-JA7SVLAF.js → chunk-LLN2SKGE.js} +4 -4
- package/dist/{chunk-JNA3AFOC.js → chunk-LYPSZYIG.js} +5 -2
- package/dist/chunk-LYPSZYIG.js.map +1 -0
- package/dist/{chunk-AE36GX4F.js → chunk-MHXSUAPE.js} +5 -2
- package/dist/chunk-MHXSUAPE.js.map +1 -0
- package/dist/{chunk-BUX26GTD.js → chunk-NKWGZIOJ.js} +5 -3
- package/dist/chunk-NKWGZIOJ.js.map +1 -0
- package/dist/{chunk-VZJGCDAG.js → chunk-NT7VDFLO.js} +5 -2
- package/dist/chunk-NT7VDFLO.js.map +1 -0
- package/dist/{chunk-7ATM7AXL.js → chunk-OGNREZPA.js} +2 -2
- package/dist/{chunk-EZ7NVTZI.js → chunk-OKPTY2ZQ.js} +7 -5
- package/dist/chunk-OKPTY2ZQ.js.map +1 -0
- package/dist/{chunk-ISHZRFVN.js → chunk-OPACRBGV.js} +2 -2
- package/dist/{chunk-J6G2I2TU.js → chunk-OZYC3TAR.js} +2 -2
- package/dist/{chunk-2XHAHSB6.js → chunk-PBT2OZJH.js} +2 -2
- package/dist/{chunk-BSV32PSO.js → chunk-PEGMMWZU.js} +6 -3
- package/dist/chunk-PEGMMWZU.js.map +1 -0
- package/dist/{chunk-BH2YB4MV.js → chunk-PWPACA4G.js} +2 -2
- package/dist/{chunk-3A6X6WV5.js → chunk-PXF3RMFH.js} +1 -2
- package/dist/chunk-PXF3RMFH.js.map +1 -0
- package/dist/{chunk-HDBH7RTY.js → chunk-QGXK664C.js} +2 -2
- package/dist/{chunk-AJEIDKVJ.js → chunk-QHQACJEU.js} +5 -2
- package/dist/chunk-QHQACJEU.js.map +1 -0
- package/dist/{chunk-CHW2EN2O.js → chunk-QPGTY5DD.js} +5 -5
- package/dist/chunk-QPGTY5DD.js.map +1 -0
- package/dist/{chunk-Y7CIJQ67.js → chunk-QRLTVRYC.js} +5 -3
- package/dist/chunk-QRLTVRYC.js.map +1 -0
- package/dist/{chunk-JHRXY36W.js → chunk-QVXCG625.js} +2 -2
- package/dist/{chunk-OQ4CWKJT.js → chunk-R7MM4BDS.js} +2 -3
- package/dist/chunk-R7MM4BDS.js.map +1 -0
- package/dist/{chunk-EEQ3REET.js → chunk-RSY3BI3P.js} +2 -2
- package/dist/{chunk-NRD5HRZV.js → chunk-RTANLM3L.js} +2 -2
- package/dist/{chunk-OABS374T.js → chunk-RUJC6FOA.js} +2 -3
- package/dist/chunk-RUJC6FOA.js.map +1 -0
- package/dist/{chunk-BQBLSXK2.js → chunk-SDCVBRJP.js} +2 -2
- package/dist/{chunk-HLGMUTFK.js → chunk-SFXJV5ZT.js} +2 -3
- package/dist/chunk-SFXJV5ZT.js.map +1 -0
- package/dist/{chunk-BPZ7BRJW.js → chunk-SHDXBQ7E.js} +5 -2
- package/dist/chunk-SHDXBQ7E.js.map +1 -0
- package/dist/{chunk-VLZ3HQQA.js → chunk-SQJTTKEI.js} +2 -2
- package/dist/{chunk-RBEW6PXR.js → chunk-SRXD4AGD.js} +5 -2
- package/dist/chunk-SRXD4AGD.js.map +1 -0
- package/dist/{chunk-4PSMM55Q.js → chunk-SWDOKPVX.js} +7 -3
- package/dist/chunk-SWDOKPVX.js.map +1 -0
- package/dist/{chunk-UJWM2BV2.js → chunk-SY2S6MMZ.js} +10 -5
- package/dist/chunk-SY2S6MMZ.js.map +1 -0
- package/dist/{chunk-ZC6KWXCW.js → chunk-SZATPYBI.js} +36 -27
- package/dist/chunk-SZATPYBI.js.map +1 -0
- package/dist/{chunk-TGKWBQ7L.js → chunk-T6ONGPRF.js} +6 -3
- package/dist/chunk-T6ONGPRF.js.map +1 -0
- package/dist/{chunk-PPB62JYV.js → chunk-TDZ3XUH7.js} +2 -2
- package/dist/{chunk-G2JUEBC5.js → chunk-TIEAKS3O.js} +5 -3
- package/dist/chunk-TIEAKS3O.js.map +1 -0
- package/dist/{chunk-DFLGGK4F.js → chunk-U7ZWIAB3.js} +6 -3
- package/dist/chunk-U7ZWIAB3.js.map +1 -0
- package/dist/chunk-VOZTLX5F.js +22 -0
- package/dist/chunk-VOZTLX5F.js.map +1 -0
- package/dist/{chunk-XW5MLXX5.js → chunk-VVV5BNLP.js} +2 -2
- package/dist/{chunk-AJ4JBKJK.js → chunk-VXOQ7IG5.js} +1 -2
- package/dist/chunk-VXOQ7IG5.js.map +1 -0
- package/dist/{chunk-HOCNCQTC.js → chunk-W6RF44CV.js} +2 -3
- package/dist/chunk-W6RF44CV.js.map +1 -0
- package/dist/{chunk-AHMKY474.js → chunk-WJOGQ6IB.js} +2 -2
- package/dist/{chunk-5BYRBC7H.js → chunk-WLW622M7.js} +18 -17
- package/dist/{chunk-5BYRBC7H.js.map → chunk-WLW622M7.js.map} +1 -1
- package/dist/{chunk-ZDA7GSWU.js → chunk-WNPPRDN3.js} +3 -4
- package/dist/chunk-WNPPRDN3.js.map +1 -0
- package/dist/{chunk-4E7OGJ3F.js → chunk-XONITURH.js} +5 -2
- package/dist/chunk-XONITURH.js.map +1 -0
- package/dist/{chunk-UJW2FPI4.js → chunk-XRZUPSUB.js} +2 -2
- package/dist/chunk-Y4HT4LCB.js +19 -0
- package/dist/chunk-Y4HT4LCB.js.map +1 -0
- package/dist/{chunk-TNCLJK4Y.js → chunk-Z2LOTP6T.js} +5 -3
- package/dist/chunk-Z2LOTP6T.js.map +1 -0
- package/dist/chunk-ZBEEQUE4.js +19 -0
- package/dist/chunk-ZBEEQUE4.js.map +1 -0
- package/dist/{chunk-FSD3DDFC.js → chunk-ZFXBHDFB.js} +5 -2
- package/dist/chunk-ZFXBHDFB.js.map +1 -0
- package/dist/{chunk-U4RNUZXO.js → chunk-ZKGR3F4F.js} +2 -2
- package/dist/{chunk-YQBM63DC.js → chunk-ZSRCVDZ2.js} +9 -4
- package/dist/chunk-ZSRCVDZ2.js.map +1 -0
- package/dist/differenceInDays.d.ts +5 -3
- package/dist/differenceInDays.d.ts.map +1 -1
- package/dist/differenceInDays.js +3 -2
- package/dist/differenceInHours.d.ts +5 -3
- package/dist/differenceInHours.d.ts.map +1 -1
- package/dist/differenceInHours.js +4 -3
- package/dist/differenceInMicroseconds.d.ts +1 -1
- package/dist/differenceInMicroseconds.d.ts.map +1 -1
- package/dist/differenceInMicroseconds.js +3 -2
- package/dist/differenceInMilliseconds.d.ts +1 -1
- package/dist/differenceInMilliseconds.d.ts.map +1 -1
- package/dist/differenceInMilliseconds.js +4 -3
- package/dist/differenceInMinutes.d.ts +5 -3
- package/dist/differenceInMinutes.d.ts.map +1 -1
- package/dist/differenceInMinutes.js +4 -3
- package/dist/differenceInMonths.d.ts +8 -5
- package/dist/differenceInMonths.d.ts.map +1 -1
- package/dist/differenceInMonths.js +3 -2
- package/dist/differenceInNanoseconds.d.ts +1 -1
- package/dist/differenceInNanoseconds.d.ts.map +1 -1
- package/dist/differenceInNanoseconds.js +3 -2
- package/dist/differenceInSeconds.d.ts +5 -3
- package/dist/differenceInSeconds.d.ts.map +1 -1
- package/dist/differenceInSeconds.js +4 -3
- package/dist/differenceInWeeks.d.ts +6 -4
- package/dist/differenceInWeeks.d.ts.map +1 -1
- package/dist/differenceInWeeks.js +3 -2
- package/dist/differenceInYears.d.ts +8 -5
- package/dist/differenceInYears.d.ts.map +1 -1
- package/dist/differenceInYears.js +3 -2
- package/dist/eachDayOfInterval.d.ts +1 -1
- package/dist/eachDayOfInterval.d.ts.map +1 -1
- package/dist/eachDayOfInterval.js +3 -2
- package/dist/eachHourOfInterval.d.ts +1 -1
- package/dist/eachHourOfInterval.d.ts.map +1 -1
- package/dist/eachHourOfInterval.js +3 -2
- package/dist/eachMinuteOfInterval.d.ts +1 -1
- package/dist/eachMinuteOfInterval.d.ts.map +1 -1
- package/dist/eachMinuteOfInterval.js +3 -2
- package/dist/eachMonthOfInterval.d.ts +1 -1
- package/dist/eachMonthOfInterval.d.ts.map +1 -1
- package/dist/eachMonthOfInterval.js +3 -2
- package/dist/eachWeekOfInterval.d.ts +1 -1
- package/dist/eachWeekOfInterval.d.ts.map +1 -1
- package/dist/eachWeekOfInterval.js +3 -2
- package/dist/eachYearOfInterval.d.ts +1 -1
- package/dist/eachYearOfInterval.d.ts.map +1 -1
- package/dist/eachYearOfInterval.js +3 -2
- package/dist/endOfDay.d.ts +1 -1
- package/dist/endOfDay.d.ts.map +1 -1
- package/dist/endOfDay.js +5 -4
- package/dist/endOfMonth.d.ts +1 -1
- package/dist/endOfMonth.d.ts.map +1 -1
- package/dist/endOfMonth.js +5 -4
- package/dist/endOfWeek.d.ts +1 -1
- package/dist/endOfWeek.d.ts.map +1 -1
- package/dist/endOfWeek.js +4 -3
- package/dist/endOfYear.d.ts +1 -1
- package/dist/endOfYear.d.ts.map +1 -1
- package/dist/endOfYear.js +5 -4
- package/dist/format.d.ts +1 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +3 -2
- package/dist/formatPlainDate.d.ts +1 -1
- package/dist/formatPlainDate.d.ts.map +1 -1
- package/dist/formatPlainDate.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -88
- package/dist/intlFormatDistance.d.ts.map +1 -1
- package/dist/intlFormatDistance.js +11 -10
- package/dist/isAfter.d.ts +1 -1
- package/dist/isAfter.d.ts.map +1 -1
- package/dist/isAfter.js +4 -3
- package/dist/isBefore.d.ts +1 -1
- package/dist/isBefore.d.ts.map +1 -1
- package/dist/isBefore.js +4 -3
- package/dist/isFuture.js +5 -4
- package/dist/isPast.js +5 -4
- package/dist/isPlainDateAfter.d.ts +1 -1
- package/dist/isPlainDateAfter.d.ts.map +1 -1
- package/dist/isPlainDateAfter.js +2 -1
- package/dist/isPlainDateBefore.d.ts +1 -1
- package/dist/isPlainDateBefore.d.ts.map +1 -1
- package/dist/isPlainDateBefore.js +2 -1
- package/dist/isPlainDateEqual.d.ts +1 -1
- package/dist/isPlainDateEqual.d.ts.map +1 -1
- package/dist/isPlainDateEqual.js +2 -1
- package/dist/isPlainTimeAfter.d.ts +1 -1
- package/dist/isPlainTimeAfter.d.ts.map +1 -1
- package/dist/isPlainTimeAfter.js +2 -1
- package/dist/isPlainTimeBefore.d.ts +1 -1
- package/dist/isPlainTimeBefore.d.ts.map +1 -1
- package/dist/isPlainTimeBefore.js +2 -1
- package/dist/isPlainTimeEqual.d.ts +1 -1
- package/dist/isPlainTimeEqual.d.ts.map +1 -1
- package/dist/isPlainTimeEqual.js +2 -1
- package/dist/isSameDay.d.ts +1 -1
- package/dist/isSameDay.d.ts.map +1 -1
- package/dist/isSameDay.js +3 -2
- package/dist/isSameHour.js +3 -2
- package/dist/isSameMicrosecond.js +3 -2
- package/dist/isSameMillisecond.js +3 -2
- package/dist/isSameMinute.js +3 -2
- package/dist/isSameMonth.js +3 -2
- package/dist/isSameNanosecond.js +3 -2
- package/dist/isSameSecond.js +3 -2
- package/dist/isSameWeek.js +3 -2
- package/dist/isSameYear.js +3 -2
- package/dist/isWithinInterval.d.ts +1 -1
- package/dist/isWithinInterval.d.ts.map +1 -1
- package/dist/isWithinInterval.js +5 -4
- package/dist/now.d.ts +1 -1
- package/dist/now.d.ts.map +1 -1
- package/dist/now.js +2 -1
- package/dist/roundToNearestHour.js +3 -2
- package/dist/roundToNearestMinute.js +3 -2
- package/dist/roundToNearestSecond.js +3 -2
- package/dist/shared/differenceInMilliseconds.d.ts +1 -1
- package/dist/shared/differenceInMilliseconds.d.ts.map +1 -1
- package/dist/shared/differenceInMilliseconds.js +2 -1
- package/dist/shared/differenceOptions.d.ts +16 -0
- package/dist/shared/differenceOptions.d.ts.map +1 -0
- package/dist/shared/differenceOptions.js +1 -0
- package/dist/shared/differenceOptions.js.map +1 -0
- package/dist/shared/isAfter.d.ts +1 -1
- package/dist/shared/isAfter.d.ts.map +1 -1
- package/dist/shared/isAfter.js +2 -1
- package/dist/shared/isBefore.d.ts +1 -1
- package/dist/shared/isBefore.d.ts.map +1 -1
- package/dist/shared/isBefore.js +2 -1
- package/dist/shared/normalizeTemporalInput.d.ts +1 -1
- package/dist/shared/normalizeTemporalInput.d.ts.map +1 -1
- package/dist/shared/normalizeTemporalInput.js +2 -1
- package/dist/shared/normalizeWithPlainDate.d.ts +1 -1
- package/dist/shared/normalizeWithPlainDate.d.ts.map +1 -1
- package/dist/shared/normalizeWithPlainDate.js +4 -3
- package/dist/shared/nowZoned.d.ts +1 -1
- package/dist/shared/nowZoned.d.ts.map +1 -1
- package/dist/shared/nowZoned.js +3 -2
- package/dist/shared/plainDateToZonedDateTime.d.ts +1 -1
- package/dist/shared/plainDateToZonedDateTime.d.ts.map +1 -1
- package/dist/shared/plainDateToZonedDateTime.js +2 -1
- package/dist/shared/temporal.d.ts +37 -0
- package/dist/shared/temporal.d.ts.map +1 -0
- package/dist/shared/temporal.js +13 -0
- package/dist/shared/temporal.js.map +1 -0
- package/dist/shared/temporal.test.d.ts +2 -0
- package/dist/shared/temporal.test.d.ts.map +1 -0
- package/dist/simpleFormat.d.ts +1 -1
- package/dist/simpleFormat.d.ts.map +1 -1
- package/dist/simpleFormat.js +2 -1
- package/dist/startOfDay.d.ts +1 -1
- package/dist/startOfDay.d.ts.map +1 -1
- package/dist/startOfDay.js +5 -4
- package/dist/startOfMonth.d.ts +1 -1
- package/dist/startOfMonth.d.ts.map +1 -1
- package/dist/startOfMonth.js +5 -4
- package/dist/startOfWeek.d.ts +1 -1
- package/dist/startOfWeek.d.ts.map +1 -1
- package/dist/startOfWeek.js +4 -3
- package/dist/startOfYear.d.ts +1 -1
- package/dist/startOfYear.d.ts.map +1 -1
- package/dist/startOfYear.js +5 -4
- package/dist/subDays.js +4 -3
- package/dist/subHours.js +4 -3
- package/dist/subMicroseconds.js +4 -3
- package/dist/subMilliseconds.js +4 -3
- package/dist/subMinutes.js +4 -3
- package/dist/subMonths.js +4 -3
- package/dist/subNanoseconds.js +4 -3
- package/dist/subSeconds.js +4 -3
- package/dist/subWeeks.js +4 -3
- package/dist/subYears.js +4 -3
- package/dist/toDate.d.ts +1 -1
- package/dist/toDate.d.ts.map +1 -1
- package/dist/toDate.js +2 -1
- package/dist/toIso.d.ts +1 -1
- package/dist/toIso.d.ts.map +1 -1
- package/dist/toIso.js +2 -1
- package/dist/toIso9075.d.ts +1 -1
- package/dist/toIso9075.d.ts.map +1 -1
- package/dist/toIso9075.js +2 -1
- package/dist/toPlainDate.d.ts +1 -1
- package/dist/toPlainDate.d.ts.map +1 -1
- package/dist/toPlainDate.js +2 -1
- package/dist/toPlainTime.d.ts +1 -1
- package/dist/toPlainTime.d.ts.map +1 -1
- package/dist/toPlainTime.js +2 -1
- package/dist/toUtc.d.ts +1 -1
- package/dist/toUtc.d.ts.map +1 -1
- package/dist/toUtc.js +2 -1
- package/dist/toZonedTime.d.ts +1 -1
- package/dist/toZonedTime.d.ts.map +1 -1
- package/dist/toZonedTime.js +2 -1
- package/dist/today.d.ts +1 -1
- package/dist/today.d.ts.map +1 -1
- package/dist/today.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-3A6X6WV5.js.map +0 -1
- package/dist/chunk-3TSFIPUR.js.map +0 -1
- package/dist/chunk-4E7OGJ3F.js.map +0 -1
- package/dist/chunk-4PSMM55Q.js.map +0 -1
- package/dist/chunk-5C3TQSWA.js.map +0 -1
- package/dist/chunk-6IP245MS.js.map +0 -1
- package/dist/chunk-776JOVV6.js.map +0 -1
- package/dist/chunk-7VLSSOVC.js.map +0 -1
- package/dist/chunk-AE36GX4F.js.map +0 -1
- package/dist/chunk-AJ4JBKJK.js.map +0 -1
- package/dist/chunk-AJEIDKVJ.js.map +0 -1
- package/dist/chunk-B2R2G5YK.js +0 -19
- package/dist/chunk-B2R2G5YK.js.map +0 -1
- package/dist/chunk-BIAPE4MR.js.map +0 -1
- package/dist/chunk-BPZ7BRJW.js.map +0 -1
- package/dist/chunk-BSV32PSO.js.map +0 -1
- package/dist/chunk-BUX26GTD.js.map +0 -1
- package/dist/chunk-BV6CLVSI.js.map +0 -1
- package/dist/chunk-CHW2EN2O.js.map +0 -1
- package/dist/chunk-DFLGGK4F.js.map +0 -1
- package/dist/chunk-DKYVFYWM.js.map +0 -1
- package/dist/chunk-EZ7NVTZI.js.map +0 -1
- package/dist/chunk-FSD3DDFC.js.map +0 -1
- package/dist/chunk-G2JUEBC5.js.map +0 -1
- package/dist/chunk-HFQUXON5.js.map +0 -1
- package/dist/chunk-HLGMUTFK.js.map +0 -1
- package/dist/chunk-HOCNCQTC.js.map +0 -1
- package/dist/chunk-JNA3AFOC.js.map +0 -1
- package/dist/chunk-KGVUENQO.js +0 -17
- package/dist/chunk-KGVUENQO.js.map +0 -1
- package/dist/chunk-KZB6NERH.js.map +0 -1
- package/dist/chunk-MJSZNWCV.js +0 -10
- package/dist/chunk-MJSZNWCV.js.map +0 -1
- package/dist/chunk-O6RIN7K3.js.map +0 -1
- package/dist/chunk-OABS374T.js.map +0 -1
- package/dist/chunk-OLEOU3XE.js.map +0 -1
- package/dist/chunk-OQ4CWKJT.js.map +0 -1
- package/dist/chunk-PMJD5N5J.js +0 -19
- package/dist/chunk-PMJD5N5J.js.map +0 -1
- package/dist/chunk-PVAOUYXF.js.map +0 -1
- package/dist/chunk-QFNGYTTH.js.map +0 -1
- package/dist/chunk-QVOEXF46.js +0 -19
- package/dist/chunk-QVOEXF46.js.map +0 -1
- package/dist/chunk-RBEW6PXR.js.map +0 -1
- package/dist/chunk-RW3C2677.js.map +0 -1
- package/dist/chunk-TGKWBQ7L.js.map +0 -1
- package/dist/chunk-TNCLJK4Y.js.map +0 -1
- package/dist/chunk-UJWM2BV2.js.map +0 -1
- package/dist/chunk-VZJGCDAG.js.map +0 -1
- package/dist/chunk-WUAIUEH7.js.map +0 -1
- package/dist/chunk-WY63VEXE.js.map +0 -1
- package/dist/chunk-X26WIJ6L.js.map +0 -1
- package/dist/chunk-Y7CIJQ67.js.map +0 -1
- package/dist/chunk-YIT6EMBC.js.map +0 -1
- package/dist/chunk-YQBM63DC.js.map +0 -1
- package/dist/chunk-ZC6KWXCW.js.map +0 -1
- package/dist/chunk-ZDA7GSWU.js.map +0 -1
- package/dist/chunk-ZGR4NZTS.js.map +0 -1
- /package/dist/{chunk-UBY22QWM.js.map → chunk-4ZRJ3EHQ.js.map} +0 -0
- /package/dist/{chunk-Q2F3HEXB.js.map → chunk-5HVHKQTJ.js.map} +0 -0
- /package/dist/{chunk-52NEOY34.js.map → chunk-7XVPK2AV.js.map} +0 -0
- /package/dist/{chunk-DT2EWLHU.js.map → chunk-BOGN7JC3.js.map} +0 -0
- /package/dist/{chunk-WVHAYLBW.js.map → chunk-CP4JNCMO.js.map} +0 -0
- /package/dist/{chunk-MMI2HHT7.js.map → chunk-DHJ353HR.js.map} +0 -0
- /package/dist/{chunk-4NJMCCUM.js.map → chunk-DJRIH2PX.js.map} +0 -0
- /package/dist/{chunk-YKBP3G7L.js.map → chunk-DN3V4IZC.js.map} +0 -0
- /package/dist/{chunk-EYO2ZJLH.js.map → chunk-DOGZ2WBH.js.map} +0 -0
- /package/dist/{chunk-L4SVABDH.js.map → chunk-G4COVQ5S.js.map} +0 -0
- /package/dist/{chunk-LDO6PRNJ.js.map → chunk-GEMTHX5S.js.map} +0 -0
- /package/dist/{chunk-S63QUP4W.js.map → chunk-I3RXBZP5.js.map} +0 -0
- /package/dist/{chunk-ADQTZVMH.js.map → chunk-IPWSPA4H.js.map} +0 -0
- /package/dist/{chunk-JOD4ATPE.js.map → chunk-JXBC2VU2.js.map} +0 -0
- /package/dist/{chunk-V27NUBXQ.js.map → chunk-KKMM6HYC.js.map} +0 -0
- /package/dist/{chunk-A5VVBYNT.js.map → chunk-KONRPZXK.js.map} +0 -0
- /package/dist/{chunk-CY746ZUQ.js.map → chunk-L2CNUS43.js.map} +0 -0
- /package/dist/{chunk-JA7SVLAF.js.map → chunk-LLN2SKGE.js.map} +0 -0
- /package/dist/{chunk-7ATM7AXL.js.map → chunk-OGNREZPA.js.map} +0 -0
- /package/dist/{chunk-ISHZRFVN.js.map → chunk-OPACRBGV.js.map} +0 -0
- /package/dist/{chunk-J6G2I2TU.js.map → chunk-OZYC3TAR.js.map} +0 -0
- /package/dist/{chunk-2XHAHSB6.js.map → chunk-PBT2OZJH.js.map} +0 -0
- /package/dist/{chunk-BH2YB4MV.js.map → chunk-PWPACA4G.js.map} +0 -0
- /package/dist/{chunk-HDBH7RTY.js.map → chunk-QGXK664C.js.map} +0 -0
- /package/dist/{chunk-JHRXY36W.js.map → chunk-QVXCG625.js.map} +0 -0
- /package/dist/{chunk-EEQ3REET.js.map → chunk-RSY3BI3P.js.map} +0 -0
- /package/dist/{chunk-NRD5HRZV.js.map → chunk-RTANLM3L.js.map} +0 -0
- /package/dist/{chunk-BQBLSXK2.js.map → chunk-SDCVBRJP.js.map} +0 -0
- /package/dist/{chunk-VLZ3HQQA.js.map → chunk-SQJTTKEI.js.map} +0 -0
- /package/dist/{chunk-PPB62JYV.js.map → chunk-TDZ3XUH7.js.map} +0 -0
- /package/dist/{chunk-XW5MLXX5.js.map → chunk-VVV5BNLP.js.map} +0 -0
- /package/dist/{chunk-AHMKY474.js.map → chunk-WJOGQ6IB.js.map} +0 -0
- /package/dist/{chunk-UJW2FPI4.js.map → chunk-XRZUPSUB.js.map} +0 -0
- /package/dist/{chunk-U4RNUZXO.js.map → chunk-ZKGR3F4F.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/format.ts"],"sourcesContent":["import { isInstant } from './shared/temporal';\nimport type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport type { Timezone } from './types';\n\nexport interface FormatOptions {\n locale?: string;\n timeZone?: Timezone;\n}\n\n/**\n * Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.\n * Uses Intl.DateTimeFormat under the hood via Temporal's toLocaleString() for zero dependencies.\n *\n * @param input - A Temporal.Instant or Temporal.ZonedDateTime to format\n * @param formatStr - Format string using date-fns tokens (e.g., \"yyyy-MM-dd HH:mm:ss\")\n * @param options - Optional configuration for locale and timezone\n * @returns Formatted date string\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * format(zoned, \"yyyy-MM-dd\"); // \"2025-01-20\"\n * format(zoned, \"MMMM d, yyyy\"); // \"January 20, 2025\"\n * format(zoned, \"h:mm a\"); // \"3:00 PM\"\n * format(zoned, \"EEEE, MMMM do, yyyy 'at' h:mm a\"); // \"Monday, January 20th, 2025 at 3:00 PM\"\n *\n * // With locale\n * format(zoned, \"MMMM d, yyyy\", { locale: \"es-ES\" }); // \"enero 20, 2025\"\n * ```\n */\nexport function format(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n formatStr: string,\n options: FormatOptions = {}\n): string {\n const { locale = 'en-US', timeZone } = options;\n\n // Convert to ZonedDateTime, applying custom timezone if provided\n let zonedDateTime: Temporal.ZonedDateTime;\n if (timeZone) {\n // If custom timezone specified, convert via Instant\n const instant = isInstant(input) ? input : input.toInstant();\n zonedDateTime = instant.toZonedDateTimeISO(timeZone);\n } else {\n // No custom timezone: normalize to ZonedDateTime (Instant -> UTC, ZonedDateTime -> keep as-is)\n zonedDateTime = normalizeTemporalInput(input);\n }\n\n let result = '';\n let i = 0;\n const len = formatStr.length;\n\n while (i < len) {\n const char = formatStr[i];\n if (!char) break;\n\n // Handle escaped text\n if (char === \"'\") {\n // Check for double single quote (not inside a string, just '')\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n continue;\n }\n // Find closing quote, handling '' inside the string\n i++;\n while (i < len) {\n if (formatStr[i] === \"'\") {\n // Check if it's a doubled quote ''\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n } else {\n // End of quoted string\n i++;\n break;\n }\n } else {\n result += formatStr[i];\n i++;\n }\n }\n continue;\n }\n\n // Check for tokens by looking ahead\n const token = consumeToken(formatStr, i, char);\n if (token !== null) {\n result += formatToken(token, zonedDateTime, locale);\n i += token.length;\n } else {\n result += char;\n i++;\n }\n }\n\n return result;\n}\n\nfunction consumeToken(formatStr: string, start: number, char: string): string | null {\n // Special case for 'Mo' and 'do' - these end with 'o'\n if (char === 'M' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'Mo';\n }\n if (char === 'd' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'do';\n }\n\n // Count how many consecutive identical characters\n let end = start;\n while (end < formatStr.length && formatStr[end] === char) {\n end++;\n }\n const count = end - start;\n\n // Check if this is a valid token pattern\n const validTokens = [\n 'GGGGG',\n 'GGGG',\n 'GGG',\n 'GG',\n 'G',\n 'yyyy',\n 'yyy',\n 'yy',\n 'y',\n 'QQQQQ',\n 'QQQQ',\n 'QQQ',\n 'QQ',\n 'Q',\n 'MMMMM',\n 'MMMM',\n 'MMM',\n 'MM',\n 'M',\n 'dd',\n 'd',\n 'EEEEEE',\n 'EEEEE',\n 'EEEE',\n 'EEE',\n 'EE',\n 'E',\n 'aaaaa',\n 'aaaa',\n 'aaa',\n 'aa',\n 'a',\n 'HH',\n 'H',\n 'hh',\n 'h',\n 'mm',\n 'm',\n 'ss',\n 's',\n 'SSS',\n 'SS',\n 'S',\n 'XXXXX',\n 'XXXX',\n 'XXX',\n 'XX',\n 'X',\n 'xxxxx',\n 'xxxx',\n 'xxx',\n 'xx',\n 'x',\n 'zzzz',\n 'zzz',\n 'zz',\n 'z',\n 'T',\n 't',\n ];\n\n // Try to match from longest to shortest\n for (let len = Math.min(count, 6); len > 0; len--) {\n const candidate = char.repeat(len);\n if (validTokens.includes(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nfunction formatToken(token: string, zonedDateTime: Temporal.ZonedDateTime, locale: string): string {\n switch (token) {\n // Era\n case 'GGGGG':\n return formatPart(zonedDateTime, 'era', 'narrow', locale);\n case 'GGGG':\n return formatPart(zonedDateTime, 'era', 'long', locale);\n case 'GGG':\n case 'GG':\n case 'G':\n return formatPart(zonedDateTime, 'era', 'short', locale);\n\n // Year\n case 'yyyy':\n return zonedDateTime.year.toString().padStart(4, '0');\n case 'yyy':\n return zonedDateTime.year.toString().padStart(3, '0');\n case 'yy':\n return (zonedDateTime.year % 100).toString().padStart(2, '0');\n case 'y':\n return zonedDateTime.year.toString();\n\n // Quarter\n case 'QQQQQ':\n return Math.ceil(zonedDateTime.month / 3).toString();\n case 'QQQQ': {\n const quarter = Math.ceil(zonedDateTime.month / 3);\n return `${quarter}${getOrdinalSuffix(quarter)} quarter`;\n }\n case 'QQQ':\n return `Q${Math.ceil(zonedDateTime.month / 3)}`;\n case 'QQ':\n return Math.ceil(zonedDateTime.month / 3)\n .toString()\n .padStart(2, '0');\n case 'Q':\n return Math.ceil(zonedDateTime.month / 3).toString();\n\n // Month\n case 'MMMMM':\n return formatPart(zonedDateTime, 'month', 'narrow', locale);\n case 'MMMM':\n return formatPart(zonedDateTime, 'month', 'long', locale);\n case 'MMM':\n return formatPart(zonedDateTime, 'month', 'short', locale);\n case 'MM':\n return zonedDateTime.month.toString().padStart(2, '0');\n case 'Mo':\n return `${zonedDateTime.month}${getOrdinalSuffix(zonedDateTime.month)}`;\n case 'M':\n return zonedDateTime.month.toString();\n\n // Day of month\n case 'do':\n return `${zonedDateTime.day}${getOrdinalSuffix(zonedDateTime.day)}`;\n case 'dd':\n return zonedDateTime.day.toString().padStart(2, '0');\n case 'd':\n return zonedDateTime.day.toString();\n\n // Day of week\n case 'EEEEEE':\n return formatPart(zonedDateTime, 'weekday', 'short', locale).slice(0, 2);\n case 'EEEEE':\n return formatPart(zonedDateTime, 'weekday', 'narrow', locale);\n case 'EEEE':\n return formatPart(zonedDateTime, 'weekday', 'long', locale);\n case 'EEE':\n case 'EE':\n case 'E':\n return formatPart(zonedDateTime, 'weekday', 'short', locale);\n\n // AM/PM (locale-aware; English widths applied only for ASCII AM/PM)\n case 'aaaaa': {\n const period = getDayPeriod(zonedDateTime, locale);\n if (isAsciiAmPm(period)) return isAm(period) ? 'a' : 'p';\n return period.charAt(0).toLowerCase();\n }\n case 'aaaa': {\n const period = getDayPeriod(zonedDateTime, locale);\n if (isAsciiAmPm(period)) return isAm(period) ? 'a.m.' : 'p.m.';\n return period;\n }\n case 'aaa':\n return getDayPeriod(zonedDateTime, locale).toLowerCase();\n case 'aa':\n case 'a':\n return getDayPeriod(zonedDateTime, locale);\n\n // Hour [0-23]\n case 'HH':\n return zonedDateTime.hour.toString().padStart(2, '0');\n case 'H':\n return zonedDateTime.hour.toString();\n\n // Hour [1-12]\n case 'hh': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString().padStart(2, '0');\n }\n case 'h': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString();\n }\n\n // Minute\n case 'mm':\n return zonedDateTime.minute.toString().padStart(2, '0');\n case 'm':\n return zonedDateTime.minute.toString();\n\n // Second\n case 'ss':\n return zonedDateTime.second.toString().padStart(2, '0');\n case 's':\n return zonedDateTime.second.toString();\n\n // Fractional seconds\n case 'SSS':\n return zonedDateTime.millisecond.toString().padStart(3, '0');\n case 'SS':\n return Math.floor(zonedDateTime.millisecond / 10)\n .toString()\n .padStart(2, '0');\n case 'S':\n return Math.floor(zonedDateTime.millisecond / 100).toString();\n\n // Timezone\n case 'XXXXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XXXX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'XXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'X': {\n const offset = getTimezoneOffset(zonedDateTime); // \"+05:30\" / \"+00:00\"\n if (offset === '+00:00') return 'Z';\n const [hours, minutes] = offset.split(':');\n return minutes === '00' ? hours! : `${hours}${minutes}`;\n }\n case 'xxxxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xxxx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'xxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'x': {\n const offset = getTimezoneOffset(zonedDateTime); // \"+05:30\" / \"+00:00\"\n const [hours, minutes] = offset.split(':');\n return minutes === '00' ? hours! : `${hours}${minutes}`;\n }\n case 'zzzz':\n return formatPart(zonedDateTime, 'timeZoneName', 'long', locale);\n case 'zzz':\n case 'zz':\n case 'z':\n return formatPart(zonedDateTime, 'timeZoneName', 'short', locale);\n\n // Timestamps\n case 'T':\n return zonedDateTime.epochMilliseconds.toString();\n case 't':\n return Math.floor(zonedDateTime.epochMilliseconds / 1000).toString();\n\n default:\n return token;\n }\n}\n\nfunction formatPart(\n zonedDateTime: Temporal.ZonedDateTime,\n part: 'era' | 'year' | 'month' | 'weekday' | 'day' | 'hour' | 'minute' | 'second' | 'timeZoneName',\n style: 'narrow' | 'short' | 'long' | 'numeric' | '2-digit',\n locale: string\n): string {\n const options: Intl.DateTimeFormatOptions = {};\n options[part] = style as any;\n return zonedDateTime.toLocaleString(locale, options);\n}\n\nfunction getOrdinalSuffix(num: number): string {\n const j = num % 10;\n const k = num % 100;\n if (j === 1 && k !== 11) return 'st';\n if (j === 2 && k !== 12) return 'nd';\n if (j === 3 && k !== 13) return 'rd';\n return 'th';\n}\n\nfunction getTimezoneOffset(zonedDateTime: Temporal.ZonedDateTime): string {\n const offsetNs = zonedDateTime.offsetNanoseconds;\n const offsetMinutes = offsetNs / (60 * 1e9);\n const sign = offsetMinutes >= 0 ? '+' : '-';\n const absMinutes = Math.abs(offsetMinutes);\n const hours = Math.floor(absMinutes / 60);\n const minutes = absMinutes % 60;\n return `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n}\n\n/**\n * Locale-correct day period (AM/PM equivalent) via Intl.formatToParts.\n * Returns the locale's own value, e.g. \"AM\"/\"PM\" (en), \"p. m.\" (es), \"午後\" (ja).\n */\nfunction getDayPeriod(zonedDateTime: Temporal.ZonedDateTime, locale: string): string {\n const parts = new Intl.DateTimeFormat(locale, {\n hour: 'numeric',\n hour12: true,\n timeZone: zonedDateTime.timeZoneId,\n }).formatToParts(new Date(zonedDateTime.epochMilliseconds));\n return parts.find((p) => p.type === 'dayPeriod')?.value ?? '';\n}\n\n/** True when the day-period is recognizably ASCII AM/PM (so English widths apply). */\nfunction isAsciiAmPm(period: string): boolean {\n const normalized = period.toUpperCase().replace(/[.\\s]/g, '');\n return normalized === 'AM' || normalized === 'PM';\n}\n\n/** True for the AM half (only meaningful when isAsciiAmPm is true). */\nfunction isAm(period: string): boolean {\n return period.toUpperCase().replace(/[.\\s]/g, '').startsWith('A');\n}\n"],"mappings":";;;;;;;;AAgCO,SAAS,OACd,OACA,WACA,UAAyB,CAAC,GAClB;AACR,QAAM,EAAE,SAAS,SAAS,SAAS,IAAI;AAGvC,MAAI;AACJ,MAAI,UAAU;AAEZ,UAAM,UAAU,UAAU,KAAK,IAAI,QAAQ,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IAAI,KAAK,eAAe,QAAQ;AAAA,IAC5C,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU,cAAc;AAAA,EAC1B,CAAC,EAAE,cAAc,IAAI,KAAK,cAAc,iBAAiB,CAAC;AAC1D,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,WAAW,GAAG,SAAS;AAC7D;AAGA,SAAS,YAAY,QAAyB;AAC5C,QAAM,aAAa,OAAO,YAAY,EAAE,QAAQ,UAAU,EAAE;AAC5D,SAAO,eAAe,QAAQ,eAAe;AAC/C;AAGA,SAAS,KAAK,QAAyB;AACrC,SAAO,OAAO,YAAY,EAAE,QAAQ,UAAU,EAAE,EAAE,WAAW,GAAG;AAClE;","names":[]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isInstant
|
|
3
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
|
+
|
|
1
5
|
// src/toDate.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
6
|
function toDate(input) {
|
|
4
|
-
if (input
|
|
7
|
+
if (isInstant(input)) {
|
|
5
8
|
return new Date(input.toString());
|
|
6
9
|
}
|
|
7
10
|
return new Date(input.toInstant().toString());
|
|
@@ -10,4 +13,4 @@ function toDate(input) {
|
|
|
10
13
|
export {
|
|
11
14
|
toDate
|
|
12
15
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-T6ONGPRF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toDate.ts"],"sourcesContent":["import { isInstant } from './shared/temporal';\nimport type { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a Temporal.Instant or ZonedDateTime to a Date object.\n *\n * @param input - A Temporal.Instant or Temporal.ZonedDateTime\n * @returns A Date object representing the same moment in time\n *\n * @example\n * ```typescript\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const date = toDate(instant);\n * // date.toISOString() === \"2025-01-20T20:00:00.000Z\"\n *\n * // From ZonedDateTime\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const date2 = toDate(zoned);\n * // date2.toISOString() === \"2025-01-20T20:00:00.000Z\"\n *\n * // Use with Drizzle ORM (for storing back to database)\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const date = toDate(instant);\n * await db.update(posts).set({ publishedAt: date });\n * ```\n */\nexport function toDate(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Date {\n if (isInstant(input)) {\n return new Date(input.toString());\n }\n\n return new Date(input.toInstant().toString());\n}\n"],"mappings":";;;;;AA2BO,SAAS,OACd,OACM;AACN,MAAI,UAAU,KAAK,GAAG;AACpB,WAAO,IAAI,KAAK,MAAM,SAAS,CAAC;AAAA,EAClC;AAEA,SAAO,IAAI,KAAK,MAAM,UAAU,EAAE,SAAS,CAAC;AAC9C;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeTemporalInput
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F6EWMA4K.js";
|
|
4
4
|
|
|
5
5
|
// src/isSameMicrosecond.ts
|
|
6
6
|
function isSameMicrosecond(date1, date2) {
|
|
@@ -12,4 +12,4 @@ function isSameMicrosecond(date1, date2) {
|
|
|
12
12
|
export {
|
|
13
13
|
isSameMicrosecond
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
//# sourceMappingURL=chunk-TDZ3XUH7.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeTemporalInput
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F6EWMA4K.js";
|
|
4
|
+
import {
|
|
5
|
+
Temporal
|
|
6
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
7
|
|
|
5
8
|
// src/eachMinuteOfInterval.ts
|
|
6
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
7
9
|
function eachMinuteOfInterval(interval) {
|
|
8
10
|
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
11
|
const endZoned = normalizeTemporalInput(interval.end);
|
|
@@ -23,4 +25,4 @@ function eachMinuteOfInterval(interval) {
|
|
|
23
25
|
export {
|
|
24
26
|
eachMinuteOfInterval
|
|
25
27
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-TIEAKS3O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachMinuteOfInterval.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each minute within the interval.\n * Each element represents the start of the minute (seconds/etc. set to 0).\n * The interval is inclusive of both start and end minutes.\n *\n * For Instant inputs, UTC is used as the timezone.\n * For ZonedDateTime inputs, the timezone of the start date is preserved.\n *\n * Warning: Large intervals can produce very large arrays. For example, a 24-hour\n * interval produces 1,441 elements. Consider whether this is appropriate for your use case.\n *\n * @param interval - The interval with start and end datetimes\n * @returns Array of ZonedDateTime at start of each minute in the interval\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2025-01-06T10:30:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-06T10:33:45Z[UTC]');\n *\n * const minutes = eachMinuteOfInterval({ start, end });\n * // [\n * // 2025-01-06T10:30:00Z[UTC],\n * // 2025-01-06T10:31:00Z[UTC],\n * // 2025-01-06T10:32:00Z[UTC],\n * // 2025-01-06T10:33:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Cross-hour boundary\n * const start = Temporal.ZonedDateTime.from('2025-01-06T10:58:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-06T11:02:00Z[UTC]');\n *\n * const minutes = eachMinuteOfInterval({ start, end });\n * // [\n * // 2025-01-06T10:58:00Z[UTC],\n * // 2025-01-06T10:59:00Z[UTC],\n * // 2025-01-06T11:00:00Z[UTC],\n * // 2025-01-06T11:01:00Z[UTC],\n * // 2025-01-06T11:02:00Z[UTC]\n * // ]\n * ```\n */\nexport function eachMinuteOfInterval(interval: {\n start: Temporal.Instant | Temporal.ZonedDateTime;\n end: Temporal.Instant | Temporal.ZonedDateTime;\n}): Temporal.ZonedDateTime[] {\n const startZoned = normalizeTemporalInput(interval.start);\n const endZoned = normalizeTemporalInput(interval.end);\n\n const timezone = startZoned.timeZoneId;\n\n // Get start of the starting minute\n const startMinute = startZoned.round({ smallestUnit: 'minute', roundingMode: 'floor' });\n\n // Get start of the ending minute in the same timezone\n const endInTimezone = endZoned.withTimeZone(timezone);\n const endMinute = endInTimezone.round({ smallestUnit: 'minute', roundingMode: 'floor' });\n\n const minutes: Temporal.ZonedDateTime[] = [];\n let current = startMinute;\n\n while (Temporal.ZonedDateTime.compare(current, endMinute) <= 0) {\n minutes.push(current);\n current = current.add({ minutes: 1 });\n }\n\n return minutes;\n}\n"],"mappings":";;;;;;;;AA+CO,SAAS,qBAAqB,UAGR;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAG5B,QAAM,cAAc,WAAW,MAAM,EAAE,cAAc,UAAU,cAAc,QAAQ,CAAC;AAGtF,QAAM,gBAAgB,SAAS,aAAa,QAAQ;AACpD,QAAM,YAAY,cAAc,MAAM,EAAE,cAAc,UAAU,cAAc,QAAQ,CAAC;AAEvF,QAAM,UAAoC,CAAC;AAC3C,MAAI,UAAU;AAEd,SAAO,SAAS,cAAc,QAAQ,SAAS,SAAS,KAAK,GAAG;AAC9D,YAAQ,KAAK,OAAO;AACpB,cAAU,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC;AAAA,EACtC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isInstant
|
|
3
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
|
+
|
|
1
5
|
// src/toIso9075.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
6
|
function toIso9075(input, options = {}) {
|
|
4
7
|
const { mode = "utc", representation = "complete" } = options;
|
|
5
8
|
let zdt;
|
|
6
|
-
if (input
|
|
9
|
+
if (isInstant(input)) {
|
|
7
10
|
zdt = input.toZonedDateTimeISO("UTC");
|
|
8
11
|
} else {
|
|
9
12
|
zdt = mode === "utc" ? input.toInstant().toZonedDateTimeISO("UTC") : input;
|
|
@@ -27,4 +30,4 @@ function pad(n) {
|
|
|
27
30
|
export {
|
|
28
31
|
toIso9075
|
|
29
32
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
//# sourceMappingURL=chunk-U7ZWIAB3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toIso9075.ts"],"sourcesContent":["import { isInstant } from './shared/temporal';\nimport type { Temporal } from '@js-temporal/polyfill';\n\nexport type Iso9075Mode = 'utc' | 'local';\nexport type Iso9075Representation = 'complete' | 'date' | 'time';\n\nexport interface ToIso9075Options {\n /**\n * Which time to output.\n * - 'utc' (default): convert to UTC before formatting\n * - 'local': use the local time of the ZonedDateTime\n */\n mode?: Iso9075Mode;\n /**\n * What to include in the output.\n * - 'complete' (default): date and time (2019-09-18 19:00:52)\n * - 'date': date only (2019-09-18)\n * - 'time': time only (19:00:52)\n */\n representation?: Iso9075Representation;\n}\n\n/**\n * Convert a Temporal.Instant to an ISO 9075 (SQL) formatted string in UTC.\n */\nexport function toIso9075(\n input: Temporal.Instant,\n options?: Omit<ToIso9075Options, 'mode'>\n): string;\n\n/**\n * Convert a Temporal.ZonedDateTime to an ISO 9075 (SQL) formatted string.\n *\n * @param input - A Temporal.ZonedDateTime\n * @param options - Format options\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * toIso9075(zoned); // \"2025-01-20 20:00:00\" (UTC, default)\n * toIso9075(zoned, { mode: 'utc' }); // \"2025-01-20 20:00:00\"\n * toIso9075(zoned, { mode: 'local' }); // \"2025-01-20 15:00:00\"\n * toIso9075(zoned, { representation: 'date' }); // \"2025-01-20\"\n * toIso9075(zoned, { representation: 'time' }); // \"20:00:00\"\n * ```\n */\nexport function toIso9075(\n input: Temporal.ZonedDateTime,\n options?: ToIso9075Options\n): string;\n\nexport function toIso9075(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options: ToIso9075Options = {}\n): string {\n const { mode = 'utc', representation = 'complete' } = options;\n\n let zdt: Temporal.ZonedDateTime;\n\n if (isInstant(input)) {\n zdt = input.toZonedDateTimeISO('UTC');\n } else {\n // ZonedDateTime: apply mode\n zdt = mode === 'utc' ? input.toInstant().toZonedDateTimeISO('UTC') : input;\n }\n\n const year = zdt.year;\n const month = zdt.month;\n const day = zdt.day;\n const hour = zdt.hour;\n const minute = zdt.minute;\n const second = zdt.second;\n\n const datePart = `${year}-${pad(month)}-${pad(day)}`;\n const timePart = `${pad(hour)}:${pad(minute)}:${pad(second)}`;\n\n if (representation === 'date') return datePart;\n if (representation === 'time') return timePart;\n return `${datePart} ${timePart}`;\n}\n\nfunction pad(n: number): string {\n return n.toString().padStart(2, '0');\n}\n"],"mappings":";;;;;AAoDO,SAAS,UACd,OACA,UAA4B,CAAC,GACrB;AACR,QAAM,EAAE,OAAO,OAAO,iBAAiB,WAAW,IAAI;AAEtD,MAAI;AAEJ,MAAI,UAAU,KAAK,GAAG;AACpB,UAAM,MAAM,mBAAmB,KAAK;AAAA,EACtC,OAAO;AAEL,UAAM,SAAS,QAAQ,MAAM,UAAU,EAAE,mBAAmB,KAAK,IAAI;AAAA,EACvE;AAEA,QAAM,OAAO,IAAI;AACjB,QAAM,QAAQ,IAAI;AAClB,QAAM,MAAM,IAAI;AAChB,QAAM,OAAO,IAAI;AACjB,QAAM,SAAS,IAAI;AACnB,QAAM,SAAS,IAAI;AAEnB,QAAM,WAAW,GAAG,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC;AAClD,QAAM,WAAW,GAAG,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC;AAE3D,MAAI,mBAAmB,OAAQ,QAAO;AACtC,MAAI,mBAAmB,OAAQ,QAAO;AACtC,SAAO,GAAG,QAAQ,IAAI,QAAQ;AAChC;AAEA,SAAS,IAAI,GAAmB;AAC9B,SAAO,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AACrC;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/shared/temporal.ts
|
|
2
|
+
var Temporal = globalThis.Temporal ?? (await import("@js-temporal/polyfill")).Temporal;
|
|
3
|
+
function brand(value) {
|
|
4
|
+
return typeof value === "object" && value !== null ? value[Symbol.toStringTag] : void 0;
|
|
5
|
+
}
|
|
6
|
+
function isInstant(value) {
|
|
7
|
+
return brand(value) === "Temporal.Instant";
|
|
8
|
+
}
|
|
9
|
+
function isZonedDateTime(value) {
|
|
10
|
+
return brand(value) === "Temporal.ZonedDateTime";
|
|
11
|
+
}
|
|
12
|
+
function isPlainDate(value) {
|
|
13
|
+
return brand(value) === "Temporal.PlainDate";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Temporal,
|
|
18
|
+
isInstant,
|
|
19
|
+
isZonedDateTime,
|
|
20
|
+
isPlainDate
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-VOZTLX5F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/temporal.ts"],"sourcesContent":["import type { Temporal as TemporalNamespace } from '@js-temporal/polyfill';\n\n/**\n * @internal\n * Single source of the Temporal implementation.\n *\n * Prefers the runtime's native `globalThis.Temporal` (Node 26+, Chrome 144+,\n * Firefox 139+, Edge, Deno) and dynamically loads `@js-temporal/polyfill` only\n * when native Temporal is absent (Safari, Node <= 25). On native runtimes the\n * polyfill is never imported or executed.\n *\n * Do not import the polyfill directly anywhere else in src/ — import `Temporal`\n * from this module so the runtime choice stays in one place.\n */\nexport const Temporal: typeof TemporalNamespace =\n (globalThis as { Temporal?: typeof TemporalNamespace }).Temporal ??\n (await import('@js-temporal/polyfill')).Temporal;\n\n/**\n * @internal\n * Merge the resolved value with the polyfill's `Temporal` type namespace so a\n * single `import { Temporal }` serves both runtime construction\n * (`Temporal.Instant.from(...)`) and type annotations (`Temporal.Instant`),\n * exactly like importing `Temporal` directly from the polyfill used to.\n */\nexport namespace Temporal {\n export type Instant = TemporalNamespace.Instant;\n export type ZonedDateTime = TemporalNamespace.ZonedDateTime;\n export type PlainDate = TemporalNamespace.PlainDate;\n export type PlainTime = TemporalNamespace.PlainTime;\n export type PlainDateTime = TemporalNamespace.PlainDateTime;\n export type PlainYearMonth = TemporalNamespace.PlainYearMonth;\n export type PlainMonthDay = TemporalNamespace.PlainMonthDay;\n export type Duration = TemporalNamespace.Duration;\n export type PlainTimeLike = TemporalNamespace.PlainTimeLike;\n export type PlainDateLike = TemporalNamespace.PlainDateLike;\n}\n\n/**\n * @internal\n * Implementation-agnostic type guards.\n *\n * `instanceof` is identity-based and fails across implementations. The Temporal\n * spec requires every implementation to set `Symbol.toStringTag`, so brand\n * checks work regardless of which implementation produced the object.\n */\nfunction brand(value: unknown): string | undefined {\n return typeof value === 'object' && value !== null\n ? (value as { [Symbol.toStringTag]?: string })[Symbol.toStringTag]\n : undefined;\n}\n\nexport function isInstant(value: unknown): value is TemporalNamespace.Instant {\n return brand(value) === 'Temporal.Instant';\n}\n\nexport function isZonedDateTime(\n value: unknown\n): value is TemporalNamespace.ZonedDateTime {\n return brand(value) === 'Temporal.ZonedDateTime';\n}\n\nexport function isPlainDate(\n value: unknown\n): value is TemporalNamespace.PlainDate {\n return brand(value) === 'Temporal.PlainDate';\n}\n"],"mappings":";AAcO,IAAM,WACV,WAAuD,aACvD,MAAM,OAAO,uBAAuB,GAAG;AA8B1C,SAAS,MAAM,OAAoC;AACjD,SAAO,OAAO,UAAU,YAAY,UAAU,OACzC,MAA4C,OAAO,WAAW,IAC/D;AACN;AAEO,SAAS,UAAU,OAAoD;AAC5E,SAAO,MAAM,KAAK,MAAM;AAC1B;AAEO,SAAS,gBACd,OAC0C;AAC1C,SAAO,MAAM,KAAK,MAAM;AAC1B;AAEO,SAAS,YACd,OACsC;AACtC,SAAO,MAAM,KAAK,MAAM;AAC1B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addHours
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DJRIH2PX.js";
|
|
4
4
|
|
|
5
5
|
// src/subHours.ts
|
|
6
6
|
function subHours(input, hours) {
|
|
@@ -10,4 +10,4 @@ function subHours(input, hours) {
|
|
|
10
10
|
export {
|
|
11
11
|
subHours
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-VVV5BNLP.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/shared/differenceInMilliseconds.ts
|
|
2
|
-
import "@js-temporal/polyfill";
|
|
3
2
|
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
4
3
|
return laterDate.epochMilliseconds - earlierDate.epochMilliseconds;
|
|
5
4
|
}
|
|
@@ -7,4 +6,4 @@ function differenceInMilliseconds(laterDate, earlierDate) {
|
|
|
7
6
|
export {
|
|
8
7
|
differenceInMilliseconds
|
|
9
8
|
};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-VXOQ7IG5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/differenceInMilliseconds.ts"],"sourcesContent":["import { Temporal } from './temporal';\n\nexport function differenceInMilliseconds(\n laterDate: Temporal.ZonedDateTime,\n earlierDate: Temporal.ZonedDateTime\n): number {\n return laterDate.epochMilliseconds - earlierDate.epochMilliseconds;\n}\n"],"mappings":";AAEO,SAAS,yBACd,WACA,aACQ;AACR,SAAO,UAAU,oBAAoB,YAAY;AACnD;","names":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeWithPlainDate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y4HT4LCB.js";
|
|
4
4
|
import {
|
|
5
5
|
getEndOfDay
|
|
6
6
|
} from "./chunk-AVGNRINZ.js";
|
|
7
7
|
|
|
8
8
|
// src/endOfDay.ts
|
|
9
|
-
import "@js-temporal/polyfill";
|
|
10
9
|
function endOfDay(input, timezone) {
|
|
11
10
|
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
12
11
|
return getEndOfDay(zonedDateTime);
|
|
@@ -15,4 +14,4 @@ function endOfDay(input, timezone) {
|
|
|
15
14
|
export {
|
|
16
15
|
endOfDay
|
|
17
16
|
};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-W6RF44CV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/endOfDay.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport type { Timezone } from './types';\nimport { getEndOfDay } from './shared/endOfDay';\nimport { normalizeWithPlainDate } from './shared/normalizeWithPlainDate';\n\n/**\n * Returns a ZonedDateTime representing the last nanosecond of the day.\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @returns ZonedDateTime at 23:59:59.999999999\n *\n * @example\n * ```ts\n * // From Instant (always UTC)\n * const instant = Temporal.Instant.from('2025-01-20T12:00:00Z');\n * const end = endOfDay(instant);\n * // 2025-01-20T23:59:59.999999999Z[UTC]\n * ```\n *\n * @example\n * ```ts\n * // From ZonedDateTime (uses its timezone)\n * const zoned = Temporal.ZonedDateTime.from('2025-01-20T15:30:00-05:00[America/New_York]');\n * const end = endOfDay(zoned);\n * // 2025-01-20T23:59:59.999999999-05:00[America/New_York]\n * ```\n *\n * @example\n * ```ts\n * // From PlainDate (requires timezone)\n * const date = Temporal.PlainDate.from('2025-01-20');\n * const end = endOfDay(date, 'America/New_York');\n * // 2025-01-20T23:59:59.999999999-05:00[America/New_York]\n * ```\n */\nexport function endOfDay(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function endOfDay(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function endOfDay(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeWithPlainDate(input, timezone!);\n return getEndOfDay(zonedDateTime);\n}\n"],"mappings":";;;;;;;;AA0CO,SAAS,SACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,SAAO,YAAY,aAAa;AAClC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addYears
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5HVHKQTJ.js";
|
|
4
4
|
|
|
5
5
|
// src/subYears.ts
|
|
6
6
|
function subYears(input, years) {
|
|
@@ -10,4 +10,4 @@ function subYears(input, years) {
|
|
|
10
10
|
export {
|
|
11
11
|
subYears
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-WJOGQ6IB.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
differenceInMonths
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HHPXUFZP.js";
|
|
4
4
|
import {
|
|
5
5
|
differenceInSeconds
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZBEEQUE4.js";
|
|
7
7
|
import {
|
|
8
8
|
differenceInWeeks
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AAORAX74.js";
|
|
10
10
|
import {
|
|
11
11
|
differenceInYears
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QPGTY5DD.js";
|
|
13
13
|
import {
|
|
14
14
|
differenceInDays
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ESTLMF2X.js";
|
|
16
16
|
import {
|
|
17
17
|
differenceInHours
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ERCE3YCO.js";
|
|
19
19
|
import {
|
|
20
20
|
differenceInMinutes
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JVB5IARQ.js";
|
|
22
22
|
import {
|
|
23
23
|
normalizeTemporalInput
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-F6EWMA4K.js";
|
|
25
25
|
|
|
26
26
|
// src/intlFormatDistance.ts
|
|
27
27
|
function intlFormatDistance(laterDate, earlierDate, options) {
|
|
@@ -32,9 +32,9 @@ function intlFormatDistance(laterDate, earlierDate, options) {
|
|
|
32
32
|
const absSeconds = Math.abs(differenceInSeconds(zoned1, zoned2));
|
|
33
33
|
const absMinutes = Math.abs(differenceInMinutes(zoned1, zoned2));
|
|
34
34
|
const absHours = Math.abs(differenceInHours(zoned1, zoned2));
|
|
35
|
-
const absDays = Math.abs(differenceInDays(zoned1, zoned2));
|
|
36
|
-
const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2));
|
|
37
|
-
const absMonths = Math.abs(differenceInMonths(zoned1, zoned2));
|
|
35
|
+
const absDays = Math.abs(differenceInDays(zoned1, zoned2, { fractional: true }));
|
|
36
|
+
const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2, { fractional: true }));
|
|
37
|
+
const absMonths = Math.abs(differenceInMonths(zoned1, zoned2, { fractional: true }));
|
|
38
38
|
if (absSeconds < 60) {
|
|
39
39
|
unit = "second";
|
|
40
40
|
} else if (absMinutes < 60) {
|
|
@@ -62,20 +62,21 @@ function intlFormatDistance(laterDate, earlierDate, options) {
|
|
|
62
62
|
case "hour":
|
|
63
63
|
value = Math.round(differenceInHours(zoned1, zoned2));
|
|
64
64
|
break;
|
|
65
|
+
// calendar units were fractional pre-2.x; sub-day units stay truncated so Math.round is a no-op
|
|
65
66
|
case "day":
|
|
66
|
-
value = Math.round(differenceInDays(zoned1, zoned2));
|
|
67
|
+
value = Math.round(differenceInDays(zoned1, zoned2, { fractional: true }));
|
|
67
68
|
break;
|
|
68
69
|
case "week":
|
|
69
|
-
value = Math.round(differenceInWeeks(zoned1, zoned2));
|
|
70
|
+
value = Math.round(differenceInWeeks(zoned1, zoned2, { fractional: true }));
|
|
70
71
|
break;
|
|
71
72
|
case "month":
|
|
72
|
-
value = Math.round(differenceInMonths(zoned1, zoned2));
|
|
73
|
+
value = Math.round(differenceInMonths(zoned1, zoned2, { fractional: true }));
|
|
73
74
|
break;
|
|
74
75
|
case "quarter":
|
|
75
|
-
value = Math.round(differenceInMonths(zoned1, zoned2) / 3);
|
|
76
|
+
value = Math.round(differenceInMonths(zoned1, zoned2, { fractional: true }) / 3);
|
|
76
77
|
break;
|
|
77
78
|
case "year":
|
|
78
|
-
value = Math.round(differenceInYears(zoned1, zoned2));
|
|
79
|
+
value = Math.round(differenceInYears(zoned1, zoned2, { fractional: true }));
|
|
79
80
|
break;
|
|
80
81
|
default:
|
|
81
82
|
value = Math.round(differenceInSeconds(zoned1, zoned2));
|
|
@@ -91,4 +92,4 @@ function intlFormatDistance(laterDate, earlierDate, options) {
|
|
|
91
92
|
export {
|
|
92
93
|
intlFormatDistance
|
|
93
94
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-WLW622M7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/intlFormatDistance.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { differenceInDays } from './differenceInDays.js';\nimport { differenceInHours } from './differenceInHours.js';\nimport { differenceInMinutes } from './differenceInMinutes.js';\nimport { differenceInMonths } from './differenceInMonths.js';\nimport { differenceInSeconds } from './differenceInSeconds.js';\nimport { differenceInWeeks } from './differenceInWeeks.js';\nimport { differenceInYears } from './differenceInYears.js';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput.js';\n\nexport interface IntlFormatDistanceOptions {\n /**\n * The unit to force formatting in. If not specified, the unit will be automatically selected.\n */\n unit?: Intl.RelativeTimeFormatUnit;\n /**\n * The locale to use for formatting. Defaults to the system locale.\n */\n locale?: string | string[];\n /**\n * The locale matching algorithm to use.\n */\n localeMatcher?: 'best fit' | 'lookup';\n /**\n * Whether to use numeric values always, or use special strings like \"yesterday\", \"tomorrow\", etc.\n * Defaults to 'auto'.\n */\n numeric?: 'always' | 'auto';\n /**\n * The formatting style to use.\n */\n style?: 'long' | 'short' | 'narrow';\n}\n\n/**\n * Formats the distance between two dates as a human-readable, internationalized string.\n *\n * The function automatically picks the most appropriate unit based on the distance between dates.\n * For example, if the distance is a few hours, it returns \"in X hours\". If the distance is a few\n * months, it returns \"in X months\".\n *\n * You can force a specific unit using the `options.unit` parameter.\n *\n * @param laterDate - The later date to compare\n * @param earlierDate - The earlier date to compare with\n * @param options - Formatting options\n * @returns The formatted distance string\n *\n * @example\n * ```typescript\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier);\n * // => 'in 1 hour'\n *\n * intlFormatDistance(earlier, later);\n * // => '1 hour ago'\n * ```\n *\n * @example\n * ```typescript\n * // Force a specific unit\n * const later = Temporal.Instant.from('2025-01-01T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { unit: 'quarter' });\n * // => 'in 4 quarters'\n * ```\n *\n * @example\n * ```typescript\n * // Use a different locale\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier, { locale: 'es' });\n * // => 'dentro de 1 hora'\n * ```\n *\n * @example\n * ```typescript\n * // Use numeric: 'always' to avoid special strings\n * const later = Temporal.Instant.from('2024-01-02T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { numeric: 'auto' });\n * // => 'tomorrow'\n *\n * intlFormatDistance(later, earlier, { numeric: 'always' });\n * // => 'in 1 day'\n * ```\n */\nexport function intlFormatDistance(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime,\n options?: IntlFormatDistanceOptions\n): string {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n // Determine unit if not specified\n let unit = options?.unit;\n if (!unit) {\n const absSeconds = Math.abs(differenceInSeconds(zoned1, zoned2));\n const absMinutes = Math.abs(differenceInMinutes(zoned1, zoned2));\n const absHours = Math.abs(differenceInHours(zoned1, zoned2));\n const absDays = Math.abs(differenceInDays(zoned1, zoned2));\n const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2));\n const absMonths = Math.abs(differenceInMonths(zoned1, zoned2));\n\n if (absSeconds < 60) {\n unit = 'second';\n } else if (absMinutes < 60) {\n unit = 'minute';\n } else if (absHours < 24) {\n unit = 'hour';\n } else if (absDays < 7) {\n unit = 'day';\n } else if (absWeeks < 4) {\n unit = 'week';\n } else if (absMonths < 12) {\n unit = 'month';\n } else {\n unit = 'year';\n }\n }\n\n // Calculate value for the selected unit\n let value: number;\n switch (unit) {\n case 'second':\n value = Math.round(differenceInSeconds(zoned1, zoned2));\n break;\n case 'minute':\n value = Math.round(differenceInMinutes(zoned1, zoned2));\n break;\n case 'hour':\n value = Math.round(differenceInHours(zoned1, zoned2));\n break;\n case 'day':\n value = Math.round(differenceInDays(zoned1, zoned2));\n break;\n case 'week':\n value = Math.round(differenceInWeeks(zoned1, zoned2));\n break;\n case 'month':\n value = Math.round(differenceInMonths(zoned1, zoned2));\n break;\n case 'quarter':\n value = Math.round(differenceInMonths(zoned1, zoned2) / 3);\n break;\n case 'year':\n value = Math.round(differenceInYears(zoned1, zoned2));\n break;\n default:\n // For any other unit type, try to use it directly\n value = Math.round(differenceInSeconds(zoned1, zoned2));\n }\n\n // Format using Intl.RelativeTimeFormat\n const formatter = new Intl.RelativeTimeFormat(options?.locale, {\n localeMatcher: options?.localeMatcher,\n numeric: options?.numeric ?? 'auto',\n style: options?.style,\n });\n\n return formatter.format(value, unit);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6FO,SAAS,mBACd,WACA,aACA,SACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAGjD,MAAI,OAAO,SAAS;AACpB,MAAI,CAAC,MAAM;AACT,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,WAAW,KAAK,IAAI,kBAAkB,QAAQ,MAAM,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/intlFormatDistance.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { differenceInDays } from './differenceInDays.js';\nimport { differenceInHours } from './differenceInHours.js';\nimport { differenceInMinutes } from './differenceInMinutes.js';\nimport { differenceInMonths } from './differenceInMonths.js';\nimport { differenceInSeconds } from './differenceInSeconds.js';\nimport { differenceInWeeks } from './differenceInWeeks.js';\nimport { differenceInYears } from './differenceInYears.js';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput.js';\n\nexport interface IntlFormatDistanceOptions {\n /**\n * The unit to force formatting in. If not specified, the unit will be automatically selected.\n */\n unit?: Intl.RelativeTimeFormatUnit;\n /**\n * The locale to use for formatting. Defaults to the system locale.\n */\n locale?: string | string[];\n /**\n * The locale matching algorithm to use.\n */\n localeMatcher?: 'best fit' | 'lookup';\n /**\n * Whether to use numeric values always, or use special strings like \"yesterday\", \"tomorrow\", etc.\n * Defaults to 'auto'.\n */\n numeric?: 'always' | 'auto';\n /**\n * The formatting style to use.\n */\n style?: 'long' | 'short' | 'narrow';\n}\n\n/**\n * Formats the distance between two dates as a human-readable, internationalized string.\n *\n * The function automatically picks the most appropriate unit based on the distance between dates.\n * For example, if the distance is a few hours, it returns \"in X hours\". If the distance is a few\n * months, it returns \"in X months\".\n *\n * You can force a specific unit using the `options.unit` parameter.\n *\n * @param laterDate - The later date to compare\n * @param earlierDate - The earlier date to compare with\n * @param options - Formatting options\n * @returns The formatted distance string\n *\n * @example\n * ```typescript\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier);\n * // => 'in 1 hour'\n *\n * intlFormatDistance(earlier, later);\n * // => '1 hour ago'\n * ```\n *\n * @example\n * ```typescript\n * // Force a specific unit\n * const later = Temporal.Instant.from('2025-01-01T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { unit: 'quarter' });\n * // => 'in 4 quarters'\n * ```\n *\n * @example\n * ```typescript\n * // Use a different locale\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier, { locale: 'es' });\n * // => 'dentro de 1 hora'\n * ```\n *\n * @example\n * ```typescript\n * // Use numeric: 'always' to avoid special strings\n * const later = Temporal.Instant.from('2024-01-02T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { numeric: 'auto' });\n * // => 'tomorrow'\n *\n * intlFormatDistance(later, earlier, { numeric: 'always' });\n * // => 'in 1 day'\n * ```\n */\nexport function intlFormatDistance(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime,\n options?: IntlFormatDistanceOptions\n): string {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n // Determine unit if not specified\n let unit = options?.unit;\n if (!unit) {\n const absSeconds = Math.abs(differenceInSeconds(zoned1, zoned2));\n const absMinutes = Math.abs(differenceInMinutes(zoned1, zoned2));\n const absHours = Math.abs(differenceInHours(zoned1, zoned2));\n // calendar units were fractional pre-2.x; sub-day units stay truncated so Math.round below is a no-op\n const absDays = Math.abs(differenceInDays(zoned1, zoned2, { fractional: true }));\n const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2, { fractional: true }));\n const absMonths = Math.abs(differenceInMonths(zoned1, zoned2, { fractional: true }));\n\n if (absSeconds < 60) {\n unit = 'second';\n } else if (absMinutes < 60) {\n unit = 'minute';\n } else if (absHours < 24) {\n unit = 'hour';\n } else if (absDays < 7) {\n unit = 'day';\n } else if (absWeeks < 4) {\n unit = 'week';\n } else if (absMonths < 12) {\n unit = 'month';\n } else {\n unit = 'year';\n }\n }\n\n // Calculate value for the selected unit\n let value: number;\n switch (unit) {\n case 'second':\n value = Math.round(differenceInSeconds(zoned1, zoned2));\n break;\n case 'minute':\n value = Math.round(differenceInMinutes(zoned1, zoned2));\n break;\n case 'hour':\n value = Math.round(differenceInHours(zoned1, zoned2));\n break;\n // calendar units were fractional pre-2.x; sub-day units stay truncated so Math.round is a no-op\n case 'day':\n value = Math.round(differenceInDays(zoned1, zoned2, { fractional: true }));\n break;\n case 'week':\n value = Math.round(differenceInWeeks(zoned1, zoned2, { fractional: true }));\n break;\n case 'month':\n value = Math.round(differenceInMonths(zoned1, zoned2, { fractional: true }));\n break;\n case 'quarter':\n value = Math.round(differenceInMonths(zoned1, zoned2, { fractional: true }) / 3);\n break;\n case 'year':\n value = Math.round(differenceInYears(zoned1, zoned2, { fractional: true }));\n break;\n default:\n // For any other unit type, try to use it directly\n value = Math.round(differenceInSeconds(zoned1, zoned2));\n }\n\n // Format using Intl.RelativeTimeFormat\n const formatter = new Intl.RelativeTimeFormat(options?.locale, {\n localeMatcher: options?.localeMatcher,\n numeric: options?.numeric ?? 'auto',\n style: options?.style,\n });\n\n return formatter.format(value, unit);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6FO,SAAS,mBACd,WACA,aACA,SACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAGjD,MAAI,OAAO,SAAS;AACpB,MAAI,CAAC,MAAM;AACT,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,WAAW,KAAK,IAAI,kBAAkB,QAAQ,MAAM,CAAC;AAE3D,UAAM,UAAU,KAAK,IAAI,iBAAiB,QAAQ,QAAQ,EAAE,YAAY,KAAK,CAAC,CAAC;AAC/E,UAAM,WAAW,KAAK,IAAI,kBAAkB,QAAQ,QAAQ,EAAE,YAAY,KAAK,CAAC,CAAC;AACjF,UAAM,YAAY,KAAK,IAAI,mBAAmB,QAAQ,QAAQ,EAAE,YAAY,KAAK,CAAC,CAAC;AAEnF,QAAI,aAAa,IAAI;AACnB,aAAO;AAAA,IACT,WAAW,aAAa,IAAI;AAC1B,aAAO;AAAA,IACT,WAAW,WAAW,IAAI;AACxB,aAAO;AAAA,IACT,WAAW,UAAU,GAAG;AACtB,aAAO;AAAA,IACT,WAAW,WAAW,GAAG;AACvB,aAAO;AAAA,IACT,WAAW,YAAY,IAAI;AACzB,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAGA,MAAI;AACJ,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,cAAQ,KAA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Before.ts
|
|
9
|
-
import "@js-temporal/polyfill";
|
|
10
9
|
function isBefore2(date1, date2) {
|
|
11
10
|
const zoned1 = normalizeTemporalInput(date1);
|
|
12
11
|
const zoned2 = normalizeTemporalInput(date2);
|
|
@@ -16,4 +15,4 @@ function isBefore2(date1, date2) {
|
|
|
16
15
|
export {
|
|
17
16
|
isBefore2 as isBefore
|
|
18
17
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-WNPPRDN3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isBefore.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { isBefore as isBeforeInternal } from './shared/isBefore';\n\n/**\n * Returns true if the first datetime is before the second datetime.\n * Compares by the underlying instant (epoch time), not by calendar date/time.\n *\n * @param date1 - First datetime (Instant or ZonedDateTime)\n * @param date2 - Second datetime (Instant or ZonedDateTime)\n * @returns true if date1 is before date2, false otherwise\n *\n * @example\n * ```ts\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');\n * const later = Temporal.ZonedDateTime.from('2025-01-20T16:00:00-05:00[America/New_York]');\n *\n * isBefore(earlier, later); // true\n * isBefore(later, earlier); // false\n * isBefore(earlier, earlier); // false\n * ```\n *\n * @example\n * ```ts\n * // Works with Instant too\n * const instant1 = Temporal.Instant.from('2025-01-20T15:00:00Z');\n * const instant2 = Temporal.Instant.from('2025-01-20T16:00:00Z');\n *\n * isBefore(instant1, instant2); // true\n * ```\n *\n * @example\n * ```ts\n * // Different timezones - compares by instant\n * const ny = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');\n * const tokyo = Temporal.ZonedDateTime.from('2025-01-21T00:00:00+09:00[Asia/Tokyo]');\n *\n * isBefore(ny, tokyo); // true\n * // NY 10:00 is 15:00 UTC, Tokyo 00:00 is 15:00 UTC the previous day\n * ```\n */\nexport function isBefore(\n date1: Temporal.Instant | Temporal.ZonedDateTime,\n date2: Temporal.Instant | Temporal.ZonedDateTime\n): boolean {\n const zoned1 = normalizeTemporalInput(date1);\n const zoned2 = normalizeTemporalInput(date2);\n\n return isBeforeInternal(zoned1, zoned2);\n}\n"],"mappings":";;;;;;;;AAyCO,SAASA,UACd,OACA,OACS;AACT,QAAM,SAAS,uBAAuB,KAAK;AAC3C,QAAM,SAAS,uBAAuB,KAAK;AAE3C,SAAO,SAAiB,QAAQ,MAAM;AACxC;","names":["isBefore"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Temporal
|
|
3
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
|
+
|
|
1
5
|
// src/isPlainDateBefore.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
6
|
function isPlainDateBefore(date1, date2) {
|
|
4
7
|
return Temporal.PlainDate.compare(date1, date2) < 0;
|
|
5
8
|
}
|
|
@@ -7,4 +10,4 @@ function isPlainDateBefore(date1, date2) {
|
|
|
7
10
|
export {
|
|
8
11
|
isPlainDateBefore
|
|
9
12
|
};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-XONITURH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isPlainDateBefore.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\n\n/**\n * Returns true if the first plain date is before the second plain date.\n * Compares calendar dates without time or timezone considerations.\n *\n * @param date1 - First plain date\n * @param date2 - Second plain date\n * @returns true if date1 is before date2, false otherwise\n *\n * @example\n * ```ts\n * const jan20 = Temporal.PlainDate.from('2025-01-20');\n * const jan25 = Temporal.PlainDate.from('2025-01-25');\n *\n * isPlainDateBefore(jan20, jan25); // true\n * isPlainDateBefore(jan25, jan20); // false\n * isPlainDateBefore(jan20, jan20); // false\n * ```\n */\nexport function isPlainDateBefore(\n date1: Temporal.PlainDate,\n date2: Temporal.PlainDate\n): boolean {\n return Temporal.PlainDate.compare(date1, date2) < 0;\n}\n"],"mappings":";;;;;AAoBO,SAAS,kBACd,OACA,OACS;AACT,SAAO,SAAS,UAAU,QAAQ,OAAO,KAAK,IAAI;AACpD;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeTemporalInput
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F6EWMA4K.js";
|
|
4
4
|
|
|
5
5
|
// src/roundToNearestMinute.ts
|
|
6
6
|
var MODE_TO_ROUNDING_MODE = {
|
|
@@ -22,4 +22,4 @@ function roundToNearestMinute(input, options) {
|
|
|
22
22
|
export {
|
|
23
23
|
roundToNearestMinute
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-XRZUPSUB.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
plainDateToZonedDateTime
|
|
3
|
+
} from "./chunk-LYPSZYIG.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeTemporalInput
|
|
6
|
+
} from "./chunk-F6EWMA4K.js";
|
|
7
|
+
import {
|
|
8
|
+
isPlainDate
|
|
9
|
+
} from "./chunk-VOZTLX5F.js";
|
|
10
|
+
|
|
11
|
+
// src/shared/normalizeWithPlainDate.ts
|
|
12
|
+
function normalizeWithPlainDate(input, timezone) {
|
|
13
|
+
return isPlainDate(input) ? plainDateToZonedDateTime(input, timezone) : normalizeTemporalInput(input);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
normalizeWithPlainDate
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-Y4HT4LCB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/normalizeWithPlainDate.ts"],"sourcesContent":["import { isPlainDate } from './temporal';\nimport type { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from '../types';\nimport { normalizeTemporalInput } from './normalizeTemporalInput';\nimport { plainDateToZonedDateTime } from './plainDateToZonedDateTime';\n\n/**\n * @internal\n * Normalizes any temporal input (Instant, ZonedDateTime, or PlainDate) to ZonedDateTime.\n * - Instant → UTC ZonedDateTime\n * - ZonedDateTime → returned as-is\n * - PlainDate → ZonedDateTime at midnight in the specified timezone\n *\n * This is an internal helper - do not use directly.\n */\nexport function normalizeWithPlainDate(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function normalizeWithPlainDate(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function normalizeWithPlainDate(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime;\nexport function normalizeWithPlainDate(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n return isPlainDate(input)\n ? plainDateToZonedDateTime(input, timezone!)\n : normalizeTemporalInput(input);\n}\n"],"mappings":";;;;;;;;;;;AA0BO,SAAS,uBACd,OACA,UACwB;AACxB,SAAO,YAAY,KAAK,IACpB,yBAAyB,OAAO,QAAS,IACzC,uBAAuB,KAAK;AAClC;","names":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeTemporalInput
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F6EWMA4K.js";
|
|
4
|
+
import {
|
|
5
|
+
Temporal
|
|
6
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
7
|
|
|
5
8
|
// src/eachMonthOfInterval.ts
|
|
6
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
7
9
|
function eachMonthOfInterval(interval) {
|
|
8
10
|
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
11
|
const endZoned = normalizeTemporalInput(interval.end);
|
|
@@ -35,4 +37,4 @@ function eachMonthOfInterval(interval) {
|
|
|
35
37
|
export {
|
|
36
38
|
eachMonthOfInterval
|
|
37
39
|
};
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-Z2LOTP6T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachMonthOfInterval.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each month within the interval.\n * Each element represents the first moment of the month (day 1 at midnight).\n * The interval is inclusive of both start and end months.\n *\n * For Instant inputs, UTC is used as the timezone.\n * For ZonedDateTime inputs, the timezone of the start date is preserved.\n *\n * @param interval - The interval with start and end datetimes\n * @returns Array of ZonedDateTime at start of each month in the interval\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2025-01-15T10:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-04-20T14:00:00Z[UTC]');\n *\n * const months = eachMonthOfInterval({ start, end });\n * // [\n * // 2025-01-01T00:00:00Z[UTC],\n * // 2025-02-01T00:00:00Z[UTC],\n * // 2025-03-01T00:00:00Z[UTC],\n * // 2025-04-01T00:00:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Cross-year boundary\n * const start = Temporal.ZonedDateTime.from('2024-11-15T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-02-15T00:00:00Z[UTC]');\n *\n * const months = eachMonthOfInterval({ start, end });\n * // [\n * // 2024-11-01T00:00:00Z[UTC],\n * // 2024-12-01T00:00:00Z[UTC],\n * // 2025-01-01T00:00:00Z[UTC],\n * // 2025-02-01T00:00:00Z[UTC]\n * // ]\n * ```\n */\nexport function eachMonthOfInterval(interval: {\n start: Temporal.Instant | Temporal.ZonedDateTime;\n end: Temporal.Instant | Temporal.ZonedDateTime;\n}): Temporal.ZonedDateTime[] {\n const startZoned = normalizeTemporalInput(interval.start);\n const endZoned = normalizeTemporalInput(interval.end);\n\n const timezone = startZoned.timeZoneId;\n\n // Get start of the starting month\n const startYearMonth = Temporal.PlainYearMonth.from({\n year: startZoned.year,\n month: startZoned.month,\n });\n\n // Get end month in the same timezone\n const endInTimezone = endZoned.withTimeZone(timezone);\n const endYearMonth = Temporal.PlainYearMonth.from({\n year: endInTimezone.year,\n month: endInTimezone.month,\n });\n\n const months: Temporal.ZonedDateTime[] = [];\n let current = startYearMonth;\n\n while (Temporal.PlainYearMonth.compare(current, endYearMonth) <= 0) {\n const firstOfMonth = current.toPlainDate({ day: 1 });\n months.push(\n firstOfMonth.toZonedDateTime({\n timeZone: timezone,\n plainTime: new Temporal.PlainTime(),\n })\n );\n current = current.add({ months: 1 });\n }\n\n return months;\n}\n"],"mappings":";;;;;;;;AA2CO,SAAS,oBAAoB,UAGP;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAG5B,QAAM,iBAAiB,SAAS,eAAe,KAAK;AAAA,IAClD,MAAM,WAAW;AAAA,IACjB,OAAO,WAAW;AAAA,EACpB,CAAC;AAGD,QAAM,gBAAgB,SAAS,aAAa,QAAQ;AACpD,QAAM,eAAe,SAAS,eAAe,KAAK;AAAA,IAChD,MAAM,cAAc;AAAA,IACpB,OAAO,cAAc;AAAA,EACvB,CAAC;AAED,QAAM,SAAmC,CAAC;AAC1C,MAAI,UAAU;AAEd,SAAO,SAAS,eAAe,QAAQ,SAAS,YAAY,KAAK,GAAG;AAClE,UAAM,eAAe,QAAQ,YAAY,EAAE,KAAK,EAAE,CAAC;AACnD,WAAO;AAAA,MACL,aAAa,gBAAgB;AAAA,QAC3B,UAAU;AAAA,QACV,WAAW,IAAI,SAAS,UAAU;AAAA,MACpC,CAAC;AAAA,IACH;AACA,cAAU,QAAQ,IAAI,EAAE,QAAQ,EAAE,CAAC;AAAA,EACrC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMilliseconds
|
|
3
|
+
} from "./chunk-VXOQ7IG5.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeTemporalInput
|
|
6
|
+
} from "./chunk-F6EWMA4K.js";
|
|
7
|
+
|
|
8
|
+
// src/differenceInSeconds.ts
|
|
9
|
+
function differenceInSeconds(laterDate, earlierDate, options) {
|
|
10
|
+
const zoned1 = normalizeTemporalInput(laterDate);
|
|
11
|
+
const zoned2 = normalizeTemporalInput(earlierDate);
|
|
12
|
+
const precise = differenceInMilliseconds(zoned1, zoned2) / 1e3;
|
|
13
|
+
return options?.fractional ? precise : Math.trunc(precise);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
differenceInSeconds
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-ZBEEQUE4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/differenceInSeconds.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { differenceInMilliseconds } from './shared/differenceInMilliseconds';\nimport type { DifferenceOptions } from './shared/differenceOptions';\n\n/**\n * Returns the number of seconds between two datetimes.\n * The result is positive if laterDate is after earlierDate, negative if before.\n *\n * @param laterDate - The later datetime (Instant or ZonedDateTime)\n * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)\n * @param options - Optional { fractional } to return the precise value\n * @returns The number of seconds between the dates, truncated toward zero (pass { fractional: true } for the precise value)\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T12:30:25Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:30:20Z');\n *\n * differenceInSeconds(later, earlier); // 5\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-20T15:01:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');\n *\n * differenceInSeconds(later, earlier); // 60\n * ```\n *\n * @example\n * ```ts\n * // Handles different timezones - compares by instant\n * const tokyo = Temporal.ZonedDateTime.from('2025-01-21T00:00:00+09:00[Asia/Tokyo]');\n * const ny = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');\n *\n * differenceInSeconds(tokyo, ny); // 0 (same instant)\n * ```\n */\nexport function differenceInSeconds(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime,\n options?: DifferenceOptions\n): number {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n const precise = differenceInMilliseconds(zoned1, zoned2) / 1000;\n return options?.fractional ? precise : Math.trunc(precise);\n}\n"],"mappings":";;;;;;;;AAwCO,SAAS,oBACd,WACA,aACA,SACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,UAAU,yBAAyB,QAAQ,MAAM,IAAI;AAC3D,SAAO,SAAS,aAAa,UAAU,KAAK,MAAM,OAAO;AAC3D;","names":[]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Temporal
|
|
3
|
+
} from "./chunk-VOZTLX5F.js";
|
|
4
|
+
|
|
1
5
|
// src/now.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
6
|
function now(timezone) {
|
|
4
7
|
return Temporal.Now.zonedDateTimeISO(timezone);
|
|
5
8
|
}
|
|
@@ -7,4 +10,4 @@ function now(timezone) {
|
|
|
7
10
|
export {
|
|
8
11
|
now
|
|
9
12
|
};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-ZFXBHDFB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/now.ts"],"sourcesContent":["import { Temporal } from './shared/temporal';\nimport type { Timezone } from './types';\n\n/**\n * Get the current date and time in the specified timezone.\n *\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime representing the current date and time\n *\n * @example\n * ```typescript\n * import { now, browserTimezone } from '@gobrand/tiempo';\n *\n * // Server-side: Get now in UTC\n * const nowUtc = now(\"UTC\");\n *\n * // Server-side: Get now in user's timezone (from DB/preferences)\n * const nowUser = now(user.timezone);\n *\n * // Client-side: Get now in browser's timezone\n * const nowLocal = now(browserTimezone());\n *\n * // Get now in a specific timezone\n * const nowInMadrid = now(\"Europe/Madrid\");\n * ```\n */\nexport function now(timezone: Timezone): Temporal.ZonedDateTime {\n return Temporal.Now.zonedDateTimeISO(timezone);\n}\n"],"mappings":";;;;;AA0BO,SAAS,IAAI,UAA4C;AAC9D,SAAO,SAAS,IAAI,iBAAiB,QAAQ;AAC/C;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addWeeks
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BOGN7JC3.js";
|
|
4
4
|
|
|
5
5
|
// src/subWeeks.ts
|
|
6
6
|
function subWeeks(input, weeks) {
|
|
@@ -10,4 +10,4 @@ function subWeeks(input, weeks) {
|
|
|
10
10
|
export {
|
|
11
11
|
subWeeks
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-ZKGR3F4F.js.map
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Temporal,
|
|
3
|
+
isInstant,
|
|
4
|
+
isZonedDateTime
|
|
5
|
+
} from "./chunk-VOZTLX5F.js";
|
|
6
|
+
|
|
1
7
|
// src/simpleFormat.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
8
|
function simpleFormat(input, options) {
|
|
4
9
|
const { locale = "en-US", timeZone } = options;
|
|
5
10
|
const dateFormat = "date" in options ? options.date : void 0;
|
|
6
11
|
const timeFormat = "time" in options ? options.time : void 0;
|
|
7
12
|
let zdt;
|
|
8
|
-
if (input
|
|
13
|
+
if (isInstant(input)) {
|
|
9
14
|
const tz = timeZone ?? "UTC";
|
|
10
15
|
zdt = input.toZonedDateTimeISO(tz);
|
|
11
|
-
} else if (input
|
|
16
|
+
} else if (isZonedDateTime(input)) {
|
|
12
17
|
if (timeZone) {
|
|
13
18
|
zdt = input.toInstant().toZonedDateTimeISO(timeZone);
|
|
14
19
|
} else {
|
|
@@ -54,4 +59,4 @@ function formatCompactTime(zdt) {
|
|
|
54
59
|
export {
|
|
55
60
|
simpleFormat
|
|
56
61
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-ZSRCVDZ2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/simpleFormat.ts"],"sourcesContent":["import { Temporal, isInstant, isZonedDateTime } from './shared/temporal';\nimport type { Timezone } from './types';\n\ninterface BaseOptions {\n locale?: string;\n timeZone?: Timezone;\n}\n\ninterface DateOnlyOptions extends BaseOptions {\n date: 'compact' | 'auto' | 'full';\n time?: never;\n}\n\ninterface TimeOnlyOptions extends BaseOptions {\n date?: never;\n time: '12h' | '24h' | 'compact';\n}\n\ninterface DateAndTimeOptions extends BaseOptions {\n date: 'compact' | 'auto' | 'full';\n time: '12h' | '24h' | 'compact';\n}\n\nexport type SimpleFormatOptions = DateOnlyOptions | TimeOnlyOptions | DateAndTimeOptions;\n\n/**\n * Format a Temporal date/time in a human-friendly way.\n *\n * Pass `date`, `time`, or both to control what's displayed.\n * At least one of `date` or `time` is required.\n *\n * @param input - A Temporal.Instant, ZonedDateTime, or PlainDate\n * @param options - Format options (at least `date` or `time` required)\n *\n * Date formats:\n * - `'compact'` - \"Dec 23\" (never shows year)\n * - `'auto'` - \"Dec 23\" or \"Dec 23, 2020\" (shows year only if not current year)\n * - `'full'` - \"Dec 23, 2026\" (always shows year)\n *\n * Time formats:\n * - `'12h'` - \"3:30 PM\"\n * - `'24h'` - \"15:30\"\n * - `'compact'` - \"9am\" or \"2:30pm\" (omits minutes when zero, lowercase am/pm)\n *\n * @example\n * ```typescript\n * const zdt = Temporal.ZonedDateTime.from(\"2026-12-23T09:00:00[America/New_York]\");\n * const pastZdt = Temporal.ZonedDateTime.from(\"2020-12-23T14:30:00[America/New_York]\");\n *\n * // Date only\n * simpleFormat(zdt, { date: 'compact' }); // \"Dec 23\"\n * simpleFormat(zdt, { date: 'auto' }); // \"Dec 23\"\n * simpleFormat(pastZdt, { date: 'auto' }); // \"Dec 23, 2020\"\n * simpleFormat(zdt, { date: 'full' }); // \"Dec 23, 2026\"\n *\n * // Time only\n * simpleFormat(zdt, { time: 'compact' }); // \"9am\"\n * simpleFormat(pastZdt, { time: 'compact' }); // \"2:30pm\"\n * simpleFormat(zdt, { time: '12h' }); // \"9:00 AM\"\n * simpleFormat(zdt, { time: '24h' }); // \"09:00\"\n *\n * // Date and time\n * simpleFormat(zdt, { date: 'auto', time: 'compact' }); // \"Dec 23, 9am\"\n * simpleFormat(zdt, { date: 'full', time: '12h' }); // \"Dec 23, 2026, 9:00 AM\"\n *\n * // With Instant (timeZone required)\n * const instant = Temporal.Instant.from(\"2026-12-23T14:00:00Z\");\n * simpleFormat(instant, { date: 'auto', timeZone: 'America/New_York' }); // \"Dec 23\"\n * ```\n */\nexport function simpleFormat(\n input: Temporal.PlainDate | Temporal.ZonedDateTime | Temporal.Instant,\n options: SimpleFormatOptions\n): string {\n const { locale = 'en-US', timeZone } = options;\n const dateFormat = 'date' in options ? options.date : undefined;\n const timeFormat = 'time' in options ? options.time : undefined;\n\n // Convert input to ZonedDateTime for consistent handling\n let zdt: Temporal.ZonedDateTime;\n\n if (isInstant(input)) {\n const tz = timeZone ?? 'UTC';\n zdt = input.toZonedDateTimeISO(tz);\n } else if (isZonedDateTime(input)) {\n if (timeZone) {\n zdt = input.toInstant().toZonedDateTimeISO(timeZone);\n } else {\n zdt = input;\n }\n } else {\n // PlainDate - convert to ZonedDateTime at midnight UTC for formatting\n zdt = input.toZonedDateTime({ timeZone: timeZone ?? 'UTC', plainTime: new Temporal.PlainTime() });\n }\n\n const parts: string[] = [];\n\n // Format date part\n if (dateFormat) {\n const currentYear = Temporal.Now.plainDateISO().year;\n const showYear =\n dateFormat === 'full' ? true : dateFormat === 'compact' ? false : zdt.year !== currentYear;\n\n const dateOptions: Intl.DateTimeFormatOptions = {\n day: 'numeric',\n month: 'short',\n year: showYear ? 'numeric' : undefined,\n };\n\n parts.push(zdt.toLocaleString(locale, dateOptions));\n }\n\n // Format time part\n if (timeFormat) {\n if (timeFormat === 'compact') {\n parts.push(formatCompactTime(zdt));\n } else {\n const timeOptions: Intl.DateTimeFormatOptions = {\n hour: 'numeric',\n minute: '2-digit',\n hour12: timeFormat === '12h',\n };\n parts.push(zdt.toLocaleString(locale, timeOptions));\n }\n }\n\n return parts.join(', ');\n}\n\n/**\n * Format time in compact style: \"9am\" or \"2:30pm\"\n * Omits minutes when they're zero for cleaner display.\n */\nfunction formatCompactTime(zdt: Temporal.ZonedDateTime): string {\n const hour12 = zdt.hour % 12 || 12;\n const ampm = zdt.hour < 12 ? 'am' : 'pm';\n\n if (zdt.minute === 0) {\n return `${hour12}${ampm}`;\n }\n return `${hour12}:${zdt.minute.toString().padStart(2, '0')}${ampm}`;\n}\n"],"mappings":";;;;;;;AAsEO,SAAS,aACd,OACA,SACQ;AACR,QAAM,EAAE,SAAS,SAAS,SAAS,IAAI;AACvC,QAAM,aAAa,UAAU,UAAU,QAAQ,OAAO;AACtD,QAAM,aAAa,UAAU,UAAU,QAAQ,OAAO;AAGtD,MAAI;AAEJ,MAAI,UAAU,KAAK,GAAG;AACpB,UAAM,KAAK,YAAY;AACvB,UAAM,MAAM,mBAAmB,EAAE;AAAA,EACnC,WAAW,gBAAgB,KAAK,GAAG;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