@gobrand/tiempo 2.6.1 → 2.6.3
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/chunk-3TSFIPUR.js +16 -0
- package/dist/chunk-3TSFIPUR.js.map +1 -0
- package/dist/chunk-776JOVV6.js +20 -0
- package/dist/chunk-776JOVV6.js.map +1 -0
- package/dist/chunk-AJ4JBKJK.js +10 -0
- package/dist/chunk-AJ4JBKJK.js.map +1 -0
- package/dist/{chunk-RJY62CDU.js → chunk-B2R2G5YK.js} +5 -2
- package/dist/chunk-B2R2G5YK.js.map +1 -0
- package/dist/chunk-BUX26GTD.js +30 -0
- package/dist/chunk-BUX26GTD.js.map +1 -0
- package/dist/{chunk-D7DPB2JR.js → chunk-BV6CLVSI.js} +7 -4
- package/dist/chunk-BV6CLVSI.js.map +1 -0
- package/dist/chunk-DKYVFYWM.js +25 -0
- package/dist/chunk-DKYVFYWM.js.map +1 -0
- package/dist/chunk-G2JUEBC5.js +26 -0
- package/dist/chunk-G2JUEBC5.js.map +1 -0
- package/dist/chunk-HLGMUTFK.js +16 -0
- package/dist/chunk-HLGMUTFK.js.map +1 -0
- package/dist/chunk-HOCNCQTC.js +18 -0
- package/dist/chunk-HOCNCQTC.js.map +1 -0
- package/dist/chunk-JA7SVLAF.js +20 -0
- package/dist/chunk-JA7SVLAF.js.map +1 -0
- package/dist/chunk-KGVUENQO.js +17 -0
- package/dist/chunk-KGVUENQO.js.map +1 -0
- package/dist/chunk-OLEOU3XE.js +28 -0
- package/dist/chunk-OLEOU3XE.js.map +1 -0
- package/dist/chunk-OQ4CWKJT.js +19 -0
- package/dist/chunk-OQ4CWKJT.js.map +1 -0
- package/dist/{chunk-PIDXROVB.js → chunk-PMJD5N5J.js} +5 -2
- package/dist/chunk-PMJD5N5J.js.map +1 -0
- package/dist/chunk-QFNGYTTH.js +14 -0
- package/dist/chunk-QFNGYTTH.js.map +1 -0
- package/dist/{chunk-ZHRMURYP.js → chunk-QVOEXF46.js} +5 -2
- package/dist/chunk-QVOEXF46.js.map +1 -0
- package/dist/chunk-TNCLJK4Y.js +38 -0
- package/dist/chunk-TNCLJK4Y.js.map +1 -0
- package/dist/chunk-UBY22QWM.js +20 -0
- package/dist/chunk-UBY22QWM.js.map +1 -0
- package/dist/chunk-Y7CIJQ67.js +26 -0
- package/dist/chunk-Y7CIJQ67.js.map +1 -0
- package/dist/chunk-YIT6EMBC.js +15 -0
- package/dist/chunk-YIT6EMBC.js.map +1 -0
- package/dist/{chunk-TDQXOSO3.js → chunk-ZJQS7ZY7.js} +4 -4
- package/dist/differenceInHours.d.ts.map +1 -1
- package/dist/differenceInHours.js +2 -1
- package/dist/differenceInMilliseconds.d.ts.map +1 -1
- package/dist/differenceInMilliseconds.js +2 -1
- package/dist/differenceInMinutes.d.ts.map +1 -1
- package/dist/differenceInMinutes.js +2 -1
- package/dist/differenceInSeconds.d.ts.map +1 -1
- package/dist/differenceInSeconds.js +2 -1
- package/dist/eachDayOfInterval.d.ts +69 -0
- package/dist/eachDayOfInterval.d.ts.map +1 -0
- package/dist/eachDayOfInterval.js +8 -0
- package/dist/eachDayOfInterval.js.map +1 -0
- package/dist/eachDayOfInterval.test.d.ts +2 -0
- package/dist/eachDayOfInterval.test.d.ts.map +1 -0
- package/dist/eachHourOfInterval.d.ts +51 -0
- package/dist/eachHourOfInterval.d.ts.map +1 -0
- package/dist/eachHourOfInterval.js +8 -0
- package/dist/eachHourOfInterval.js.map +1 -0
- package/dist/eachHourOfInterval.test.d.ts +2 -0
- package/dist/eachHourOfInterval.test.d.ts.map +1 -0
- package/dist/eachMinuteOfInterval.d.ts +50 -0
- package/dist/eachMinuteOfInterval.d.ts.map +1 -0
- package/dist/eachMinuteOfInterval.js +8 -0
- package/dist/eachMinuteOfInterval.js.map +1 -0
- package/dist/eachMinuteOfInterval.test.d.ts +2 -0
- package/dist/eachMinuteOfInterval.test.d.ts.map +1 -0
- package/dist/eachMonthOfInterval.d.ts +46 -0
- package/dist/eachMonthOfInterval.d.ts.map +1 -0
- package/dist/eachMonthOfInterval.js +8 -0
- package/dist/eachMonthOfInterval.js.map +1 -0
- package/dist/eachMonthOfInterval.test.d.ts +2 -0
- package/dist/eachMonthOfInterval.test.d.ts.map +1 -0
- package/dist/eachWeekOfInterval.d.ts +58 -0
- package/dist/eachWeekOfInterval.d.ts.map +1 -0
- package/dist/eachWeekOfInterval.js +8 -0
- package/dist/eachWeekOfInterval.js.map +1 -0
- package/dist/eachWeekOfInterval.test.d.ts +2 -0
- package/dist/eachWeekOfInterval.test.d.ts.map +1 -0
- package/dist/eachYearOfInterval.d.ts +55 -0
- package/dist/eachYearOfInterval.d.ts.map +1 -0
- package/dist/eachYearOfInterval.js +8 -0
- package/dist/eachYearOfInterval.js.map +1 -0
- package/dist/eachYearOfInterval.test.d.ts +2 -0
- package/dist/eachYearOfInterval.test.d.ts.map +1 -0
- package/dist/endOfDay.d.ts.map +1 -1
- package/dist/endOfDay.js +2 -1
- package/dist/endOfMonth.d.ts.map +1 -1
- package/dist/endOfMonth.js +2 -1
- package/dist/endOfYear.d.ts.map +1 -1
- package/dist/endOfYear.js +2 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77 -50
- package/dist/intlFormatDistance.js +5 -4
- package/dist/isFuture.d.ts +1 -1
- package/dist/isFuture.d.ts.map +1 -1
- package/dist/isFuture.js +3 -1
- package/dist/isPast.d.ts +1 -1
- package/dist/isPast.d.ts.map +1 -1
- package/dist/isPast.js +3 -1
- package/dist/shared/differenceInMilliseconds.d.ts +3 -0
- package/dist/shared/differenceInMilliseconds.d.ts.map +1 -0
- package/dist/shared/differenceInMilliseconds.js +7 -0
- package/dist/shared/differenceInMilliseconds.js.map +1 -0
- package/dist/shared/normalizeWithPlainDate.d.ts +15 -0
- package/dist/shared/normalizeWithPlainDate.d.ts.map +1 -0
- package/dist/shared/normalizeWithPlainDate.js +9 -0
- package/dist/shared/normalizeWithPlainDate.js.map +1 -0
- package/dist/shared/nowZoned.d.ts +3 -0
- package/dist/shared/nowZoned.d.ts.map +1 -0
- package/dist/shared/nowZoned.js +8 -0
- package/dist/shared/nowZoned.js.map +1 -0
- package/dist/startOfDay.d.ts.map +1 -1
- package/dist/startOfDay.js +2 -1
- package/dist/startOfMonth.d.ts.map +1 -1
- package/dist/startOfMonth.js +2 -1
- package/dist/startOfYear.d.ts.map +1 -1
- package/dist/startOfYear.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-2H4KLXGL.js +0 -16
- package/dist/chunk-2H4KLXGL.js.map +0 -1
- package/dist/chunk-7GEIOKVQ.js +0 -19
- package/dist/chunk-7GEIOKVQ.js.map +0 -1
- package/dist/chunk-D7DPB2JR.js.map +0 -1
- package/dist/chunk-GFWC7CHD.js +0 -21
- package/dist/chunk-GFWC7CHD.js.map +0 -1
- package/dist/chunk-GLGAVKGV.js +0 -24
- package/dist/chunk-GLGAVKGV.js.map +0 -1
- package/dist/chunk-ID52RFFD.js +0 -19
- package/dist/chunk-ID52RFFD.js.map +0 -1
- package/dist/chunk-PIDXROVB.js.map +0 -1
- package/dist/chunk-PWISCOZV.js +0 -23
- package/dist/chunk-PWISCOZV.js.map +0 -1
- package/dist/chunk-R5XN76EV.js +0 -16
- package/dist/chunk-R5XN76EV.js.map +0 -1
- package/dist/chunk-RJY62CDU.js.map +0 -1
- package/dist/chunk-XPJFOBPW.js +0 -24
- package/dist/chunk-XPJFOBPW.js.map +0 -1
- package/dist/chunk-ZHRMURYP.js.map +0 -1
- /package/dist/{chunk-TDQXOSO3.js.map → chunk-ZJQS7ZY7.js.map} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
|
|
5
|
+
// src/startOfYear.ts
|
|
6
|
+
import "@js-temporal/polyfill";
|
|
7
|
+
function startOfYear(input, timezone) {
|
|
8
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
9
|
+
const firstDay = zonedDateTime.with({ month: 1, day: 1 });
|
|
10
|
+
return firstDay.startOfDay();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
startOfYear
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-3TSFIPUR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/startOfYear.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\nimport { normalizeWithPlainDate } from './shared/normalizeWithPlainDate';\n\n/**\n * Returns a ZonedDateTime representing the first moment of the year (January 1 at midnight).\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @returns ZonedDateTime at January 1st at 00:00:00.000000000\n *\n * @example\n * ```ts\n * // From Instant (always UTC)\n * const instant = Temporal.Instant.from('2025-06-15T12:00:00Z');\n * const start = startOfYear(instant);\n * // 2025-01-01T00:00:00Z[UTC]\n * ```\n *\n * @example\n * ```ts\n * // From ZonedDateTime (uses its timezone)\n * const zoned = Temporal.ZonedDateTime.from('2025-06-15T15:30:00-05:00[America/New_York]');\n * const start = startOfYear(zoned);\n * // 2025-01-01T00:00:00-05:00[America/New_York]\n * ```\n *\n * @example\n * ```ts\n * // From PlainDate (requires timezone)\n * const date = Temporal.PlainDate.from('2025-06-15');\n * const start = startOfYear(date, 'America/New_York');\n * // 2025-01-01T00:00:00-05:00[America/New_York]\n * ```\n */\nexport function startOfYear(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function startOfYear(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function startOfYear(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeWithPlainDate(input, timezone!);\n const firstDay = zonedDateTime.with({ month: 1, day: 1 });\n return firstDay.startOfDay();\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAyClB,SAAS,YACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,QAAM,WAAW,cAAc,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,CAAC;AACxD,SAAO,SAAS,WAAW;AAC7B;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
import {
|
|
5
|
+
getEndOfDay
|
|
6
|
+
} from "./chunk-AVGNRINZ.js";
|
|
7
|
+
|
|
8
|
+
// src/endOfYear.ts
|
|
9
|
+
import "@js-temporal/polyfill";
|
|
10
|
+
function endOfYear(input, timezone) {
|
|
11
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
12
|
+
const lastMonth = zonedDateTime.with({ month: zonedDateTime.monthsInYear });
|
|
13
|
+
const lastDay = lastMonth.with({ day: lastMonth.daysInMonth });
|
|
14
|
+
return getEndOfDay(lastDay);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
endOfYear
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-776JOVV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/endOfYear.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\nimport { getEndOfDay } from './shared/endOfDay';\nimport { normalizeWithPlainDate } from './shared/normalizeWithPlainDate';\n\n/**\n * Returns a ZonedDateTime representing the last moment of the year (last day at 23:59:59.999999999).\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @returns ZonedDateTime at the last day of the year at 23:59:59.999999999\n *\n * @example\n * ```ts\n * // From Instant (always UTC)\n * const instant = Temporal.Instant.from('2025-06-15T12:00:00Z');\n * const end = endOfYear(instant);\n * // 2025-12-31T23:59:59.999999999Z[UTC]\n * ```\n *\n * @example\n * ```ts\n * // From ZonedDateTime (uses its timezone)\n * const zoned = Temporal.ZonedDateTime.from('2025-06-15T15:30:00-05:00[America/New_York]');\n * const end = endOfYear(zoned);\n * // 2025-12-31T23: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-06-15');\n * const end = endOfYear(date, 'America/New_York');\n * // 2025-12-31T23:59:59.999999999-05:00[America/New_York]\n * ```\n */\nexport function endOfYear(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function endOfYear(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function endOfYear(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeWithPlainDate(input, timezone!);\n const lastMonth = zonedDateTime.with({ month: zonedDateTime.monthsInYear });\n const lastDay = lastMonth.with({ day: lastMonth.daysInMonth });\n return getEndOfDay(lastDay);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AA0ClB,SAAS,UACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,QAAM,YAAY,cAAc,KAAK,EAAE,OAAO,cAAc,aAAa,CAAC;AAC1E,QAAM,UAAU,UAAU,KAAK,EAAE,KAAK,UAAU,YAAY,CAAC;AAC7D,SAAO,YAAY,OAAO;AAC5B;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/shared/differenceInMilliseconds.ts
|
|
2
|
+
import "@js-temporal/polyfill";
|
|
3
|
+
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
4
|
+
return laterDate.epochMilliseconds - earlierDate.epochMilliseconds;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
differenceInMilliseconds
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-AJ4JBKJK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/differenceInMilliseconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport function differenceInMilliseconds(\n laterDate: Temporal.ZonedDateTime,\n earlierDate: Temporal.ZonedDateTime\n): number {\n return laterDate.epochMilliseconds - earlierDate.epochMilliseconds;\n}\n"],"mappings":";AAAA,OAAyB;AAElB,SAAS,yBACd,WACA,aACQ;AACR,SAAO,UAAU,oBAAoB,YAAY;AACnD;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMilliseconds
|
|
3
|
+
} from "./chunk-AJ4JBKJK.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeTemporalInput
|
|
3
6
|
} from "./chunk-MJSZNWCV.js";
|
|
@@ -7,10 +10,10 @@ import "@js-temporal/polyfill";
|
|
|
7
10
|
function differenceInMinutes(laterDate, earlierDate) {
|
|
8
11
|
const zoned1 = normalizeTemporalInput(laterDate);
|
|
9
12
|
const zoned2 = normalizeTemporalInput(earlierDate);
|
|
10
|
-
return Math.trunc((zoned1
|
|
13
|
+
return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 6e4);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
|
14
17
|
differenceInMinutes
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-B2R2G5YK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/differenceInMinutes.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { differenceInMilliseconds } from './shared/differenceInMilliseconds';\n\n/**\n * Returns the number of minutes 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 * @returns The number of minutes between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T12:45:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:30:00Z');\n *\n * differenceInMinutes(later, earlier); // 15\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-20T16:00:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');\n *\n * differenceInMinutes(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 * differenceInMinutes(tokyo, ny); // 0 (same instant)\n * ```\n */\nexport function differenceInMinutes(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime\n): number {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 60000);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AAsClB,SAAS,oBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,MAAM,yBAAyB,QAAQ,MAAM,IAAI,GAAK;AACpE;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachYearOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachYearOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const startYear = startZoned.year;
|
|
12
|
+
const endInTimezone = endZoned.withTimeZone(timezone);
|
|
13
|
+
const endYear = endInTimezone.year;
|
|
14
|
+
const years = [];
|
|
15
|
+
for (let year = startYear; year <= endYear; year++) {
|
|
16
|
+
const firstOfYear = Temporal.PlainDate.from({ year, month: 1, day: 1 });
|
|
17
|
+
years.push(
|
|
18
|
+
firstOfYear.toZonedDateTime({
|
|
19
|
+
timeZone: timezone,
|
|
20
|
+
plainTime: new Temporal.PlainTime()
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return years;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
eachYearOfInterval
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-BUX26GTD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachYearOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each year within the interval.\n * Each element represents the first moment of the year (January 1st at midnight).\n * The interval is inclusive of both start and end years.\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 year in the interval\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2022-06-15T10:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-03-20T14:00:00Z[UTC]');\n *\n * const years = eachYearOfInterval({ start, end });\n * // [\n * // 2022-01-01T00:00:00Z[UTC],\n * // 2023-01-01T00:00:00Z[UTC],\n * // 2024-01-01T00:00:00Z[UTC],\n * // 2025-01-01T00:00:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Single year\n * const start = Temporal.ZonedDateTime.from('2025-01-15T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-12-31T23:59:59Z[UTC]');\n *\n * const years = eachYearOfInterval({ start, end });\n * // [2025-01-01T00:00:00Z[UTC]]\n * ```\n *\n * @example\n * ```ts\n * // With timezone\n * const start = Temporal.ZonedDateTime.from('2024-01-01T00:00:00-05:00[America/New_York]');\n * const end = Temporal.ZonedDateTime.from('2026-06-15T00:00:00-04:00[America/New_York]');\n *\n * const years = eachYearOfInterval({ start, end });\n * // [\n * // 2024-01-01T00:00:00-05:00[America/New_York],\n * // 2025-01-01T00:00:00-05:00[America/New_York],\n * // 2026-01-01T00:00:00-05:00[America/New_York]\n * // ]\n * ```\n */\nexport function eachYearOfInterval(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 const startYear = startZoned.year;\n\n // Get end year in the same timezone\n const endInTimezone = endZoned.withTimeZone(timezone);\n const endYear = endInTimezone.year;\n\n const years: Temporal.ZonedDateTime[] = [];\n\n for (let year = startYear; year <= endYear; year++) {\n const firstOfYear = Temporal.PlainDate.from({ year, month: 1, day: 1 });\n years.push(\n firstOfYear.toZonedDateTime({\n timeZone: timezone,\n plainTime: new Temporal.PlainTime(),\n })\n );\n }\n\n return years;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAoDlB,SAAS,mBAAmB,UAGN;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAC5B,QAAM,YAAY,WAAW;AAG7B,QAAM,gBAAgB,SAAS,aAAa,QAAQ;AACpD,QAAM,UAAU,cAAc;AAE9B,QAAM,QAAkC,CAAC;AAEzC,WAAS,OAAO,WAAW,QAAQ,SAAS,QAAQ;AAClD,UAAM,cAAc,SAAS,UAAU,KAAK,EAAE,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;AACtE,UAAM;AAAA,MACJ,YAAY,gBAAgB;AAAA,QAC1B,UAAU;AAAA,QACV,WAAW,IAAI,SAAS,UAAU;AAAA,MACpC,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMilliseconds
|
|
3
|
+
} from "./chunk-AJ4JBKJK.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeTemporalInput
|
|
3
6
|
} from "./chunk-MJSZNWCV.js";
|
|
4
7
|
|
|
5
8
|
// src/differenceInMilliseconds.ts
|
|
6
9
|
import "@js-temporal/polyfill";
|
|
7
|
-
function
|
|
10
|
+
function differenceInMilliseconds2(laterDate, earlierDate) {
|
|
8
11
|
const zoned1 = normalizeTemporalInput(laterDate);
|
|
9
12
|
const zoned2 = normalizeTemporalInput(earlierDate);
|
|
10
|
-
return zoned1
|
|
13
|
+
return differenceInMilliseconds(zoned1, zoned2);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
|
14
|
-
differenceInMilliseconds
|
|
17
|
+
differenceInMilliseconds2 as differenceInMilliseconds
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-BV6CLVSI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/differenceInMilliseconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { differenceInMilliseconds as differenceInMillisecondsInternal } from './shared/differenceInMilliseconds';\n\n/**\n * Returns the number of milliseconds 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 * @returns The number of milliseconds between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T12:30:21.700Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:30:20.600Z');\n *\n * differenceInMilliseconds(later, earlier); // 1100\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T14:00:00-05:00[America/New_York]');\n *\n * differenceInMilliseconds(later, earlier); // 3600000\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 * differenceInMilliseconds(tokyo, ny); // 0 (same instant)\n * ```\n */\nexport function differenceInMilliseconds(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime\n): number {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n return differenceInMillisecondsInternal(zoned1, zoned2);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AAsClB,SAASA,0BACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,yBAAiC,QAAQ,MAAM;AACxD;","names":["differenceInMilliseconds"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachDayOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachDayOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const startDate = startZoned.toPlainDate();
|
|
12
|
+
const endDate = endZoned.withTimeZone(timezone).toPlainDate();
|
|
13
|
+
const days = [];
|
|
14
|
+
let current = startDate;
|
|
15
|
+
while (Temporal.PlainDate.compare(current, endDate) <= 0) {
|
|
16
|
+
days.push(current.toZonedDateTime({ timeZone: timezone, plainTime: new Temporal.PlainTime() }));
|
|
17
|
+
current = current.add({ days: 1 });
|
|
18
|
+
}
|
|
19
|
+
return days;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
eachDayOfInterval
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-DKYVFYWM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachDayOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each calendar day within the interval.\n * Each element represents the start of day (midnight) in the timezone of the interval start.\n * The interval is inclusive of both start and end days.\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 day in the interval\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2025-01-06T10:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-10T14:00:00Z[UTC]');\n *\n * const days = eachDayOfInterval({ start, end });\n * // [\n * // 2025-01-06T00:00:00Z[UTC],\n * // 2025-01-07T00:00:00Z[UTC],\n * // 2025-01-08T00:00:00Z[UTC],\n * // 2025-01-09T00:00:00Z[UTC],\n * // 2025-01-10T00:00:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // With timezone - preserves the timezone from start\n * const start = Temporal.ZonedDateTime.from('2025-01-06T10:00:00-05:00[America/New_York]');\n * const end = Temporal.ZonedDateTime.from('2025-01-08T14:00:00-05:00[America/New_York]');\n *\n * const days = eachDayOfInterval({ start, end });\n * // [\n * // 2025-01-06T00:00:00-05:00[America/New_York],\n * // 2025-01-07T00:00:00-05:00[America/New_York],\n * // 2025-01-08T00:00:00-05:00[America/New_York]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // With Instant (uses UTC)\n * const start = Temporal.Instant.from('2025-01-06T00:00:00Z');\n * const end = Temporal.Instant.from('2025-01-08T00:00:00Z');\n *\n * const days = eachDayOfInterval({ start, end });\n * // [\n * // 2025-01-06T00:00:00Z[UTC],\n * // 2025-01-07T00:00:00Z[UTC],\n * // 2025-01-08T00:00:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Single day interval\n * const date = Temporal.ZonedDateTime.from('2025-01-15T12:00:00Z[UTC]');\n *\n * eachDayOfInterval({ start: date, end: date });\n * // [2025-01-15T00:00:00Z[UTC]]\n * ```\n */\nexport function eachDayOfInterval(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 const startDate = startZoned.toPlainDate();\n const endDate = endZoned.withTimeZone(timezone).toPlainDate();\n\n const days: Temporal.ZonedDateTime[] = [];\n let current = startDate;\n\n while (Temporal.PlainDate.compare(current, endDate) <= 0) {\n days.push(current.toZonedDateTime({ timeZone: timezone, plainTime: new Temporal.PlainTime() }));\n current = current.add({ days: 1 });\n }\n\n return days;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAkElB,SAAS,kBAAkB,UAGL;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAC5B,QAAM,YAAY,WAAW,YAAY;AACzC,QAAM,UAAU,SAAS,aAAa,QAAQ,EAAE,YAAY;AAE5D,QAAM,OAAiC,CAAC;AACxC,MAAI,UAAU;AAEd,SAAO,SAAS,UAAU,QAAQ,SAAS,OAAO,KAAK,GAAG;AACxD,SAAK,KAAK,QAAQ,gBAAgB,EAAE,UAAU,UAAU,WAAW,IAAI,SAAS,UAAU,EAAE,CAAC,CAAC;AAC9F,cAAU,QAAQ,IAAI,EAAE,MAAM,EAAE,CAAC;AAAA,EACnC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachMinuteOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachMinuteOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const startMinute = startZoned.round({ smallestUnit: "minute", roundingMode: "floor" });
|
|
12
|
+
const endInTimezone = endZoned.withTimeZone(timezone);
|
|
13
|
+
const endMinute = endInTimezone.round({ smallestUnit: "minute", roundingMode: "floor" });
|
|
14
|
+
const minutes = [];
|
|
15
|
+
let current = startMinute;
|
|
16
|
+
while (Temporal.ZonedDateTime.compare(current, endMinute) <= 0) {
|
|
17
|
+
minutes.push(current);
|
|
18
|
+
current = current.add({ minutes: 1 });
|
|
19
|
+
}
|
|
20
|
+
return minutes;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
eachMinuteOfInterval
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=chunk-G2JUEBC5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachMinuteOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\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":";;;;;AAAA,SAAS,gBAAgB;AA+ClB,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":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
|
|
5
|
+
// src/startOfMonth.ts
|
|
6
|
+
import "@js-temporal/polyfill";
|
|
7
|
+
function startOfMonth(input, timezone) {
|
|
8
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
9
|
+
const firstDay = zonedDateTime.with({ day: 1 });
|
|
10
|
+
return firstDay.startOfDay();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
startOfMonth
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-HLGMUTFK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/startOfMonth.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\nimport { normalizeWithPlainDate } from './shared/normalizeWithPlainDate';\n\n/**\n * Returns a ZonedDateTime representing the first moment of the month (day 1 at midnight).\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @returns ZonedDateTime at the 1st day of the month at 00:00:00.000000000\n *\n * @example\n * ```ts\n * // From Instant (always UTC)\n * const instant = Temporal.Instant.from('2025-01-15T12:00:00Z');\n * const start = startOfMonth(instant);\n * // 2025-01-01T00:00:00Z[UTC]\n * ```\n *\n * @example\n * ```ts\n * // From ZonedDateTime (uses its timezone)\n * const zoned = Temporal.ZonedDateTime.from('2025-01-15T15:30:00-05:00[America/New_York]');\n * const start = startOfMonth(zoned);\n * // 2025-01-01T00:00:00-05:00[America/New_York]\n * ```\n *\n * @example\n * ```ts\n * // From PlainDate (requires timezone)\n * const date = Temporal.PlainDate.from('2025-01-15');\n * const start = startOfMonth(date, 'America/New_York');\n * // 2025-01-01T00:00:00-05:00[America/New_York]\n * ```\n */\nexport function startOfMonth(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function startOfMonth(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function startOfMonth(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeWithPlainDate(input, timezone!);\n const firstDay = zonedDateTime.with({ day: 1 });\n return firstDay.startOfDay();\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAyClB,SAAS,aACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,QAAM,WAAW,cAAc,KAAK,EAAE,KAAK,EAAE,CAAC;AAC9C,SAAO,SAAS,WAAW;AAC7B;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
import {
|
|
5
|
+
getEndOfDay
|
|
6
|
+
} from "./chunk-AVGNRINZ.js";
|
|
7
|
+
|
|
8
|
+
// src/endOfDay.ts
|
|
9
|
+
import "@js-temporal/polyfill";
|
|
10
|
+
function endOfDay(input, timezone) {
|
|
11
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
12
|
+
return getEndOfDay(zonedDateTime);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
endOfDay
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-HOCNCQTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/endOfDay.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\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":";;;;;;;;AAAA,OAAyB;AA0ClB,SAAS,SACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,SAAO,YAAY,aAAa;AAClC;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAfter
|
|
3
|
+
} from "./chunk-WY63VEXE.js";
|
|
4
|
+
import {
|
|
5
|
+
nowZoned
|
|
6
|
+
} from "./chunk-QFNGYTTH.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeTemporalInput
|
|
9
|
+
} from "./chunk-MJSZNWCV.js";
|
|
10
|
+
|
|
11
|
+
// src/isFuture.ts
|
|
12
|
+
function isFuture(date) {
|
|
13
|
+
const zoned = normalizeTemporalInput(date);
|
|
14
|
+
return isAfter(zoned, nowZoned());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
isFuture
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-JA7SVLAF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isFuture.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { isAfter } from './shared/isAfter';\nimport { nowZoned } from './shared/nowZoned';\n\n/**\n * Returns true if the given datetime is in the future.\n * Compares by the underlying instant (epoch time) against the current time.\n *\n * @param date - Datetime to check (Instant or ZonedDateTime)\n * @returns true if date is after the current instant, false otherwise\n *\n * @example\n * ```ts\n * const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });\n * const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });\n *\n * isFuture(tomorrow); // true\n * isFuture(yesterday); // false\n * ```\n *\n * @example\n * ```ts\n * // Works with Instant too\n * const futureInstant = Temporal.Now.instant().add({ hours: 1 });\n *\n * isFuture(futureInstant); // true\n * ```\n *\n * @example\n * ```ts\n * // Works with any timezone\n * const futureInTokyo = Temporal.ZonedDateTime.from('2100-01-01T00:00:00+09:00[Asia/Tokyo]');\n *\n * isFuture(futureInTokyo); // true\n * ```\n */\nexport function isFuture(\n date: Temporal.Instant | Temporal.ZonedDateTime\n): boolean {\n const zoned = normalizeTemporalInput(date);\n\n return isAfter(zoned, nowZoned());\n}\n"],"mappings":";;;;;;;;;;;AAqCO,SAAS,SACd,MACS;AACT,QAAM,QAAQ,uBAAuB,IAAI;AAEzC,SAAO,QAAQ,OAAO,SAAS,CAAC;AAClC;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
plainDateToZonedDateTime
|
|
3
|
+
} from "./chunk-JNA3AFOC.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeTemporalInput
|
|
6
|
+
} from "./chunk-MJSZNWCV.js";
|
|
7
|
+
|
|
8
|
+
// src/shared/normalizeWithPlainDate.ts
|
|
9
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
10
|
+
function normalizeWithPlainDate(input, timezone) {
|
|
11
|
+
return input instanceof Temporal.PlainDate ? plainDateToZonedDateTime(input, timezone) : normalizeTemporalInput(input);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
normalizeWithPlainDate
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-KGVUENQO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/normalizeWithPlainDate.ts"],"sourcesContent":["import { 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 input instanceof Temporal.PlainDate\n ? plainDateToZonedDateTime(input, timezone!)\n : normalizeTemporalInput(input);\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,gBAAgB;AAyBlB,SAAS,uBACd,OACA,UACwB;AACxB,SAAO,iBAAiB,SAAS,YAC7B,yBAAyB,OAAO,QAAS,IACzC,uBAAuB,KAAK;AAClC;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachWeekOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachWeekOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const daysToSubtractStart = startZoned.dayOfWeek - 1;
|
|
12
|
+
const startMonday = startZoned.subtract({ days: daysToSubtractStart }).startOfDay();
|
|
13
|
+
const endInTimezone = endZoned.withTimeZone(timezone);
|
|
14
|
+
const daysToSubtractEnd = endInTimezone.dayOfWeek - 1;
|
|
15
|
+
const endMonday = endInTimezone.subtract({ days: daysToSubtractEnd }).startOfDay();
|
|
16
|
+
const weeks = [];
|
|
17
|
+
let current = startMonday;
|
|
18
|
+
while (Temporal.ZonedDateTime.compare(current, endMonday) <= 0) {
|
|
19
|
+
weeks.push(current);
|
|
20
|
+
current = current.add({ weeks: 1 });
|
|
21
|
+
}
|
|
22
|
+
return weeks;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
eachWeekOfInterval
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-OLEOU3XE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachWeekOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each week within the interval.\n * Each element represents the first moment of the week (Monday at midnight).\n * Uses ISO 8601 week definition: weeks start on Monday.\n * The interval is inclusive of both start and end weeks.\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 week (Monday) in the interval\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2025-01-06T10:00:00Z[UTC]'); // Monday\n * const end = Temporal.ZonedDateTime.from('2025-01-22T14:00:00Z[UTC]'); // Wednesday\n *\n * const weeks = eachWeekOfInterval({ start, end });\n * // [\n * // 2025-01-06T00:00:00Z[UTC], // Week 2\n * // 2025-01-13T00:00:00Z[UTC], // Week 3\n * // 2025-01-20T00:00:00Z[UTC] // Week 4\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Mid-week start\n * const start = Temporal.ZonedDateTime.from('2025-01-08T10:00:00Z[UTC]'); // Wednesday\n * const end = Temporal.ZonedDateTime.from('2025-01-15T14:00:00Z[UTC]'); // Wednesday\n *\n * const weeks = eachWeekOfInterval({ start, end });\n * // [\n * // 2025-01-06T00:00:00Z[UTC], // Monday of week containing Jan 8\n * // 2025-01-13T00:00:00Z[UTC] // Monday of week containing Jan 15\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Cross-year boundary\n * const start = Temporal.ZonedDateTime.from('2024-12-25T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-08T00:00:00Z[UTC]');\n *\n * const weeks = eachWeekOfInterval({ start, end });\n * // [\n * // 2024-12-23T00:00:00Z[UTC], // Monday of week containing Dec 25\n * // 2024-12-30T00:00:00Z[UTC], // Monday of week containing Dec 30\n * // 2025-01-06T00:00:00Z[UTC] // Monday of week containing Jan 8\n * // ]\n * ```\n */\nexport function eachWeekOfInterval(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 Monday of the starting week\n // dayOfWeek: 1 = Monday, 7 = Sunday (ISO 8601)\n const daysToSubtractStart = startZoned.dayOfWeek - 1;\n const startMonday = startZoned.subtract({ days: daysToSubtractStart }).startOfDay();\n\n // Get Monday of the ending week\n const endInTimezone = endZoned.withTimeZone(timezone);\n const daysToSubtractEnd = endInTimezone.dayOfWeek - 1;\n const endMonday = endInTimezone.subtract({ days: daysToSubtractEnd }).startOfDay();\n\n const weeks: Temporal.ZonedDateTime[] = [];\n let current = startMonday;\n\n while (Temporal.ZonedDateTime.compare(current, endMonday) <= 0) {\n weeks.push(current);\n current = current.add({ weeks: 1 });\n }\n\n return weeks;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAuDlB,SAAS,mBAAmB,UAGN;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAI5B,QAAM,sBAAsB,WAAW,YAAY;AACnD,QAAM,cAAc,WAAW,SAAS,EAAE,MAAM,oBAAoB,CAAC,EAAE,WAAW;AAGlF,QAAM,gBAAgB,SAAS,aAAa,QAAQ;AACpD,QAAM,oBAAoB,cAAc,YAAY;AACpD,QAAM,YAAY,cAAc,SAAS,EAAE,MAAM,kBAAkB,CAAC,EAAE,WAAW;AAEjF,QAAM,QAAkC,CAAC;AACzC,MAAI,UAAU;AAEd,SAAO,SAAS,cAAc,QAAQ,SAAS,SAAS,KAAK,GAAG;AAC9D,UAAM,KAAK,OAAO;AAClB,cAAU,QAAQ,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,EACpC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
import {
|
|
5
|
+
getEndOfDay
|
|
6
|
+
} from "./chunk-AVGNRINZ.js";
|
|
7
|
+
|
|
8
|
+
// src/endOfMonth.ts
|
|
9
|
+
import "@js-temporal/polyfill";
|
|
10
|
+
function endOfMonth(input, timezone) {
|
|
11
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
12
|
+
const lastDay = zonedDateTime.with({ day: zonedDateTime.daysInMonth });
|
|
13
|
+
return getEndOfDay(lastDay);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
endOfMonth
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-OQ4CWKJT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/endOfMonth.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\nimport { getEndOfDay } from './shared/endOfDay';\nimport { normalizeWithPlainDate } from './shared/normalizeWithPlainDate';\n\n/**\n * Returns a ZonedDateTime representing the last moment of the month (last day at 23:59:59.999999999).\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @returns ZonedDateTime at the last day of the month at 23:59:59.999999999\n *\n * @example\n * ```ts\n * // From Instant (always UTC)\n * const instant = Temporal.Instant.from('2025-01-15T12:00:00Z');\n * const end = endOfMonth(instant);\n * // 2025-01-31T23:59:59.999999999Z[UTC]\n * ```\n *\n * @example\n * ```ts\n * // From ZonedDateTime (uses its timezone)\n * const zoned = Temporal.ZonedDateTime.from('2025-02-15T15:30:00-05:00[America/New_York]');\n * const end = endOfMonth(zoned);\n * // 2025-02-28T23: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-02-15');\n * const end = endOfMonth(date, 'America/New_York');\n * // 2025-02-28T23:59:59.999999999-05:00[America/New_York]\n * ```\n */\nexport function endOfMonth(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): Temporal.ZonedDateTime;\nexport function endOfMonth(\n input: Temporal.PlainDate,\n timezone: Timezone\n): Temporal.ZonedDateTime;\nexport function endOfMonth(\n input: Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDate,\n timezone?: Timezone\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeWithPlainDate(input, timezone!);\n const lastDay = zonedDateTime.with({ day: zonedDateTime.daysInMonth });\n return getEndOfDay(lastDay);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AA0ClB,SAAS,WACd,OACA,UACwB;AACxB,QAAM,gBAAgB,uBAAuB,OAAO,QAAS;AAC7D,QAAM,UAAU,cAAc,KAAK,EAAE,KAAK,cAAc,YAAY,CAAC;AACrE,SAAO,YAAY,OAAO;AAC5B;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMilliseconds
|
|
3
|
+
} from "./chunk-AJ4JBKJK.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeTemporalInput
|
|
3
6
|
} from "./chunk-MJSZNWCV.js";
|
|
@@ -7,10 +10,10 @@ import "@js-temporal/polyfill";
|
|
|
7
10
|
function differenceInHours(laterDate, earlierDate) {
|
|
8
11
|
const zoned1 = normalizeTemporalInput(laterDate);
|
|
9
12
|
const zoned2 = normalizeTemporalInput(earlierDate);
|
|
10
|
-
return Math.trunc((zoned1
|
|
13
|
+
return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 36e5);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
|
14
17
|
differenceInHours
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-PMJD5N5J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/differenceInHours.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { differenceInMilliseconds } from './shared/differenceInMilliseconds';\n\n/**\n * Returns the number of hours 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 * @returns The number of hours between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T18:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T15:00:00Z');\n *\n * differenceInHours(later, earlier); // 3\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-21T00:00:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');\n *\n * differenceInHours(later, earlier); // 9\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 * differenceInHours(tokyo, ny); // 0 (same instant)\n * ```\n */\nexport function differenceInHours(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime\n): number {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 3600000);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AAsClB,SAAS,kBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,MAAM,yBAAyB,QAAQ,MAAM,IAAI,IAAO;AACtE;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/nowZoned.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function nowZoned() {
|
|
8
|
+
return normalizeTemporalInput(Temporal.Now.instant());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
nowZoned
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-QFNGYTTH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/nowZoned.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './normalizeTemporalInput';\n\nexport function nowZoned(): Temporal.ZonedDateTime {\n return normalizeTemporalInput(Temporal.Now.instant());\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAGlB,SAAS,WAAmC;AACjD,SAAO,uBAAuB,SAAS,IAAI,QAAQ,CAAC;AACtD;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMilliseconds
|
|
3
|
+
} from "./chunk-AJ4JBKJK.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeTemporalInput
|
|
3
6
|
} from "./chunk-MJSZNWCV.js";
|
|
@@ -7,10 +10,10 @@ import "@js-temporal/polyfill";
|
|
|
7
10
|
function differenceInSeconds(laterDate, earlierDate) {
|
|
8
11
|
const zoned1 = normalizeTemporalInput(laterDate);
|
|
9
12
|
const zoned2 = normalizeTemporalInput(earlierDate);
|
|
10
|
-
return Math.trunc((zoned1
|
|
13
|
+
return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 1e3);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
|
14
17
|
differenceInSeconds
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-QVOEXF46.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/differenceInSeconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { differenceInMilliseconds } from './shared/differenceInMilliseconds';\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 * @returns The number of seconds between the dates\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): number {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n return Math.trunc(differenceInMilliseconds(zoned1, zoned2) / 1000);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AAsClB,SAAS,oBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,MAAM,yBAAyB,QAAQ,MAAM,IAAI,GAAI;AACnE;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachMonthOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachMonthOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const startYearMonth = Temporal.PlainYearMonth.from({
|
|
12
|
+
year: startZoned.year,
|
|
13
|
+
month: startZoned.month
|
|
14
|
+
});
|
|
15
|
+
const endInTimezone = endZoned.withTimeZone(timezone);
|
|
16
|
+
const endYearMonth = Temporal.PlainYearMonth.from({
|
|
17
|
+
year: endInTimezone.year,
|
|
18
|
+
month: endInTimezone.month
|
|
19
|
+
});
|
|
20
|
+
const months = [];
|
|
21
|
+
let current = startYearMonth;
|
|
22
|
+
while (Temporal.PlainYearMonth.compare(current, endYearMonth) <= 0) {
|
|
23
|
+
const firstOfMonth = current.toPlainDate({ day: 1 });
|
|
24
|
+
months.push(
|
|
25
|
+
firstOfMonth.toZonedDateTime({
|
|
26
|
+
timeZone: timezone,
|
|
27
|
+
plainTime: new Temporal.PlainTime()
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
current = current.add({ months: 1 });
|
|
31
|
+
}
|
|
32
|
+
return months;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
eachMonthOfInterval
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-TNCLJK4Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachMonthOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\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":";;;;;AAAA,SAAS,gBAAgB;AA2ClB,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,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isBefore
|
|
3
|
+
} from "./chunk-WUAIUEH7.js";
|
|
4
|
+
import {
|
|
5
|
+
nowZoned
|
|
6
|
+
} from "./chunk-QFNGYTTH.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeTemporalInput
|
|
9
|
+
} from "./chunk-MJSZNWCV.js";
|
|
10
|
+
|
|
11
|
+
// src/isPast.ts
|
|
12
|
+
function isPast(date) {
|
|
13
|
+
const zoned = normalizeTemporalInput(date);
|
|
14
|
+
return isBefore(zoned, nowZoned());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
isPast
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-UBY22QWM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isPast.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { isBefore } from './shared/isBefore';\nimport { nowZoned } from './shared/nowZoned';\n\n/**\n * Returns true if the given datetime is in the past.\n * Compares by the underlying instant (epoch time) against the current time.\n *\n * @param date - Datetime to check (Instant or ZonedDateTime)\n * @returns true if date is before the current instant, false otherwise\n *\n * @example\n * ```ts\n * const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });\n * const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });\n *\n * isPast(yesterday); // true\n * isPast(tomorrow); // false\n * ```\n *\n * @example\n * ```ts\n * // Works with Instant too\n * const pastInstant = Temporal.Now.instant().subtract({ hours: 1 });\n *\n * isPast(pastInstant); // true\n * ```\n *\n * @example\n * ```ts\n * // Works with any timezone\n * const pastInTokyo = Temporal.ZonedDateTime.from('1970-01-01T00:00:00+09:00[Asia/Tokyo]');\n *\n * isPast(pastInTokyo); // true\n * ```\n */\nexport function isPast(\n date: Temporal.Instant | Temporal.ZonedDateTime\n): boolean {\n const zoned = normalizeTemporalInput(date);\n\n return isBefore(zoned, nowZoned());\n}\n"],"mappings":";;;;;;;;;;;AAqCO,SAAS,OACd,MACS;AACT,QAAM,QAAQ,uBAAuB,IAAI;AAEzC,SAAO,SAAS,OAAO,SAAS,CAAC;AACnC;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/eachHourOfInterval.ts
|
|
6
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
7
|
+
function eachHourOfInterval(interval) {
|
|
8
|
+
const startZoned = normalizeTemporalInput(interval.start);
|
|
9
|
+
const endZoned = normalizeTemporalInput(interval.end);
|
|
10
|
+
const timezone = startZoned.timeZoneId;
|
|
11
|
+
const startHour = startZoned.round({ smallestUnit: "hour", roundingMode: "floor" });
|
|
12
|
+
const endInTimezone = endZoned.withTimeZone(timezone);
|
|
13
|
+
const endHour = endInTimezone.round({ smallestUnit: "hour", roundingMode: "floor" });
|
|
14
|
+
const hours = [];
|
|
15
|
+
let current = startHour;
|
|
16
|
+
while (Temporal.ZonedDateTime.compare(current, endHour) <= 0) {
|
|
17
|
+
hours.push(current);
|
|
18
|
+
current = current.add({ hours: 1 });
|
|
19
|
+
}
|
|
20
|
+
return hours;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
eachHourOfInterval
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=chunk-Y7CIJQ67.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eachHourOfInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns an array of ZonedDateTime objects for each hour within the interval.\n * Each element represents the start of the hour (minute/second/etc. set to 0).\n * The interval is inclusive of both start and end hours.\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 * Note: During DST transitions, some hours may be skipped (spring forward) or\n * the array may contain fewer/more hours than expected based on wall-clock time.\n *\n * @param interval - The interval with start and end datetimes\n * @returns Array of ZonedDateTime at start of each hour 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-06T14:15:00Z[UTC]');\n *\n * const hours = eachHourOfInterval({ start, end });\n * // [\n * // 2025-01-06T10:00:00Z[UTC],\n * // 2025-01-06T11:00:00Z[UTC],\n * // 2025-01-06T12:00:00Z[UTC],\n * // 2025-01-06T13:00:00Z[UTC],\n * // 2025-01-06T14:00:00Z[UTC]\n * // ]\n * ```\n *\n * @example\n * ```ts\n * // Cross-day boundary\n * const start = Temporal.ZonedDateTime.from('2025-01-06T22:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T02:00:00Z[UTC]');\n *\n * const hours = eachHourOfInterval({ start, end });\n * // [\n * // 2025-01-06T22:00:00Z[UTC],\n * // 2025-01-06T23:00:00Z[UTC],\n * // 2025-01-07T00:00:00Z[UTC],\n * // 2025-01-07T01:00:00Z[UTC],\n * // 2025-01-07T02:00:00Z[UTC]\n * // ]\n * ```\n */\nexport function eachHourOfInterval(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 hour\n const startHour = startZoned.round({ smallestUnit: 'hour', roundingMode: 'floor' });\n\n // Get start of the ending hour in the same timezone\n const endInTimezone = endZoned.withTimeZone(timezone);\n const endHour = endInTimezone.round({ smallestUnit: 'hour', roundingMode: 'floor' });\n\n const hours: Temporal.ZonedDateTime[] = [];\n let current = startHour;\n\n while (Temporal.ZonedDateTime.compare(current, endHour) <= 0) {\n hours.push(current);\n current = current.add({ hours: 1 });\n }\n\n return hours;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAgDlB,SAAS,mBAAmB,UAGN;AAC3B,QAAM,aAAa,uBAAuB,SAAS,KAAK;AACxD,QAAM,WAAW,uBAAuB,SAAS,GAAG;AAEpD,QAAM,WAAW,WAAW;AAG5B,QAAM,YAAY,WAAW,MAAM,EAAE,cAAc,QAAQ,cAAc,QAAQ,CAAC;AAGlF,QAAM,gBAAgB,SAAS,aAAa,QAAQ;AACpD,QAAM,UAAU,cAAc,MAAM,EAAE,cAAc,QAAQ,cAAc,QAAQ,CAAC;AAEnF,QAAM,QAAkC,CAAC;AACzC,MAAI,UAAU;AAEd,SAAO,SAAS,cAAc,QAAQ,SAAS,OAAO,KAAK,GAAG;AAC5D,UAAM,KAAK,OAAO;AAClB,cAAU,QAAQ,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,EACpC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeWithPlainDate
|
|
3
|
+
} from "./chunk-KGVUENQO.js";
|
|
4
|
+
|
|
5
|
+
// src/startOfDay.ts
|
|
6
|
+
import "@js-temporal/polyfill";
|
|
7
|
+
function startOfDay(input, timezone) {
|
|
8
|
+
const zonedDateTime = normalizeWithPlainDate(input, timezone);
|
|
9
|
+
return zonedDateTime.startOfDay();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
startOfDay
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-YIT6EMBC.js.map
|