@gobrand/tiempo 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +156 -10
  2. package/dist/chunk-2H4KLXGL.js +16 -0
  3. package/dist/chunk-2H4KLXGL.js.map +1 -0
  4. package/dist/chunk-6IP245MS.js +17 -0
  5. package/dist/chunk-6IP245MS.js.map +1 -0
  6. package/dist/chunk-BIAPE4MR.js +17 -0
  7. package/dist/chunk-BIAPE4MR.js.map +1 -0
  8. package/dist/chunk-CHW2EN2O.js +17 -0
  9. package/dist/chunk-CHW2EN2O.js.map +1 -0
  10. package/dist/chunk-D7DPB2JR.js +16 -0
  11. package/dist/chunk-D7DPB2JR.js.map +1 -0
  12. package/dist/chunk-OABS374T.js +16 -0
  13. package/dist/chunk-OABS374T.js.map +1 -0
  14. package/dist/chunk-PIDXROVB.js +16 -0
  15. package/dist/chunk-PIDXROVB.js.map +1 -0
  16. package/dist/chunk-PVAOUYXF.js +17 -0
  17. package/dist/chunk-PVAOUYXF.js.map +1 -0
  18. package/dist/chunk-R5XN76EV.js +16 -0
  19. package/dist/chunk-R5XN76EV.js.map +1 -0
  20. package/dist/chunk-RJY62CDU.js +16 -0
  21. package/dist/chunk-RJY62CDU.js.map +1 -0
  22. package/dist/chunk-ZGR4NZTS.js +17 -0
  23. package/dist/chunk-ZGR4NZTS.js.map +1 -0
  24. package/dist/chunk-ZHRMURYP.js +16 -0
  25. package/dist/chunk-ZHRMURYP.js.map +1 -0
  26. package/dist/differenceInDays.d.ts +43 -0
  27. package/dist/differenceInDays.d.ts.map +1 -0
  28. package/dist/differenceInDays.js +8 -0
  29. package/dist/differenceInDays.js.map +1 -0
  30. package/dist/differenceInDays.test.d.ts +2 -0
  31. package/dist/differenceInDays.test.d.ts.map +1 -0
  32. package/dist/differenceInHours.d.ts +37 -0
  33. package/dist/differenceInHours.d.ts.map +1 -0
  34. package/dist/differenceInHours.js +8 -0
  35. package/dist/differenceInHours.js.map +1 -0
  36. package/dist/differenceInHours.test.d.ts +2 -0
  37. package/dist/differenceInHours.test.d.ts.map +1 -0
  38. package/dist/differenceInMicroseconds.d.ts +37 -0
  39. package/dist/differenceInMicroseconds.d.ts.map +1 -0
  40. package/dist/differenceInMicroseconds.js +8 -0
  41. package/dist/differenceInMicroseconds.js.map +1 -0
  42. package/dist/differenceInMicroseconds.test.d.ts +2 -0
  43. package/dist/differenceInMicroseconds.test.d.ts.map +1 -0
  44. package/dist/differenceInMilliseconds.d.ts +37 -0
  45. package/dist/differenceInMilliseconds.d.ts.map +1 -0
  46. package/dist/differenceInMilliseconds.js +8 -0
  47. package/dist/differenceInMilliseconds.js.map +1 -0
  48. package/dist/differenceInMilliseconds.test.d.ts +2 -0
  49. package/dist/differenceInMilliseconds.test.d.ts.map +1 -0
  50. package/dist/differenceInMinutes.d.ts +37 -0
  51. package/dist/differenceInMinutes.d.ts.map +1 -0
  52. package/dist/differenceInMinutes.js +8 -0
  53. package/dist/differenceInMinutes.js.map +1 -0
  54. package/dist/differenceInMinutes.test.d.ts +2 -0
  55. package/dist/differenceInMinutes.test.d.ts.map +1 -0
  56. package/dist/differenceInMonths.d.ts +43 -0
  57. package/dist/differenceInMonths.d.ts.map +1 -0
  58. package/dist/differenceInMonths.js +8 -0
  59. package/dist/differenceInMonths.js.map +1 -0
  60. package/dist/differenceInMonths.test.d.ts +2 -0
  61. package/dist/differenceInMonths.test.d.ts.map +1 -0
  62. package/dist/differenceInNanoseconds.d.ts +37 -0
  63. package/dist/differenceInNanoseconds.d.ts.map +1 -0
  64. package/dist/differenceInNanoseconds.js +8 -0
  65. package/dist/differenceInNanoseconds.js.map +1 -0
  66. package/dist/differenceInNanoseconds.test.d.ts +2 -0
  67. package/dist/differenceInNanoseconds.test.d.ts.map +1 -0
  68. package/dist/differenceInSeconds.d.ts +37 -0
  69. package/dist/differenceInSeconds.d.ts.map +1 -0
  70. package/dist/differenceInSeconds.js +8 -0
  71. package/dist/differenceInSeconds.js.map +1 -0
  72. package/dist/differenceInSeconds.test.d.ts +2 -0
  73. package/dist/differenceInSeconds.test.d.ts.map +1 -0
  74. package/dist/differenceInWeeks.d.ts +43 -0
  75. package/dist/differenceInWeeks.d.ts.map +1 -0
  76. package/dist/differenceInWeeks.js +8 -0
  77. package/dist/differenceInWeeks.js.map +1 -0
  78. package/dist/differenceInWeeks.test.d.ts +2 -0
  79. package/dist/differenceInWeeks.test.d.ts.map +1 -0
  80. package/dist/differenceInYears.d.ts +43 -0
  81. package/dist/differenceInYears.d.ts.map +1 -0
  82. package/dist/differenceInYears.js +8 -0
  83. package/dist/differenceInYears.js.map +1 -0
  84. package/dist/differenceInYears.test.d.ts +2 -0
  85. package/dist/differenceInYears.test.d.ts.map +1 -0
  86. package/dist/index.d.ts +12 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +59 -11
  89. package/dist/isFuture.d.ts +35 -0
  90. package/dist/isFuture.d.ts.map +1 -0
  91. package/dist/isFuture.js +8 -0
  92. package/dist/isFuture.js.map +1 -0
  93. package/dist/isFuture.test.d.ts +2 -0
  94. package/dist/isFuture.test.d.ts.map +1 -0
  95. package/dist/isPast.d.ts +35 -0
  96. package/dist/isPast.d.ts.map +1 -0
  97. package/dist/isPast.js +8 -0
  98. package/dist/isPast.js.map +1 -0
  99. package/dist/isPast.test.d.ts +2 -0
  100. package/dist/isPast.test.d.ts.map +1 -0
  101. package/package.json +1 -1
package/README.md CHANGED
@@ -270,32 +270,178 @@ endOfYear(zoned); // 2025-12-31T23:59:59.999999999-05:00[America/New_York]
270
270
 
271
271
  ### Comparison Utilities
272
272
 
273
- #### `isBefore(date1, date2)`
273
+ #### `isBefore(date1, date2)` / `isAfter(date1, date2)`
274
274
 
275
- Check if the first datetime is before the second. Compares the underlying instant in time.
275
+ Check if the first datetime is before or after the second. Compares the underlying instant in time.
276
276
 
277
277
  ```typescript
278
- import { isBefore } from '@gobrand/tiempo';
278
+ import { isBefore, isAfter } from '@gobrand/tiempo';
279
279
 
280
280
  const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
281
281
  const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
282
282
 
283
283
  isBefore(earlier, later); // true
284
284
  isBefore(later, earlier); // false
285
+
286
+ isAfter(later, earlier); // true
287
+ isAfter(earlier, later); // false
285
288
  ```
286
289
 
287
- #### `isAfter(date1, date2)`
290
+ ### Difference Utilities
291
+
292
+ All difference functions compare the underlying instant in time and return a positive value if laterDate is after earlierDate, negative if before.
293
+
294
+ #### Time-based precision (instant comparison)
288
295
 
289
- Check if the first datetime is after the second. Compares the underlying instant in time.
296
+ ##### `differenceInNanoseconds(laterDate, earlierDate)`
297
+
298
+ Returns the difference in nanoseconds as a BigInt. Provides the highest precision available in Temporal.
290
299
 
291
300
  ```typescript
292
- import { isAfter } from '@gobrand/tiempo';
301
+ import { differenceInNanoseconds } from '@gobrand/tiempo';
293
302
 
294
- const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
295
- const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
303
+ const later = Temporal.Instant.from('2025-01-20T12:30:20.000000500Z');
304
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000000Z');
305
+ differenceInNanoseconds(later, earlier); // 500n
306
+ ```
296
307
 
297
- isAfter(later, earlier); // true
298
- isAfter(earlier, later); // false
308
+ ##### `differenceInMicroseconds(laterDate, earlierDate)`
309
+
310
+ Returns the difference in microseconds (1/1,000,000 second).
311
+
312
+ ```typescript
313
+ import { differenceInMicroseconds } from '@gobrand/tiempo';
314
+
315
+ const later = Temporal.Instant.from('2025-01-20T12:30:20.001000Z');
316
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000Z');
317
+ differenceInMicroseconds(later, earlier); // 1000
318
+ ```
319
+
320
+ ##### `differenceInMilliseconds(laterDate, earlierDate)`
321
+
322
+ Returns the difference in milliseconds (1/1,000 second).
323
+
324
+ ```typescript
325
+ import { differenceInMilliseconds } from '@gobrand/tiempo';
326
+
327
+ const later = Temporal.Instant.from('2025-01-20T12:30:21.700Z');
328
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.600Z');
329
+ differenceInMilliseconds(later, earlier); // 1100
330
+ ```
331
+
332
+ ##### `differenceInSeconds(laterDate, earlierDate)`
333
+
334
+ Returns the difference in seconds (truncates sub-second precision).
335
+
336
+ ```typescript
337
+ import { differenceInSeconds } from '@gobrand/tiempo';
338
+
339
+ const later = Temporal.Instant.from('2025-01-20T12:30:25Z');
340
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20Z');
341
+ differenceInSeconds(later, earlier); // 5
342
+ ```
343
+
344
+ ##### `differenceInMinutes(laterDate, earlierDate)`
345
+
346
+ Returns the difference in minutes (truncates sub-minute precision).
347
+
348
+ ```typescript
349
+ import { differenceInMinutes } from '@gobrand/tiempo';
350
+
351
+ const later = Temporal.Instant.from('2025-01-20T12:45:00Z');
352
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:00Z');
353
+ differenceInMinutes(later, earlier); // 15
354
+ ```
355
+
356
+ ##### `differenceInHours(laterDate, earlierDate)`
357
+
358
+ Returns the difference in hours (truncates sub-hour precision).
359
+
360
+ ```typescript
361
+ import { differenceInHours } from '@gobrand/tiempo';
362
+
363
+ const later = Temporal.Instant.from('2025-01-20T18:00:00Z');
364
+ const earlier = Temporal.Instant.from('2025-01-20T15:00:00Z');
365
+ differenceInHours(later, earlier); // 3
366
+ ```
367
+
368
+ #### Calendar-aware precision
369
+
370
+ These functions use Temporal's `until()` method to account for variable-length calendar units.
371
+
372
+ ##### `differenceInDays(laterDate, earlierDate)`
373
+
374
+ Returns the difference in days. Calendar-aware, so it properly handles DST transitions where days can be 23, 24, or 25 hours.
375
+
376
+ ```typescript
377
+ import { differenceInDays } from '@gobrand/tiempo';
378
+
379
+ const later = Temporal.Instant.from('2025-01-25T12:00:00Z');
380
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
381
+ differenceInDays(later, earlier); // 5
382
+
383
+ // Handles DST transitions correctly
384
+ const afterDst = Temporal.ZonedDateTime.from('2025-03-10T12:00:00-04:00[America/New_York]');
385
+ const beforeDst = Temporal.ZonedDateTime.from('2025-03-08T12:00:00-05:00[America/New_York]');
386
+ differenceInDays(afterDst, beforeDst); // 2 (calendar days, not 48 hours)
387
+ ```
388
+
389
+ ##### `differenceInWeeks(laterDate, earlierDate)`
390
+
391
+ Returns the difference in weeks (7-day periods).
392
+
393
+ ```typescript
394
+ import { differenceInWeeks } from '@gobrand/tiempo';
395
+
396
+ const later = Temporal.Instant.from('2025-02-10T12:00:00Z');
397
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
398
+ differenceInWeeks(later, earlier); // 3
399
+ ```
400
+
401
+ ##### `differenceInMonths(laterDate, earlierDate)`
402
+
403
+ Returns the difference in months. Calendar-aware, properly handling months with different numbers of days (28-31).
404
+
405
+ ```typescript
406
+ import { differenceInMonths } from '@gobrand/tiempo';
407
+
408
+ const later = Temporal.Instant.from('2025-04-20T12:00:00Z');
409
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
410
+ differenceInMonths(later, earlier); // 3
411
+ ```
412
+
413
+ ##### `differenceInYears(laterDate, earlierDate)`
414
+
415
+ Returns the difference in years. Calendar-aware, properly handling leap years (366 days) and regular years (365 days).
416
+
417
+ ```typescript
418
+ import { differenceInYears } from '@gobrand/tiempo';
419
+
420
+ const later = Temporal.Instant.from('2028-01-20T12:00:00Z');
421
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
422
+ differenceInYears(later, earlier); // 3
423
+
424
+ // Calculate age
425
+ const today = Temporal.ZonedDateTime.from('2025-01-20T12:00:00Z[UTC]');
426
+ const birthdate = Temporal.ZonedDateTime.from('1990-01-20T12:00:00Z[UTC]');
427
+ differenceInYears(today, birthdate); // 35
428
+ ```
429
+
430
+ #### `isFuture(date)` / `isPast(date)`
431
+
432
+ Check if a datetime is in the future or past relative to the current moment. Compares against `Temporal.Now.instant()`.
433
+
434
+ ```typescript
435
+ import { isFuture, isPast } from '@gobrand/tiempo';
436
+
437
+ const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });
438
+ const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });
439
+
440
+ isFuture(tomorrow); // true
441
+ isFuture(yesterday); // false
442
+
443
+ isPast(yesterday); // true
444
+ isPast(tomorrow); // false
299
445
  ```
300
446
 
301
447
  #### `isSameDay(date1, date2)`
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/isPast.ts
6
+ import { Temporal } from "@js-temporal/polyfill";
7
+ function isPast(date) {
8
+ const zoned = normalizeTemporalInput(date);
9
+ const nowInstant = Temporal.Now.instant();
10
+ return Temporal.Instant.compare(zoned.toInstant(), nowInstant) < 0;
11
+ }
12
+
13
+ export {
14
+ isPast
15
+ };
16
+ //# sourceMappingURL=chunk-2H4KLXGL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/isPast.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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 const nowInstant = Temporal.Now.instant();\n\n return Temporal.Instant.compare(zoned.toInstant(), nowInstant) < 0;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAmClB,SAAS,OACd,MACS;AACT,QAAM,QAAQ,uBAAuB,IAAI;AACzC,QAAM,aAAa,SAAS,IAAI,QAAQ;AAExC,SAAO,SAAS,QAAQ,QAAQ,MAAM,UAAU,GAAG,UAAU,IAAI;AACnE;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInDays.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInDays(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ const duration = zoned2.until(zoned1, { largestUnit: "hours" });
11
+ return duration.total({ unit: "days", relativeTo: zoned2 });
12
+ }
13
+
14
+ export {
15
+ differenceInDays
16
+ };
17
+ //# sourceMappingURL=chunk-6IP245MS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInDays.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of days between two datetimes.\n * The result is positive if laterDate is after earlierDate, negative if before.\n *\n * This function uses calendar-aware calculation, which means it properly handles\n * DST transitions where days can be 23, 24, or 25 hours long.\n *\n * Instant inputs are converted to UTC for calendar calculations.\n * For ZonedDateTime inputs, their timezone is preserved.\n *\n * @param laterDate - The later datetime (Instant or ZonedDateTime)\n * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)\n * @returns The number of days between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-25T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInDays(later, earlier); // 5\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-25T15: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 * differenceInDays(later, earlier); // 5\n * ```\n *\n * @example\n * ```ts\n * // Handles DST transitions correctly\n * const afterDst = Temporal.ZonedDateTime.from('2025-03-10T12:00:00-04:00[America/New_York]');\n * const beforeDst = Temporal.ZonedDateTime.from('2025-03-08T12:00:00-05:00[America/New_York]');\n *\n * differenceInDays(afterDst, beforeDst); // 2 (calendar days, not 48 hours)\n * ```\n */\nexport function differenceInDays(\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 const duration = zoned2.until(zoned1, { largestUnit: 'hours' });\n return duration.total({ unit: 'days', relativeTo: zoned2 });\n}\n"],"mappings":";;;;;AAAA,OAAyB;AA2ClB,SAAS,iBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,WAAW,OAAO,MAAM,QAAQ,EAAE,aAAa,QAAQ,CAAC;AAC9D,SAAO,SAAS,MAAM,EAAE,MAAM,QAAQ,YAAY,OAAO,CAAC;AAC5D;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInMonths.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInMonths(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ const duration = zoned2.until(zoned1, { largestUnit: "hours" });
11
+ return duration.total({ unit: "months", relativeTo: zoned2 });
12
+ }
13
+
14
+ export {
15
+ differenceInMonths
16
+ };
17
+ //# sourceMappingURL=chunk-BIAPE4MR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInMonths.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of months between two datetimes.\n * The result is positive if laterDate is after earlierDate, negative if before.\n *\n * This function uses calendar-aware calculation, which means it properly handles\n * months with different numbers of days (28, 29, 30, or 31).\n *\n * Instant inputs are converted to UTC for calendar calculations.\n * For ZonedDateTime inputs, their timezone is preserved.\n *\n * @param laterDate - The later datetime (Instant or ZonedDateTime)\n * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)\n * @returns The number of months between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-04-20T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInMonths(later, earlier); // 3\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-06-15T15:00:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-15T15:00:00-05:00[America/New_York]');\n *\n * differenceInMonths(later, earlier); // 5\n * ```\n *\n * @example\n * ```ts\n * // Returns fractional months for partial month differences\n * const later = Temporal.Instant.from('2025-02-05T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInMonths(later, earlier); // ~0.5 (approximately half a month)\n * ```\n */\nexport function differenceInMonths(\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 const duration = zoned2.until(zoned1, { largestUnit: 'hours' });\n return duration.total({ unit: 'months', relativeTo: zoned2 });\n}\n"],"mappings":";;;;;AAAA,OAAyB;AA2ClB,SAAS,mBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,WAAW,OAAO,MAAM,QAAQ,EAAE,aAAa,QAAQ,CAAC;AAC9D,SAAO,SAAS,MAAM,EAAE,MAAM,UAAU,YAAY,OAAO,CAAC;AAC9D;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInYears.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInYears(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ const duration = zoned2.until(zoned1, { largestUnit: "hours" });
11
+ return duration.total({ unit: "years", relativeTo: zoned2 });
12
+ }
13
+
14
+ export {
15
+ differenceInYears
16
+ };
17
+ //# sourceMappingURL=chunk-CHW2EN2O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInYears.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of years between two datetimes.\n * The result is positive if laterDate is after earlierDate, negative if before.\n *\n * This function uses calendar-aware calculation, which means it properly handles\n * leap years (366 days) and regular years (365 days).\n *\n * Instant inputs are converted to UTC for calendar calculations.\n * For ZonedDateTime inputs, their timezone is preserved.\n *\n * @param laterDate - The later datetime (Instant or ZonedDateTime)\n * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)\n * @returns The number of years between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2028-01-20T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInYears(later, earlier); // 3\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2030-06-15T15:00:00-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-06-15T15:00:00-05:00[America/New_York]');\n *\n * differenceInYears(later, earlier); // 5\n * ```\n *\n * @example\n * ```ts\n * // Returns fractional years for partial year differences\n * const later = Temporal.Instant.from('2025-07-20T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInYears(later, earlier); // ~0.5 (approximately half a year)\n * ```\n */\nexport function differenceInYears(\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 const duration = zoned2.until(zoned1, { largestUnit: 'hours' });\n return duration.total({ unit: 'years', relativeTo: zoned2 });\n}\n"],"mappings":";;;;;AAAA,OAAyB;AA2ClB,SAAS,kBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,WAAW,OAAO,MAAM,QAAQ,EAAE,aAAa,QAAQ,CAAC;AAC9D,SAAO,SAAS,MAAM,EAAE,MAAM,SAAS,YAAY,OAAO,CAAC;AAC7D;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInMilliseconds.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInMilliseconds(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ return zoned1.epochMilliseconds - zoned2.epochMilliseconds;
11
+ }
12
+
13
+ export {
14
+ differenceInMilliseconds
15
+ };
16
+ //# sourceMappingURL=chunk-D7DPB2JR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInMilliseconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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 zoned1.epochMilliseconds - zoned2.epochMilliseconds;\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,yBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,OAAO,oBAAoB,OAAO;AAC3C;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInNanoseconds.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInNanoseconds(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ return zoned1.epochNanoseconds - zoned2.epochNanoseconds;
11
+ }
12
+
13
+ export {
14
+ differenceInNanoseconds
15
+ };
16
+ //# sourceMappingURL=chunk-OABS374T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInNanoseconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of nanoseconds 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 nanoseconds between the dates as a BigInt\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T12:30:20.000000500Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000000Z');\n *\n * differenceInNanoseconds(later, earlier); // 500n\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00.000000001-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00.000000000-05:00[America/New_York]');\n *\n * differenceInNanoseconds(later, earlier); // 1n\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 * differenceInNanoseconds(tokyo, ny); // 0n (same instant)\n * ```\n */\nexport function differenceInNanoseconds(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime\n): bigint {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n return zoned1.epochNanoseconds - zoned2.epochNanoseconds;\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,wBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,OAAO,mBAAmB,OAAO;AAC1C;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInHours.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInHours(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ return Math.trunc((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 36e5);
11
+ }
12
+
13
+ export {
14
+ differenceInHours
15
+ };
16
+ //# sourceMappingURL=chunk-PIDXROVB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInHours.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 3600000);\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,kBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,OAAO,OAAO,oBAAoB,OAAO,qBAAqB,IAAO;AACnF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInWeeks.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInWeeks(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ const duration = zoned2.until(zoned1, { largestUnit: "hours" });
11
+ return duration.total({ unit: "weeks", relativeTo: zoned2 });
12
+ }
13
+
14
+ export {
15
+ differenceInWeeks
16
+ };
17
+ //# sourceMappingURL=chunk-PVAOUYXF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInWeeks.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of weeks between two datetimes.\n * The result is positive if laterDate is after earlierDate, negative if before.\n *\n * This function uses calendar-aware calculation, which means it properly handles\n * DST transitions and calendar weeks.\n *\n * Instant inputs are converted to UTC for calendar calculations.\n * For ZonedDateTime inputs, their timezone is preserved.\n *\n * @param laterDate - The later datetime (Instant or ZonedDateTime)\n * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)\n * @returns The number of weeks between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-02-10T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInWeeks(later, earlier); // 3\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-02-10T15: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 * differenceInWeeks(later, earlier); // 3\n * ```\n *\n * @example\n * ```ts\n * // Returns fractional weeks for partial week differences\n * const later = Temporal.Instant.from('2025-01-27T12:00:00Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');\n *\n * differenceInWeeks(later, earlier); // 1\n * ```\n */\nexport function differenceInWeeks(\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 const duration = zoned2.until(zoned1, { largestUnit: 'hours' });\n return duration.total({ unit: 'weeks', relativeTo: zoned2 });\n}\n"],"mappings":";;;;;AAAA,OAAyB;AA2ClB,SAAS,kBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,WAAW,OAAO,MAAM,QAAQ,EAAE,aAAa,QAAQ,CAAC;AAC9D,SAAO,SAAS,MAAM,EAAE,MAAM,SAAS,YAAY,OAAO,CAAC;AAC7D;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/isFuture.ts
6
+ import { Temporal } from "@js-temporal/polyfill";
7
+ function isFuture(date) {
8
+ const zoned = normalizeTemporalInput(date);
9
+ const nowInstant = Temporal.Now.instant();
10
+ return Temporal.Instant.compare(zoned.toInstant(), nowInstant) > 0;
11
+ }
12
+
13
+ export {
14
+ isFuture
15
+ };
16
+ //# sourceMappingURL=chunk-R5XN76EV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/isFuture.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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 const nowInstant = Temporal.Now.instant();\n\n return Temporal.Instant.compare(zoned.toInstant(), nowInstant) > 0;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAmClB,SAAS,SACd,MACS;AACT,QAAM,QAAQ,uBAAuB,IAAI;AACzC,QAAM,aAAa,SAAS,IAAI,QAAQ;AAExC,SAAO,SAAS,QAAQ,QAAQ,MAAM,UAAU,GAAG,UAAU,IAAI;AACnE;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInMinutes.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInMinutes(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ return Math.trunc((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 6e4);
11
+ }
12
+
13
+ export {
14
+ differenceInMinutes
15
+ };
16
+ //# sourceMappingURL=chunk-RJY62CDU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInMinutes.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 60000);\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,oBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,OAAO,OAAO,oBAAoB,OAAO,qBAAqB,GAAK;AACjF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInMicroseconds.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInMicroseconds(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ const diffNanos = zoned1.epochNanoseconds - zoned2.epochNanoseconds;
11
+ return Number(diffNanos / 1000n);
12
+ }
13
+
14
+ export {
15
+ differenceInMicroseconds
16
+ };
17
+ //# sourceMappingURL=chunk-ZGR4NZTS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInMicroseconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\n/**\n * Returns the number of microseconds 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 microseconds between the dates\n *\n * @example\n * ```ts\n * const later = Temporal.Instant.from('2025-01-20T12:30:20.001000Z');\n * const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000Z');\n *\n * differenceInMicroseconds(later, earlier); // 1000\n * ```\n *\n * @example\n * ```ts\n * // Works with ZonedDateTime\n * const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00.000500-05:00[America/New_York]');\n * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00.000000-05:00[America/New_York]');\n *\n * differenceInMicroseconds(later, earlier); // 500\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 * differenceInMicroseconds(tokyo, ny); // 0 (same instant)\n * ```\n */\nexport function differenceInMicroseconds(\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 const diffNanos = zoned1.epochNanoseconds - zoned2.epochNanoseconds;\n return Number(diffNanos / 1000n);\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,yBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,QAAM,YAAY,OAAO,mBAAmB,OAAO;AACnD,SAAO,OAAO,YAAY,KAAK;AACjC;","names":[]}
@@ -0,0 +1,16 @@
1
+ import {
2
+ normalizeTemporalInput
3
+ } from "./chunk-MJSZNWCV.js";
4
+
5
+ // src/differenceInSeconds.ts
6
+ import "@js-temporal/polyfill";
7
+ function differenceInSeconds(laterDate, earlierDate) {
8
+ const zoned1 = normalizeTemporalInput(laterDate);
9
+ const zoned2 = normalizeTemporalInput(earlierDate);
10
+ return Math.trunc((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 1e3);
11
+ }
12
+
13
+ export {
14
+ differenceInSeconds
15
+ };
16
+ //# sourceMappingURL=chunk-ZHRMURYP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/differenceInSeconds.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\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((zoned1.epochMilliseconds - zoned2.epochMilliseconds) / 1000);\n}\n"],"mappings":";;;;;AAAA,OAAyB;AAqClB,SAAS,oBACd,WACA,aACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAEjD,SAAO,KAAK,OAAO,OAAO,oBAAoB,OAAO,qBAAqB,GAAI;AAChF;","names":[]}
@@ -0,0 +1,43 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ /**
3
+ * Returns the number of days between two datetimes.
4
+ * The result is positive if laterDate is after earlierDate, negative if before.
5
+ *
6
+ * This function uses calendar-aware calculation, which means it properly handles
7
+ * DST transitions where days can be 23, 24, or 25 hours long.
8
+ *
9
+ * Instant inputs are converted to UTC for calendar calculations.
10
+ * For ZonedDateTime inputs, their timezone is preserved.
11
+ *
12
+ * @param laterDate - The later datetime (Instant or ZonedDateTime)
13
+ * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)
14
+ * @returns The number of days between the dates
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const later = Temporal.Instant.from('2025-01-25T12:00:00Z');
19
+ * const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
20
+ *
21
+ * differenceInDays(later, earlier); // 5
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * // Works with ZonedDateTime
27
+ * const later = Temporal.ZonedDateTime.from('2025-01-25T15:00:00-05:00[America/New_York]');
28
+ * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
29
+ *
30
+ * differenceInDays(later, earlier); // 5
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // Handles DST transitions correctly
36
+ * const afterDst = Temporal.ZonedDateTime.from('2025-03-10T12:00:00-04:00[America/New_York]');
37
+ * const beforeDst = Temporal.ZonedDateTime.from('2025-03-08T12:00:00-05:00[America/New_York]');
38
+ *
39
+ * differenceInDays(afterDst, beforeDst); // 2 (calendar days, not 48 hours)
40
+ * ```
41
+ */
42
+ export declare function differenceInDays(laterDate: Temporal.Instant | Temporal.ZonedDateTime, earlierDate: Temporal.Instant | Temporal.ZonedDateTime): number;
43
+ //# sourceMappingURL=differenceInDays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differenceInDays.d.ts","sourceRoot":"","sources":["../src/differenceInDays.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACpD,WAAW,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GACrD,MAAM,CAMR"}
@@ -0,0 +1,8 @@
1
+ import {
2
+ differenceInDays
3
+ } from "./chunk-6IP245MS.js";
4
+ import "./chunk-MJSZNWCV.js";
5
+ export {
6
+ differenceInDays
7
+ };
8
+ //# sourceMappingURL=differenceInDays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=differenceInDays.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differenceInDays.test.d.ts","sourceRoot":"","sources":["../src/differenceInDays.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ /**
3
+ * Returns the number of hours between two datetimes.
4
+ * The result is positive if laterDate is after earlierDate, negative if before.
5
+ *
6
+ * @param laterDate - The later datetime (Instant or ZonedDateTime)
7
+ * @param earlierDate - The earlier datetime (Instant or ZonedDateTime)
8
+ * @returns The number of hours between the dates
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const later = Temporal.Instant.from('2025-01-20T18:00:00Z');
13
+ * const earlier = Temporal.Instant.from('2025-01-20T15:00:00Z');
14
+ *
15
+ * differenceInHours(later, earlier); // 3
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // Works with ZonedDateTime
21
+ * const later = Temporal.ZonedDateTime.from('2025-01-21T00:00:00-05:00[America/New_York]');
22
+ * const earlier = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
23
+ *
24
+ * differenceInHours(later, earlier); // 9
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // Handles different timezones - compares by instant
30
+ * const tokyo = Temporal.ZonedDateTime.from('2025-01-21T00:00:00+09:00[Asia/Tokyo]');
31
+ * const ny = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
32
+ *
33
+ * differenceInHours(tokyo, ny); // 0 (same instant)
34
+ * ```
35
+ */
36
+ export declare function differenceInHours(laterDate: Temporal.Instant | Temporal.ZonedDateTime, earlierDate: Temporal.Instant | Temporal.ZonedDateTime): number;
37
+ //# sourceMappingURL=differenceInHours.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differenceInHours.d.ts","sourceRoot":"","sources":["../src/differenceInHours.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACpD,WAAW,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GACrD,MAAM,CAKR"}
@@ -0,0 +1,8 @@
1
+ import {
2
+ differenceInHours
3
+ } from "./chunk-PIDXROVB.js";
4
+ import "./chunk-MJSZNWCV.js";
5
+ export {
6
+ differenceInHours
7
+ };
8
+ //# sourceMappingURL=differenceInHours.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=differenceInHours.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differenceInHours.test.d.ts","sourceRoot":"","sources":["../src/differenceInHours.test.ts"],"names":[],"mappings":""}