@gobrand/tiempo 2.5.4 → 2.6.1
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-5C3TQSWA.js +23 -0
- package/dist/chunk-5C3TQSWA.js.map +1 -0
- package/dist/{chunk-BBNNR2QH.js → chunk-7VLSSOVC.js} +8 -5
- package/dist/{chunk-BBNNR2QH.js.map → chunk-7VLSSOVC.js.map} +1 -1
- package/dist/chunk-HFQUXON5.js +41 -0
- package/dist/chunk-HFQUXON5.js.map +1 -0
- package/dist/chunk-JHRXY36W.js +25 -0
- package/dist/chunk-JHRXY36W.js.map +1 -0
- package/dist/chunk-MMI2HHT7.js +25 -0
- package/dist/chunk-MMI2HHT7.js.map +1 -0
- package/dist/chunk-UJW2FPI4.js +25 -0
- package/dist/chunk-UJW2FPI4.js.map +1 -0
- package/dist/chunk-UJWM2BV2.js +41 -0
- package/dist/chunk-UJWM2BV2.js.map +1 -0
- package/dist/chunk-WUAIUEH7.js +10 -0
- package/dist/chunk-WUAIUEH7.js.map +1 -0
- package/dist/chunk-WY63VEXE.js +10 -0
- package/dist/chunk-WY63VEXE.js.map +1 -0
- package/dist/chunk-ZDA7GSWU.js +19 -0
- package/dist/chunk-ZDA7GSWU.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -34
- package/dist/isAfter.d.ts.map +1 -1
- package/dist/isAfter.js +2 -1
- package/dist/isBefore.d.ts.map +1 -1
- package/dist/isBefore.js +2 -1
- package/dist/isWithinInterval.d.ts +71 -0
- package/dist/isWithinInterval.d.ts.map +1 -0
- package/dist/isWithinInterval.js +10 -0
- package/dist/isWithinInterval.js.map +1 -0
- package/dist/isWithinInterval.test.d.ts +2 -0
- package/dist/isWithinInterval.test.d.ts.map +1 -0
- package/dist/roundToNearestHour.d.ts +77 -0
- package/dist/roundToNearestHour.d.ts.map +1 -0
- package/dist/roundToNearestHour.js +8 -0
- package/dist/roundToNearestHour.js.map +1 -0
- package/dist/roundToNearestHour.test.d.ts +2 -0
- package/dist/roundToNearestHour.test.d.ts.map +1 -0
- package/dist/roundToNearestMinute.d.ts +76 -0
- package/dist/roundToNearestMinute.d.ts.map +1 -0
- package/dist/roundToNearestMinute.js +8 -0
- package/dist/roundToNearestMinute.js.map +1 -0
- package/dist/roundToNearestMinute.test.d.ts +2 -0
- package/dist/roundToNearestMinute.test.d.ts.map +1 -0
- package/dist/roundToNearestSecond.d.ts +75 -0
- package/dist/roundToNearestSecond.d.ts.map +1 -0
- package/dist/roundToNearestSecond.js +8 -0
- package/dist/roundToNearestSecond.js.map +1 -0
- package/dist/roundToNearestSecond.test.d.ts +2 -0
- package/dist/roundToNearestSecond.test.d.ts.map +1 -0
- package/dist/shared/isAfter.d.ts +3 -0
- package/dist/shared/isAfter.d.ts.map +1 -0
- package/dist/shared/isAfter.js +7 -0
- package/dist/shared/isAfter.js.map +1 -0
- package/dist/shared/isBefore.d.ts +3 -0
- package/dist/shared/isBefore.d.ts.map +1 -0
- package/dist/shared/isBefore.js +7 -0
- package/dist/shared/isBefore.js.map +1 -0
- package/dist/toPlainDate.d.ts +14 -7
- package/dist/toPlainDate.d.ts.map +1 -1
- package/dist/toPlainDate.js +1 -1
- package/dist/toPlainTime.d.ts +15 -7
- package/dist/toPlainTime.d.ts.map +1 -1
- package/dist/toPlainTime.js +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-G45S5B4O.js +0 -25
- package/dist/chunk-G45S5B4O.js.map +0 -1
- package/dist/chunk-IPJUERCK.js +0 -16
- package/dist/chunk-IPJUERCK.js.map +0 -1
- package/dist/chunk-UCCWUJ2K.js +0 -25
- package/dist/chunk-UCCWUJ2K.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAfter
|
|
3
|
+
} from "./chunk-WY63VEXE.js";
|
|
4
|
+
import {
|
|
5
|
+
isBefore
|
|
6
|
+
} from "./chunk-WUAIUEH7.js";
|
|
7
|
+
import {
|
|
8
|
+
normalizeTemporalInput
|
|
9
|
+
} from "./chunk-MJSZNWCV.js";
|
|
10
|
+
|
|
11
|
+
// src/isWithinInterval.ts
|
|
12
|
+
import "@js-temporal/polyfill";
|
|
13
|
+
function isWithinInterval(date, interval) {
|
|
14
|
+
const normalizedDate = normalizeTemporalInput(date);
|
|
15
|
+
const normalizedStart = normalizeTemporalInput(interval.start);
|
|
16
|
+
const normalizedEnd = normalizeTemporalInput(interval.end);
|
|
17
|
+
return !isBefore(normalizedDate, normalizedStart) && !isAfter(normalizedDate, normalizedEnd);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
isWithinInterval
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-5C3TQSWA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isWithinInterval.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { isBefore } from './shared/isBefore';\nimport { isAfter } from './shared/isAfter';\n\n/**\n * Returns true if the given date is within the interval (inclusive of start and end).\n * Compares by the underlying instant (epoch time), not by calendar date/time.\n *\n * @param date - The date to check (Instant or ZonedDateTime)\n * @param interval - The interval with start and end dates\n * @returns true if date is within the interval, false otherwise\n *\n * @example\n * ```ts\n * const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');\n * const date = Temporal.ZonedDateTime.from('2025-01-03T00:00:00Z[UTC]');\n *\n * isWithinInterval(date, { start, end }); // true\n * ```\n *\n * @example\n * ```ts\n * // Date outside the interval\n * const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');\n * const date = Temporal.ZonedDateTime.from('2025-01-10T00:00:00Z[UTC]');\n *\n * isWithinInterval(date, { start, end }); // false\n * ```\n *\n * @example\n * ```ts\n * // Date equal to interval start (inclusive)\n * const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');\n *\n * isWithinInterval(start, { start, end }); // true\n * ```\n *\n * @example\n * ```ts\n * // Date equal to interval end (inclusive)\n * const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');\n *\n * isWithinInterval(end, { start, end }); // true\n * ```\n *\n * @example\n * ```ts\n * // Works with Instant too\n * const start = Temporal.Instant.from('2025-01-01T00:00:00Z');\n * const end = Temporal.Instant.from('2025-01-07T00:00:00Z');\n * const date = Temporal.Instant.from('2025-01-03T00:00:00Z');\n *\n * isWithinInterval(date, { start, end }); // true\n * ```\n *\n * @example\n * ```ts\n * // Different timezones - compares by instant\n * const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00-05:00[America/New_York]');\n * const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00+09:00[Asia/Tokyo]');\n * const date = Temporal.ZonedDateTime.from('2025-01-03T12:00:00Z[UTC]');\n *\n * isWithinInterval(date, { start, end }); // true\n * ```\n */\nexport function isWithinInterval(\n date: Temporal.Instant | Temporal.ZonedDateTime,\n interval: {\n start: Temporal.Instant | Temporal.ZonedDateTime;\n end: Temporal.Instant | Temporal.ZonedDateTime;\n }\n): boolean {\n const normalizedDate = normalizeTemporalInput(date);\n const normalizedStart = normalizeTemporalInput(interval.start);\n const normalizedEnd = normalizeTemporalInput(interval.end);\n\n return !isBefore(normalizedDate, normalizedStart) && !isAfter(normalizedDate, normalizedEnd);\n}\n"],"mappings":";;;;;;;;;;;AAAA,OAAyB;AAsElB,SAAS,iBACd,MACA,UAIS;AACT,QAAM,iBAAiB,uBAAuB,IAAI;AAClD,QAAM,kBAAkB,uBAAuB,SAAS,KAAK;AAC7D,QAAM,gBAAgB,uBAAuB,SAAS,GAAG;AAEzD,SAAO,CAAC,SAAS,gBAAgB,eAAe,KAAK,CAAC,QAAQ,gBAAgB,aAAa;AAC7F;","names":[]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAfter
|
|
3
|
+
} from "./chunk-WY63VEXE.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeTemporalInput
|
|
3
6
|
} from "./chunk-MJSZNWCV.js";
|
|
4
7
|
|
|
5
8
|
// src/isAfter.ts
|
|
6
|
-
import
|
|
7
|
-
function
|
|
9
|
+
import "@js-temporal/polyfill";
|
|
10
|
+
function isAfter2(date1, date2) {
|
|
8
11
|
const zoned1 = normalizeTemporalInput(date1);
|
|
9
12
|
const zoned2 = normalizeTemporalInput(date2);
|
|
10
|
-
return
|
|
13
|
+
return isAfter(zoned1, zoned2);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
|
14
|
-
isAfter
|
|
17
|
+
isAfter2 as isAfter
|
|
15
18
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-7VLSSOVC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isAfter.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns true if the first datetime is after 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 after 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 * isAfter(later, earlier); // true\n * isAfter(earlier, later); // false\n * isAfter(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 * isAfter(instant2, instant1); // 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 * isAfter(tokyo, ny); // false\n * // NY 10:00 is 15:00 UTC, Tokyo 00:00 is 15:00 UTC the previous day (same instant)\n * ```\n */\nexport function isAfter(\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
|
|
1
|
+
{"version":3,"sources":["../src/isAfter.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport { isAfter as isAfterInternal } from './shared/isAfter';\n\n/**\n * Returns true if the first datetime is after 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 after 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 * isAfter(later, earlier); // true\n * isAfter(earlier, later); // false\n * isAfter(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 * isAfter(instant2, instant1); // 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 * isAfter(tokyo, ny); // false\n * // NY 10:00 is 15:00 UTC, Tokyo 00:00 is 15:00 UTC the previous day (same instant)\n * ```\n */\nexport function isAfter(\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 isAfterInternal(zoned1, zoned2);\n}\n"],"mappings":";;;;;;;;AAAA,OAAyB;AAyClB,SAASA,SACd,OACA,OACS;AACT,QAAM,SAAS,uBAAuB,KAAK;AAC3C,QAAM,SAAS,uBAAuB,KAAK;AAE3C,SAAO,QAAgB,QAAQ,MAAM;AACvC;","names":["isAfter"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/toPlainDate.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
var PLAIN_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
4
|
+
function toPlainDate(input, timezone) {
|
|
5
|
+
if (input instanceof Temporal.ZonedDateTime && timezone === void 0) {
|
|
6
|
+
return input.toPlainDate();
|
|
7
|
+
}
|
|
8
|
+
if (input instanceof Date) {
|
|
9
|
+
if (timezone === void 0) {
|
|
10
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string");
|
|
11
|
+
}
|
|
12
|
+
return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone).toPlainDate();
|
|
13
|
+
}
|
|
14
|
+
if (input instanceof Temporal.Instant) {
|
|
15
|
+
if (timezone === void 0) {
|
|
16
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string");
|
|
17
|
+
}
|
|
18
|
+
return input.toZonedDateTimeISO(timezone).toPlainDate();
|
|
19
|
+
}
|
|
20
|
+
if (input instanceof Temporal.ZonedDateTime) {
|
|
21
|
+
if (timezone === void 0) {
|
|
22
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string");
|
|
23
|
+
}
|
|
24
|
+
return input.toInstant().toZonedDateTimeISO(timezone).toPlainDate();
|
|
25
|
+
}
|
|
26
|
+
if (typeof input === "string") {
|
|
27
|
+
if (timezone !== void 0) {
|
|
28
|
+
return Temporal.Instant.from(input).toZonedDateTimeISO(timezone).toPlainDate();
|
|
29
|
+
}
|
|
30
|
+
if (PLAIN_DATE_PATTERN.test(input)) {
|
|
31
|
+
return Temporal.PlainDate.from(input);
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string");
|
|
34
|
+
}
|
|
35
|
+
return Temporal.PlainDate.from(input);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
toPlainDate
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-HFQUXON5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toPlainDate.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n// Pattern to detect plain date strings: YYYY-MM-DD\nconst PLAIN_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/**\n * Parse a plain date or extract the calendar date from a datetime.\n *\n * @param input - A PlainDateLike object, plain date string (YYYY-MM-DD), ZonedDateTime, or datetime input requiring timezone\n * @param timezone - IANA timezone identifier. Required for ISO strings, Date, and Instant inputs.\n * @returns A Temporal.PlainDate representing the calendar date\n *\n * @example\n * ```typescript\n * import { toPlainDate, toZonedTime } from '@gobrand/tiempo';\n *\n * // From PlainDateLike object (no timezone needed)\n * const date = toPlainDate({ year: 2025, month: 1, day: 20 }); // 2025-01-20\n *\n * // From plain date string (no timezone needed)\n * const date2 = toPlainDate(\"2025-01-20\"); // 2025-01-20\n *\n * // From ZonedDateTime (no timezone needed)\n * const zdt = toZonedTime(\"2025-01-20T15:30:00Z\", \"America/New_York\");\n * const date3 = toPlainDate(zdt); // 2025-01-20\n *\n * // From UTC string with timezone\n * const date4 = toPlainDate(\"2025-01-20T15:30:00Z\", \"America/New_York\"); // 2025-01-20\n *\n * // From Date with timezone\n * const jsDate = new Date(\"2025-01-20T15:30:00.000Z\");\n * const date5 = toPlainDate(jsDate, \"Europe/London\"); // 2025-01-20\n *\n * // Date boundary crossing: 23:00 UTC on Jan 20 → Jan 21 in Tokyo\n * const date6 = toPlainDate(\"2025-01-20T23:00:00Z\", \"Asia/Tokyo\"); // 2025-01-21\n * ```\n */\nexport function toPlainDate(input: Temporal.ZonedDateTime): Temporal.PlainDate;\nexport function toPlainDate(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: Timezone\n): Temporal.PlainDate;\nexport function toPlainDate(input: Temporal.PlainDateLike | string): Temporal.PlainDate;\nexport function toPlainDate(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDateLike,\n timezone?: Timezone\n): Temporal.PlainDate {\n // ZonedDateTime without timezone override\n if (input instanceof Temporal.ZonedDateTime && timezone === undefined) {\n return input.toPlainDate();\n }\n\n // Date requires timezone\n if (input instanceof Date) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string');\n }\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone).toPlainDate();\n }\n\n // Instant requires timezone\n if (input instanceof Temporal.Instant) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string');\n }\n return input.toZonedDateTimeISO(timezone).toPlainDate();\n }\n\n // ZonedDateTime with timezone override\n if (input instanceof Temporal.ZonedDateTime) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string');\n }\n return input.toInstant().toZonedDateTimeISO(timezone).toPlainDate();\n }\n\n // String: ISO datetime (requires timezone) or plain date (no timezone)\n if (typeof input === 'string') {\n if (timezone !== undefined) {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone).toPlainDate();\n }\n if (PLAIN_DATE_PATTERN.test(input)) {\n return Temporal.PlainDate.from(input);\n }\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainDateLike, or plain date string');\n }\n\n // PlainDateLike object - pass directly to Temporal.PlainDate.from()\n return Temporal.PlainDate.from(input);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAIzB,IAAM,qBAAqB;AAwCpB,SAAS,YACd,OACA,UACoB;AAEpB,MAAI,iBAAiB,SAAS,iBAAiB,aAAa,QAAW;AACrE,WAAO,MAAM,YAAY;AAAA,EAC3B;AAGA,MAAI,iBAAiB,MAAM;AACzB,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EAC7F;AAGA,MAAI,iBAAiB,SAAS,SAAS;AACrC,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,MAAM,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EACxD;AAGA,MAAI,iBAAiB,SAAS,eAAe;AAC3C,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EACpE;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,aAAa,QAAW;AAC1B,aAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,IAC/E;AACA,QAAI,mBAAmB,KAAK,KAAK,GAAG;AAClC,aAAO,SAAS,UAAU,KAAK,KAAK;AAAA,IACtC;AACA,UAAM,IAAI,MAAM,2FAA2F;AAAA,EAC7G;AAGA,SAAO,SAAS,UAAU,KAAK,KAAK;AACtC;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/roundToNearestSecond.ts
|
|
6
|
+
var MODE_TO_ROUNDING_MODE = {
|
|
7
|
+
round: "halfExpand",
|
|
8
|
+
ceil: "ceil",
|
|
9
|
+
floor: "floor"
|
|
10
|
+
};
|
|
11
|
+
function roundToNearestSecond(input, options) {
|
|
12
|
+
const zonedDateTime = normalizeTemporalInput(input);
|
|
13
|
+
const mode = options?.mode ?? "round";
|
|
14
|
+
const nearestTo = options?.nearestTo ?? 1;
|
|
15
|
+
return zonedDateTime.round({
|
|
16
|
+
smallestUnit: "second",
|
|
17
|
+
roundingMode: MODE_TO_ROUNDING_MODE[mode],
|
|
18
|
+
roundingIncrement: nearestTo
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
roundToNearestSecond
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-JHRXY36W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/roundToNearestSecond.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Options for rounding to nearest second.\n */\nexport interface RoundToNearestSecondOptions {\n /**\n * The rounding mode to use.\n *\n * Given time 14:37:42.300:\n * - `'round'` → 14:37:42 (300ms < 500, rounds DOWN to nearest)\n * - `'ceil'` → 14:37:43 (always rounds UP to next second)\n * - `'floor'` → 14:37:42 (always rounds DOWN to current second)\n *\n * Given time 14:37:42 with nearestTo: 10:\n * - `'round'` → 14:37:40 (42 is closer to 40 than 50)\n * - `'ceil'` → 14:37:50 (always rounds UP to next 10-sec mark)\n * - `'floor'` → 14:37:40 (always rounds DOWN to current 10-sec mark)\n *\n * @default 'round'\n */\n mode?: 'round' | 'ceil' | 'floor';\n /**\n * Round to the nearest N seconds. Must divide evenly into 60.\n * Valid values: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30\n * @example nearestTo: 10 rounds to 10-second marks (00, 10, 20, 30, 40, 50)\n */\n nearestTo?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30;\n}\n\nconst MODE_TO_ROUNDING_MODE = {\n round: 'halfExpand',\n ceil: 'ceil',\n floor: 'floor',\n} as const;\n\n/**\n * Rounds a datetime to the nearest second boundary.\n *\n * ## Mode comparison (given 14:37:42.567)\n *\n * ```\n * :42 ─────────────────●─────────────── :43\n * .567\n *\n * 'round' → :43 (nearest second - 567ms >= 500)\n * 'ceil' → :43 (next second - always up)\n * 'floor' → :42 (current second - always down)\n * ```\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @param options - Rounding options\n * @returns ZonedDateTime rounded to the second boundary\n *\n * @example\n * ```ts\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:37:42.567[America/New_York]');\n *\n * roundToNearestSecond(time); // → 14:37:43 (567ms >= 500)\n * roundToNearestSecond(time, { mode: 'ceil' }); // → 14:37:43 (always up)\n * roundToNearestSecond(time, { mode: 'floor' }); // → 14:37:42 (always down)\n * ```\n *\n * @example\n * ```ts\n * // 10-second intervals\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:37:42[America/New_York]');\n *\n * roundToNearestSecond(time, { nearestTo: 10 }); // → 14:37:40 (nearest)\n * roundToNearestSecond(time, { mode: 'ceil', nearestTo: 10 }); // → 14:37:50 (next 10s)\n * roundToNearestSecond(time, { mode: 'floor', nearestTo: 10 }); // → 14:37:40 (current 10s)\n * ```\n *\n * @example\n * ```ts\n * // Remove sub-second precision for logging\n * const logTime = Temporal.ZonedDateTime.from('2025-01-20T14:37:42.123456789[UTC]');\n * roundToNearestSecond(logTime, { mode: 'floor' });\n * // → 14:37:42.000000000 (clean timestamp)\n * ```\n */\nexport function roundToNearestSecond(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options?: RoundToNearestSecondOptions\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeTemporalInput(input);\n const mode = options?.mode ?? 'round';\n const nearestTo = options?.nearestTo ?? 1;\n\n return zonedDateTime.round({\n smallestUnit: 'second',\n roundingMode: MODE_TO_ROUNDING_MODE[mode],\n roundingIncrement: nearestTo,\n });\n}\n"],"mappings":";;;;;AA+BA,IAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AA+CO,SAAS,qBACd,OACA,SACwB;AACxB,QAAM,gBAAgB,uBAAuB,KAAK;AAClD,QAAM,OAAO,SAAS,QAAQ;AAC9B,QAAM,YAAY,SAAS,aAAa;AAExC,SAAO,cAAc,MAAM;AAAA,IACzB,cAAc;AAAA,IACd,cAAc,sBAAsB,IAAI;AAAA,IACxC,mBAAmB;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/roundToNearestHour.ts
|
|
6
|
+
var MODE_TO_ROUNDING_MODE = {
|
|
7
|
+
round: "halfExpand",
|
|
8
|
+
ceil: "ceil",
|
|
9
|
+
floor: "floor"
|
|
10
|
+
};
|
|
11
|
+
function roundToNearestHour(input, options) {
|
|
12
|
+
const zonedDateTime = normalizeTemporalInput(input);
|
|
13
|
+
const mode = options?.mode ?? "round";
|
|
14
|
+
const nearestTo = options?.nearestTo ?? 1;
|
|
15
|
+
return zonedDateTime.round({
|
|
16
|
+
smallestUnit: "hour",
|
|
17
|
+
roundingMode: MODE_TO_ROUNDING_MODE[mode],
|
|
18
|
+
roundingIncrement: nearestTo
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
roundToNearestHour
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-MMI2HHT7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/roundToNearestHour.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Options for rounding to nearest hour.\n */\nexport interface RoundToNearestHourOptions {\n /**\n * The rounding mode to use.\n *\n * Given time 14:20:\n * - `'round'` → 14:00 (20 min < 30, rounds DOWN to nearest)\n * - `'ceil'` → 15:00 (always rounds UP to next hour)\n * - `'floor'` → 14:00 (always rounds DOWN to current hour)\n *\n * Given time 14:40:\n * - `'round'` → 15:00 (40 min >= 30, rounds UP to nearest)\n * - `'ceil'` → 15:00 (always rounds UP to next hour)\n * - `'floor'` → 14:00 (always rounds DOWN to current hour)\n *\n * @default 'round'\n */\n mode?: 'round' | 'ceil' | 'floor';\n /**\n * Round to the nearest N hours. Must divide evenly into 24.\n * Valid values: 1, 2, 3, 4, 6, 8, 12\n * @example nearestTo: 6 rounds to 00:00, 06:00, 12:00, or 18:00\n */\n nearestTo?: 1 | 2 | 3 | 4 | 6 | 8 | 12;\n}\n\nconst MODE_TO_ROUNDING_MODE = {\n round: 'halfExpand',\n ceil: 'ceil',\n floor: 'floor',\n} as const;\n\n/**\n * Rounds a datetime to the nearest hour boundary.\n *\n * ## Mode comparison (given 14:20)\n *\n * ```\n * 14:00 ─────────────●───────────────── 15:00\n * 14:20\n *\n * 'round' → 14:00 (nearest hour - 20 min < 30)\n * 'ceil' → 15:00 (next hour - always up)\n * 'floor' → 14:00 (current hour - always down)\n * ```\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @param options - Rounding options\n * @returns ZonedDateTime rounded to the hour boundary\n *\n * @example\n * ```ts\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:20:00[America/New_York]');\n *\n * roundToNearestHour(time); // → 14:00 (nearest)\n * roundToNearestHour(time, { mode: 'ceil' }); // → 15:00 (always up)\n * roundToNearestHour(time, { mode: 'floor' }); // → 14:00 (always down)\n * ```\n *\n * @example\n * ```ts\n * // With 37 minutes (past the halfway point)\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:37:00[America/New_York]');\n *\n * roundToNearestHour(time); // → 15:00 (nearest - 37 >= 30)\n * roundToNearestHour(time, { mode: 'ceil' }); // → 15:00 (always up)\n * roundToNearestHour(time, { mode: 'floor' }); // → 14:00 (always down)\n * ```\n *\n * @example\n * ```ts\n * // Round to 6-hour blocks (shift scheduling)\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:00:00[America/New_York]');\n *\n * roundToNearestHour(time, { nearestTo: 6 }); // → 12:00\n * roundToNearestHour(time, { mode: 'ceil', nearestTo: 6 }); // → 18:00\n * roundToNearestHour(time, { mode: 'floor', nearestTo: 6 }); // → 12:00\n * ```\n */\nexport function roundToNearestHour(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options?: RoundToNearestHourOptions\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeTemporalInput(input);\n const mode = options?.mode ?? 'round';\n const nearestTo = options?.nearestTo ?? 1;\n\n return zonedDateTime.round({\n smallestUnit: 'hour',\n roundingMode: MODE_TO_ROUNDING_MODE[mode],\n roundingIncrement: nearestTo,\n });\n}\n"],"mappings":";;;;;AA+BA,IAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AAiDO,SAAS,mBACd,OACA,SACwB;AACxB,QAAM,gBAAgB,uBAAuB,KAAK;AAClD,QAAM,OAAO,SAAS,QAAQ;AAC9B,QAAM,YAAY,SAAS,aAAa;AAExC,SAAO,cAAc,MAAM;AAAA,IACzB,cAAc;AAAA,IACd,cAAc,sBAAsB,IAAI;AAAA,IACxC,mBAAmB;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTemporalInput
|
|
3
|
+
} from "./chunk-MJSZNWCV.js";
|
|
4
|
+
|
|
5
|
+
// src/roundToNearestMinute.ts
|
|
6
|
+
var MODE_TO_ROUNDING_MODE = {
|
|
7
|
+
round: "halfExpand",
|
|
8
|
+
ceil: "ceil",
|
|
9
|
+
floor: "floor"
|
|
10
|
+
};
|
|
11
|
+
function roundToNearestMinute(input, options) {
|
|
12
|
+
const zonedDateTime = normalizeTemporalInput(input);
|
|
13
|
+
const mode = options?.mode ?? "round";
|
|
14
|
+
const nearestTo = options?.nearestTo ?? 1;
|
|
15
|
+
return zonedDateTime.round({
|
|
16
|
+
smallestUnit: "minute",
|
|
17
|
+
roundingMode: MODE_TO_ROUNDING_MODE[mode],
|
|
18
|
+
roundingIncrement: nearestTo
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
roundToNearestMinute
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-UJW2FPI4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/roundToNearestMinute.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Options for rounding to nearest minute.\n */\nexport interface RoundToNearestMinuteOptions {\n /**\n * The rounding mode to use.\n *\n * Given time 14:37:20:\n * - `'round'` → 14:37 (20 sec < 30, rounds DOWN to nearest)\n * - `'ceil'` → 14:38 (always rounds UP to next minute)\n * - `'floor'` → 14:37 (always rounds DOWN to current minute)\n *\n * Given time 14:37:00 with nearestTo: 15:\n * - `'round'` → 14:30 (37 is closer to 30 than 45)\n * - `'ceil'` → 14:45 (always rounds UP to next 15-min slot)\n * - `'floor'` → 14:30 (always rounds DOWN to current 15-min slot)\n *\n * @default 'round'\n */\n mode?: 'round' | 'ceil' | 'floor';\n /**\n * Round to the nearest N minutes. Must divide evenly into 60.\n * Valid values: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30\n * @example nearestTo: 15 rounds to quarter-hour marks (00, 15, 30, 45)\n */\n nearestTo?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30;\n}\n\nconst MODE_TO_ROUNDING_MODE = {\n round: 'halfExpand',\n ceil: 'ceil',\n floor: 'floor',\n} as const;\n\n/**\n * Rounds a datetime to the nearest minute boundary.\n *\n * ## Mode comparison (given 14:37 with 15-min slots)\n *\n * ```\n * 14:30 ─────────●───────────────────── 14:45\n * 14:37\n *\n * 'round' → 14:30 (nearest slot - 37 is closer to 30 than 45)\n * 'ceil' → 14:45 (next slot - always up)\n * 'floor' → 14:30 (current slot - always down)\n * ```\n *\n * @param input - A Temporal.Instant (UTC) or Temporal.ZonedDateTime\n * @param options - Rounding options\n * @returns ZonedDateTime rounded to the minute boundary\n *\n * @example\n * ```ts\n * // 15-minute booking slots at 14:37\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:37:00[America/New_York]');\n *\n * roundToNearestMinute(time, { nearestTo: 15 }); // → 14:30 (nearest)\n * roundToNearestMinute(time, { mode: 'ceil', nearestTo: 15 }); // → 14:45 (next slot)\n * roundToNearestMinute(time, { mode: 'floor', nearestTo: 15 }); // → 14:30 (current slot)\n * ```\n *\n * @example\n * ```ts\n * // Basic minute rounding (no slots)\n * const time = Temporal.ZonedDateTime.from('2025-01-20T14:37:42[America/New_York]');\n *\n * roundToNearestMinute(time); // → 14:38 (42 sec >= 30)\n * roundToNearestMinute(time, { mode: 'ceil' }); // → 14:38 (always up)\n * roundToNearestMinute(time, { mode: 'floor' }); // → 14:37 (always down)\n * ```\n *\n * @example\n * ```ts\n * // Billing: round up to 30-minute increments\n * const sessionEnd = Temporal.ZonedDateTime.from('2025-01-20T11:07:00[America/New_York]');\n * roundToNearestMinute(sessionEnd, { mode: 'ceil', nearestTo: 30 });\n * // → 11:30 (bill for 30 mins even though session was 7 mins)\n * ```\n */\nexport function roundToNearestMinute(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options?: RoundToNearestMinuteOptions\n): Temporal.ZonedDateTime {\n const zonedDateTime = normalizeTemporalInput(input);\n const mode = options?.mode ?? 'round';\n const nearestTo = options?.nearestTo ?? 1;\n\n return zonedDateTime.round({\n smallestUnit: 'minute',\n roundingMode: MODE_TO_ROUNDING_MODE[mode],\n roundingIncrement: nearestTo,\n });\n}\n"],"mappings":";;;;;AA+BA,IAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AAgDO,SAAS,qBACd,OACA,SACwB;AACxB,QAAM,gBAAgB,uBAAuB,KAAK;AAClD,QAAM,OAAO,SAAS,QAAQ;AAC9B,QAAM,YAAY,SAAS,aAAa;AAExC,SAAO,cAAc,MAAM;AAAA,IACzB,cAAc;AAAA,IACd,cAAc,sBAAsB,IAAI;AAAA,IACxC,mBAAmB;AAAA,EACrB,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/toPlainTime.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
var PLAIN_TIME_PATTERN = /^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;
|
|
4
|
+
function toPlainTime(input, timezone) {
|
|
5
|
+
if (input instanceof Temporal.ZonedDateTime && timezone === void 0) {
|
|
6
|
+
return input.toPlainTime();
|
|
7
|
+
}
|
|
8
|
+
if (input instanceof Date) {
|
|
9
|
+
if (timezone === void 0) {
|
|
10
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string");
|
|
11
|
+
}
|
|
12
|
+
return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone).toPlainTime();
|
|
13
|
+
}
|
|
14
|
+
if (input instanceof Temporal.Instant) {
|
|
15
|
+
if (timezone === void 0) {
|
|
16
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string");
|
|
17
|
+
}
|
|
18
|
+
return input.toZonedDateTimeISO(timezone).toPlainTime();
|
|
19
|
+
}
|
|
20
|
+
if (input instanceof Temporal.ZonedDateTime) {
|
|
21
|
+
if (timezone === void 0) {
|
|
22
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string");
|
|
23
|
+
}
|
|
24
|
+
return input.toInstant().toZonedDateTimeISO(timezone).toPlainTime();
|
|
25
|
+
}
|
|
26
|
+
if (typeof input === "string") {
|
|
27
|
+
if (timezone !== void 0) {
|
|
28
|
+
return Temporal.Instant.from(input).toZonedDateTimeISO(timezone).toPlainTime();
|
|
29
|
+
}
|
|
30
|
+
if (PLAIN_TIME_PATTERN.test(input)) {
|
|
31
|
+
return Temporal.PlainTime.from(input);
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string");
|
|
34
|
+
}
|
|
35
|
+
return Temporal.PlainTime.from(input);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
toPlainTime
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-UJWM2BV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toPlainTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n// Pattern to detect plain time strings: HH:MM, HH:MM:SS, or HH:MM:SS.fractional\nconst PLAIN_TIME_PATTERN = /^\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?$/;\n\n/**\n * Parse a plain time or extract the wall-clock time from a datetime.\n *\n * @param input - A PlainTimeLike object, plain time string (HH:MM or HH:MM:SS), ZonedDateTime, or datetime input requiring timezone\n * @param timezone - IANA timezone identifier. Required for ISO strings, Date, and Instant inputs.\n * @returns A Temporal.PlainTime representing the wall-clock time\n *\n * @example\n * ```typescript\n * import { toPlainTime, toZonedTime } from '@gobrand/tiempo';\n *\n * // From PlainTimeLike object (no timezone needed)\n * const time = toPlainTime({ hour: 14, minute: 30 }); // 14:30\n *\n * // From plain time string (no timezone needed)\n * const time2 = toPlainTime(\"14:30\"); // 14:30\n * const timeWithSeconds = toPlainTime(\"14:30:45\"); // 14:30:45\n *\n * // From ZonedDateTime (no timezone needed)\n * const zdt = toZonedTime(\"2025-01-20T15:30:00Z\", \"America/New_York\");\n * const time3 = toPlainTime(zdt); // 10:30\n *\n * // From UTC string with timezone\n * const time4 = toPlainTime(\"2025-01-20T15:30:00Z\", \"America/New_York\"); // 10:30\n *\n * // From Date with timezone\n * const date = new Date(\"2025-01-20T15:30:00.000Z\");\n * const time5 = toPlainTime(date, \"Europe/London\"); // 15:30\n *\n * // From Instant with timezone\n * const instant = Temporal.Instant.from(\"2025-01-20T15:30:00Z\");\n * const time6 = toPlainTime(instant, \"Asia/Tokyo\"); // 00:30\n * ```\n */\nexport function toPlainTime(input: Temporal.ZonedDateTime): Temporal.PlainTime;\nexport function toPlainTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: Timezone\n): Temporal.PlainTime;\nexport function toPlainTime(input: Temporal.PlainTimeLike | string): Temporal.PlainTime;\nexport function toPlainTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime | Temporal.PlainTimeLike,\n timezone?: Timezone\n): Temporal.PlainTime {\n // ZonedDateTime without timezone override\n if (input instanceof Temporal.ZonedDateTime && timezone === undefined) {\n return input.toPlainTime();\n }\n\n // Date requires timezone\n if (input instanceof Date) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string');\n }\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone).toPlainTime();\n }\n\n // Instant requires timezone\n if (input instanceof Temporal.Instant) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string');\n }\n return input.toZonedDateTimeISO(timezone).toPlainTime();\n }\n\n // ZonedDateTime with timezone override\n if (input instanceof Temporal.ZonedDateTime) {\n if (timezone === undefined) {\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string');\n }\n return input.toInstant().toZonedDateTimeISO(timezone).toPlainTime();\n }\n\n // String: ISO datetime (requires timezone) or plain time (no timezone)\n if (typeof input === 'string') {\n if (timezone !== undefined) {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone).toPlainTime();\n }\n if (PLAIN_TIME_PATTERN.test(input)) {\n return Temporal.PlainTime.from(input);\n }\n throw new Error('Timezone is required unless input is a ZonedDateTime, PlainTimeLike, or plain time string');\n }\n\n // PlainTimeLike object - pass directly to Temporal.PlainTime.from()\n return Temporal.PlainTime.from(input);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAIzB,IAAM,qBAAqB;AA0CpB,SAAS,YACd,OACA,UACoB;AAEpB,MAAI,iBAAiB,SAAS,iBAAiB,aAAa,QAAW;AACrE,WAAO,MAAM,YAAY;AAAA,EAC3B;AAGA,MAAI,iBAAiB,MAAM;AACzB,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EAC7F;AAGA,MAAI,iBAAiB,SAAS,SAAS;AACrC,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,MAAM,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EACxD;AAGA,MAAI,iBAAiB,SAAS,eAAe;AAC3C,QAAI,aAAa,QAAW;AAC1B,YAAM,IAAI,MAAM,2FAA2F;AAAA,IAC7G;AACA,WAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,EACpE;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,aAAa,QAAW;AAC1B,aAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ,EAAE,YAAY;AAAA,IAC/E;AACA,QAAI,mBAAmB,KAAK,KAAK,GAAG;AAClC,aAAO,SAAS,UAAU,KAAK,KAAK;AAAA,IACtC;AACA,UAAM,IAAI,MAAM,2FAA2F;AAAA,EAC7G;AAGA,SAAO,SAAS,UAAU,KAAK,KAAK;AACtC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/isBefore.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport function isBefore(\n date1: Temporal.ZonedDateTime,\n date2: Temporal.ZonedDateTime\n): boolean {\n return Temporal.ZonedDateTime.compare(date1, date2) < 0;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAElB,SAAS,SACd,OACA,OACS;AACT,SAAO,SAAS,cAAc,QAAQ,OAAO,KAAK,IAAI;AACxD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/isAfter.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport function isAfter(\n date1: Temporal.ZonedDateTime,\n date2: Temporal.ZonedDateTime\n): boolean {\n return Temporal.ZonedDateTime.compare(date1, date2) > 0;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAElB,SAAS,QACd,OACA,OACS;AACT,SAAO,SAAS,cAAc,QAAQ,OAAO,KAAK,IAAI;AACxD;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isBefore
|
|
3
|
+
} from "./chunk-WUAIUEH7.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeTemporalInput
|
|
6
|
+
} from "./chunk-MJSZNWCV.js";
|
|
7
|
+
|
|
8
|
+
// src/isBefore.ts
|
|
9
|
+
import "@js-temporal/polyfill";
|
|
10
|
+
function isBefore2(date1, date2) {
|
|
11
|
+
const zoned1 = normalizeTemporalInput(date1);
|
|
12
|
+
const zoned2 = normalizeTemporalInput(date2);
|
|
13
|
+
return isBefore(zoned1, zoned2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
isBefore2 as isBefore
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-ZDA7GSWU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/isBefore.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\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":";;;;;;;;AAAA,OAAyB;AAyClB,SAASA,UACd,OACA,OACS;AACT,QAAM,SAAS,uBAAuB,KAAK;AAC3C,QAAM,SAAS,uBAAuB,KAAK;AAE3C,SAAO,SAAiB,QAAQ,MAAM;AACxC;","names":["isBefore"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { startOfYear } from './startOfYear';
|
|
|
42
42
|
export { endOfYear } from './endOfYear';
|
|
43
43
|
export { isBefore } from './isBefore';
|
|
44
44
|
export { isAfter } from './isAfter';
|
|
45
|
+
export { isWithinInterval } from './isWithinInterval';
|
|
45
46
|
export { isFuture } from './isFuture';
|
|
46
47
|
export { isPast } from './isPast';
|
|
47
48
|
export { isSameDay } from './isSameDay';
|
|
@@ -64,6 +65,9 @@ export { differenceInDays } from './differenceInDays';
|
|
|
64
65
|
export { differenceInWeeks } from './differenceInWeeks';
|
|
65
66
|
export { differenceInMonths } from './differenceInMonths';
|
|
66
67
|
export { differenceInYears } from './differenceInYears';
|
|
68
|
+
export { roundToNearestHour, type RoundToNearestHourOptions, } from './roundToNearestHour';
|
|
69
|
+
export { roundToNearestMinute, type RoundToNearestMinuteOptions, } from './roundToNearestMinute';
|
|
70
|
+
export { roundToNearestSecond, type RoundToNearestSecondOptions, } from './roundToNearestSecond';
|
|
67
71
|
export { intlFormatDistance, type IntlFormatDistanceOptions, } from './intlFormatDistance';
|
|
68
72
|
export { isPlainDateBefore } from './isPlainDateBefore';
|
|
69
73
|
export { isPlainDateAfter } from './isPlainDateAfter';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;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kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toIso9075
|
|
3
|
+
} from "./chunk-DFLGGK4F.js";
|
|
4
|
+
import {
|
|
5
|
+
toPlainDate
|
|
6
|
+
} from "./chunk-HFQUXON5.js";
|
|
7
|
+
import {
|
|
8
|
+
toPlainTime
|
|
9
|
+
} from "./chunk-UJWM2BV2.js";
|
|
10
|
+
import {
|
|
11
|
+
toUtc
|
|
12
|
+
} from "./chunk-BW5SFCKS.js";
|
|
1
13
|
import {
|
|
2
14
|
toZonedTime
|
|
3
15
|
} from "./chunk-MXQFENCR.js";
|
|
4
16
|
import {
|
|
5
17
|
today
|
|
6
18
|
} from "./chunk-KZB6NERH.js";
|
|
19
|
+
import {
|
|
20
|
+
subMonths
|
|
21
|
+
} from "./chunk-52NEOY34.js";
|
|
22
|
+
import {
|
|
23
|
+
subNanoseconds
|
|
24
|
+
} from "./chunk-WVHAYLBW.js";
|
|
25
|
+
import {
|
|
26
|
+
subSeconds
|
|
27
|
+
} from "./chunk-BH2YB4MV.js";
|
|
28
|
+
import {
|
|
29
|
+
subWeeks
|
|
30
|
+
} from "./chunk-U4RNUZXO.js";
|
|
7
31
|
import {
|
|
8
32
|
subYears
|
|
9
33
|
} from "./chunk-AHMKY474.js";
|
|
@@ -14,17 +38,17 @@ import {
|
|
|
14
38
|
toIso
|
|
15
39
|
} from "./chunk-BSV32PSO.js";
|
|
16
40
|
import {
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
41
|
+
startOfMonth
|
|
42
|
+
} from "./chunk-7GEIOKVQ.js";
|
|
19
43
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./chunk-
|
|
44
|
+
startOfWeek
|
|
45
|
+
} from "./chunk-EZ7NVTZI.js";
|
|
22
46
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./chunk-
|
|
47
|
+
startOfYear
|
|
48
|
+
} from "./chunk-ID52RFFD.js";
|
|
25
49
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
50
|
+
subDays
|
|
51
|
+
} from "./chunk-YKBP3G7L.js";
|
|
28
52
|
import {
|
|
29
53
|
subHours
|
|
30
54
|
} from "./chunk-XW5MLXX5.js";
|
|
@@ -37,42 +61,30 @@ import {
|
|
|
37
61
|
import {
|
|
38
62
|
subMinutes
|
|
39
63
|
} from "./chunk-J6G2I2TU.js";
|
|
40
|
-
import {
|
|
41
|
-
subMonths
|
|
42
|
-
} from "./chunk-52NEOY34.js";
|
|
43
|
-
import {
|
|
44
|
-
subNanoseconds
|
|
45
|
-
} from "./chunk-WVHAYLBW.js";
|
|
46
|
-
import {
|
|
47
|
-
subSeconds
|
|
48
|
-
} from "./chunk-BH2YB4MV.js";
|
|
49
|
-
import {
|
|
50
|
-
subWeeks
|
|
51
|
-
} from "./chunk-U4RNUZXO.js";
|
|
52
64
|
import {
|
|
53
65
|
isSameYear
|
|
54
66
|
} from "./chunk-VLZ3HQQA.js";
|
|
67
|
+
import {
|
|
68
|
+
isWithinInterval
|
|
69
|
+
} from "./chunk-5C3TQSWA.js";
|
|
55
70
|
import {
|
|
56
71
|
now
|
|
57
72
|
} from "./chunk-FSD3DDFC.js";
|
|
73
|
+
import {
|
|
74
|
+
roundToNearestHour
|
|
75
|
+
} from "./chunk-MMI2HHT7.js";
|
|
76
|
+
import {
|
|
77
|
+
roundToNearestMinute
|
|
78
|
+
} from "./chunk-UJW2FPI4.js";
|
|
79
|
+
import {
|
|
80
|
+
roundToNearestSecond
|
|
81
|
+
} from "./chunk-JHRXY36W.js";
|
|
58
82
|
import {
|
|
59
83
|
simpleFormat
|
|
60
84
|
} from "./chunk-TFSZ55L7.js";
|
|
61
85
|
import {
|
|
62
86
|
startOfDay
|
|
63
87
|
} from "./chunk-GFWC7CHD.js";
|
|
64
|
-
import {
|
|
65
|
-
startOfMonth
|
|
66
|
-
} from "./chunk-7GEIOKVQ.js";
|
|
67
|
-
import {
|
|
68
|
-
startOfWeek
|
|
69
|
-
} from "./chunk-EZ7NVTZI.js";
|
|
70
|
-
import {
|
|
71
|
-
startOfYear
|
|
72
|
-
} from "./chunk-ID52RFFD.js";
|
|
73
|
-
import {
|
|
74
|
-
subDays
|
|
75
|
-
} from "./chunk-YKBP3G7L.js";
|
|
76
88
|
import {
|
|
77
89
|
isSameHour
|
|
78
90
|
} from "./chunk-EEQ3REET.js";
|
|
@@ -135,10 +147,12 @@ import {
|
|
|
135
147
|
} from "./chunk-TDQXOSO3.js";
|
|
136
148
|
import {
|
|
137
149
|
isAfter
|
|
138
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-7VLSSOVC.js";
|
|
151
|
+
import "./chunk-WY63VEXE.js";
|
|
139
152
|
import {
|
|
140
153
|
isBefore
|
|
141
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-ZDA7GSWU.js";
|
|
155
|
+
import "./chunk-WUAIUEH7.js";
|
|
142
156
|
import {
|
|
143
157
|
isFuture
|
|
144
158
|
} from "./chunk-R5XN76EV.js";
|
|
@@ -266,7 +280,11 @@ export {
|
|
|
266
280
|
isSameSecond,
|
|
267
281
|
isSameWeek,
|
|
268
282
|
isSameYear,
|
|
283
|
+
isWithinInterval,
|
|
269
284
|
now,
|
|
285
|
+
roundToNearestHour,
|
|
286
|
+
roundToNearestMinute,
|
|
287
|
+
roundToNearestSecond,
|
|
270
288
|
simpleFormat,
|
|
271
289
|
startOfDay,
|
|
272
290
|
startOfMonth,
|
package/dist/isAfter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAfter.d.ts","sourceRoot":"","sources":["../src/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"isAfter.d.ts","sourceRoot":"","sources":["../src/isAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChD,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GAC/C,OAAO,CAKT"}
|
package/dist/isAfter.js
CHANGED
package/dist/isBefore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBefore.d.ts","sourceRoot":"","sources":["../src/isBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"isBefore.d.ts","sourceRoot":"","sources":["../src/isBefore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChD,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GAC/C,OAAO,CAKT"}
|
package/dist/isBefore.js
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given date is within the interval (inclusive of start and end).
|
|
4
|
+
* Compares by the underlying instant (epoch time), not by calendar date/time.
|
|
5
|
+
*
|
|
6
|
+
* @param date - The date to check (Instant or ZonedDateTime)
|
|
7
|
+
* @param interval - The interval with start and end dates
|
|
8
|
+
* @returns true if date is within the interval, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');
|
|
13
|
+
* const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');
|
|
14
|
+
* const date = Temporal.ZonedDateTime.from('2025-01-03T00:00:00Z[UTC]');
|
|
15
|
+
*
|
|
16
|
+
* isWithinInterval(date, { start, end }); // true
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // Date outside the interval
|
|
22
|
+
* const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');
|
|
23
|
+
* const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');
|
|
24
|
+
* const date = Temporal.ZonedDateTime.from('2025-01-10T00:00:00Z[UTC]');
|
|
25
|
+
*
|
|
26
|
+
* isWithinInterval(date, { start, end }); // false
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Date equal to interval start (inclusive)
|
|
32
|
+
* const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');
|
|
33
|
+
* const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');
|
|
34
|
+
*
|
|
35
|
+
* isWithinInterval(start, { start, end }); // true
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // Date equal to interval end (inclusive)
|
|
41
|
+
* const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00Z[UTC]');
|
|
42
|
+
* const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00Z[UTC]');
|
|
43
|
+
*
|
|
44
|
+
* isWithinInterval(end, { start, end }); // true
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* // Works with Instant too
|
|
50
|
+
* const start = Temporal.Instant.from('2025-01-01T00:00:00Z');
|
|
51
|
+
* const end = Temporal.Instant.from('2025-01-07T00:00:00Z');
|
|
52
|
+
* const date = Temporal.Instant.from('2025-01-03T00:00:00Z');
|
|
53
|
+
*
|
|
54
|
+
* isWithinInterval(date, { start, end }); // true
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // Different timezones - compares by instant
|
|
60
|
+
* const start = Temporal.ZonedDateTime.from('2025-01-01T00:00:00-05:00[America/New_York]');
|
|
61
|
+
* const end = Temporal.ZonedDateTime.from('2025-01-07T00:00:00+09:00[Asia/Tokyo]');
|
|
62
|
+
* const date = Temporal.ZonedDateTime.from('2025-01-03T12:00:00Z[UTC]');
|
|
63
|
+
*
|
|
64
|
+
* isWithinInterval(date, { start, end }); // true
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function isWithinInterval(date: Temporal.Instant | Temporal.ZonedDateTime, interval: {
|
|
68
|
+
start: Temporal.Instant | Temporal.ZonedDateTime;
|
|
69
|
+
end: Temporal.Instant | Temporal.ZonedDateTime;
|
|
70
|
+
}): boolean;
|
|
71
|
+
//# sourceMappingURL=isWithinInterval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isWithinInterval.d.ts","sourceRoot":"","sources":["../src/isWithinInterval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAC/C,QAAQ,EAAE;IACR,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC;IACjD,GAAG,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC;CAChD,GACA,OAAO,CAMT"}
|