@gobrand/tiempo 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +234 -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-NL5LWPJI.js +94 -0
  13. package/dist/chunk-NL5LWPJI.js.map +1 -0
  14. package/dist/chunk-OABS374T.js +16 -0
  15. package/dist/chunk-OABS374T.js.map +1 -0
  16. package/dist/chunk-PIDXROVB.js +16 -0
  17. package/dist/chunk-PIDXROVB.js.map +1 -0
  18. package/dist/chunk-PVAOUYXF.js +17 -0
  19. package/dist/chunk-PVAOUYXF.js.map +1 -0
  20. package/dist/chunk-R5XN76EV.js +16 -0
  21. package/dist/chunk-R5XN76EV.js.map +1 -0
  22. package/dist/chunk-RJY62CDU.js +16 -0
  23. package/dist/chunk-RJY62CDU.js.map +1 -0
  24. package/dist/chunk-ZGR4NZTS.js +17 -0
  25. package/dist/chunk-ZGR4NZTS.js.map +1 -0
  26. package/dist/chunk-ZHRMURYP.js +16 -0
  27. package/dist/chunk-ZHRMURYP.js.map +1 -0
  28. package/dist/differenceInDays.d.ts +43 -0
  29. package/dist/differenceInDays.d.ts.map +1 -0
  30. package/dist/differenceInDays.js +8 -0
  31. package/dist/differenceInDays.js.map +1 -0
  32. package/dist/differenceInDays.test.d.ts +2 -0
  33. package/dist/differenceInDays.test.d.ts.map +1 -0
  34. package/dist/differenceInHours.d.ts +37 -0
  35. package/dist/differenceInHours.d.ts.map +1 -0
  36. package/dist/differenceInHours.js +8 -0
  37. package/dist/differenceInHours.js.map +1 -0
  38. package/dist/differenceInHours.test.d.ts +2 -0
  39. package/dist/differenceInHours.test.d.ts.map +1 -0
  40. package/dist/differenceInMicroseconds.d.ts +37 -0
  41. package/dist/differenceInMicroseconds.d.ts.map +1 -0
  42. package/dist/differenceInMicroseconds.js +8 -0
  43. package/dist/differenceInMicroseconds.js.map +1 -0
  44. package/dist/differenceInMicroseconds.test.d.ts +2 -0
  45. package/dist/differenceInMicroseconds.test.d.ts.map +1 -0
  46. package/dist/differenceInMilliseconds.d.ts +37 -0
  47. package/dist/differenceInMilliseconds.d.ts.map +1 -0
  48. package/dist/differenceInMilliseconds.js +8 -0
  49. package/dist/differenceInMilliseconds.js.map +1 -0
  50. package/dist/differenceInMilliseconds.test.d.ts +2 -0
  51. package/dist/differenceInMilliseconds.test.d.ts.map +1 -0
  52. package/dist/differenceInMinutes.d.ts +37 -0
  53. package/dist/differenceInMinutes.d.ts.map +1 -0
  54. package/dist/differenceInMinutes.js +8 -0
  55. package/dist/differenceInMinutes.js.map +1 -0
  56. package/dist/differenceInMinutes.test.d.ts +2 -0
  57. package/dist/differenceInMinutes.test.d.ts.map +1 -0
  58. package/dist/differenceInMonths.d.ts +43 -0
  59. package/dist/differenceInMonths.d.ts.map +1 -0
  60. package/dist/differenceInMonths.js +8 -0
  61. package/dist/differenceInMonths.js.map +1 -0
  62. package/dist/differenceInMonths.test.d.ts +2 -0
  63. package/dist/differenceInMonths.test.d.ts.map +1 -0
  64. package/dist/differenceInNanoseconds.d.ts +37 -0
  65. package/dist/differenceInNanoseconds.d.ts.map +1 -0
  66. package/dist/differenceInNanoseconds.js +8 -0
  67. package/dist/differenceInNanoseconds.js.map +1 -0
  68. package/dist/differenceInNanoseconds.test.d.ts +2 -0
  69. package/dist/differenceInNanoseconds.test.d.ts.map +1 -0
  70. package/dist/differenceInSeconds.d.ts +37 -0
  71. package/dist/differenceInSeconds.d.ts.map +1 -0
  72. package/dist/differenceInSeconds.js +8 -0
  73. package/dist/differenceInSeconds.js.map +1 -0
  74. package/dist/differenceInSeconds.test.d.ts +2 -0
  75. package/dist/differenceInSeconds.test.d.ts.map +1 -0
  76. package/dist/differenceInWeeks.d.ts +43 -0
  77. package/dist/differenceInWeeks.d.ts.map +1 -0
  78. package/dist/differenceInWeeks.js +8 -0
  79. package/dist/differenceInWeeks.js.map +1 -0
  80. package/dist/differenceInWeeks.test.d.ts +2 -0
  81. package/dist/differenceInWeeks.test.d.ts.map +1 -0
  82. package/dist/differenceInYears.d.ts +43 -0
  83. package/dist/differenceInYears.d.ts.map +1 -0
  84. package/dist/differenceInYears.js +8 -0
  85. package/dist/differenceInYears.js.map +1 -0
  86. package/dist/differenceInYears.test.d.ts +2 -0
  87. package/dist/differenceInYears.test.d.ts.map +1 -0
  88. package/dist/index.d.ts +13 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +66 -14
  91. package/dist/intlFormatDistance.d.ts +85 -0
  92. package/dist/intlFormatDistance.d.ts.map +1 -0
  93. package/dist/intlFormatDistance.js +15 -0
  94. package/dist/intlFormatDistance.js.map +1 -0
  95. package/dist/intlFormatDistance.test.d.ts +2 -0
  96. package/dist/intlFormatDistance.test.d.ts.map +1 -0
  97. package/dist/isFuture.d.ts +35 -0
  98. package/dist/isFuture.d.ts.map +1 -0
  99. package/dist/isFuture.js +8 -0
  100. package/dist/isFuture.js.map +1 -0
  101. package/dist/isFuture.test.d.ts +2 -0
  102. package/dist/isFuture.test.d.ts.map +1 -0
  103. package/dist/isPast.d.ts +35 -0
  104. package/dist/isPast.d.ts.map +1 -0
  105. package/dist/isPast.js +8 -0
  106. package/dist/isPast.js.map +1 -0
  107. package/dist/isPast.test.d.ts +2 -0
  108. package/dist/isPast.test.d.ts.map +1 -0
  109. package/package.json +1 -1
package/README.md CHANGED
@@ -120,6 +120,84 @@ console.log(iso2); // "2025-01-20T20:00:00Z"
120
120
 
121
121
  ### Formatting
122
122
 
123
+ #### `intlFormatDistance(laterDate, earlierDate, options?)`
124
+
125
+ Format the distance between two dates as a human-readable, internationalized string using `Intl.RelativeTimeFormat`. Automatically selects the most appropriate unit (seconds, minutes, hours, days, weeks, months, years) based on the distance.
126
+
127
+ **Parameters:**
128
+ - `laterDate` (Temporal.Instant | Temporal.ZonedDateTime): The later date to compare
129
+ - `earlierDate` (Temporal.Instant | Temporal.ZonedDateTime): The earlier date to compare with
130
+ - `options` (IntlFormatDistanceOptions, optional): Formatting options
131
+ - `unit` (Intl.RelativeTimeFormatUnit): Force a specific unit instead of automatic selection
132
+ - `locale` (string | string[]): Locale for formatting (default: system locale)
133
+ - `numeric` ('always' | 'auto'): Use numeric values always or allow natural language like "tomorrow" (default: 'auto')
134
+ - `style` ('long' | 'short' | 'narrow'): Formatting style (default: 'long')
135
+ - `localeMatcher` ('best fit' | 'lookup'): Locale matching algorithm
136
+
137
+ **Returns:** `string` - Formatted relative time string
138
+
139
+ **Automatic unit selection:**
140
+ - < 60 seconds → "in X seconds" / "X seconds ago"
141
+ - < 60 minutes → "in X minutes" / "X minutes ago"
142
+ - < 24 hours → "in X hours" / "X hours ago"
143
+ - < 7 days → "tomorrow" / "yesterday" / "in X days" / "X days ago"
144
+ - < 4 weeks → "next week" / "last week" / "in X weeks" / "X weeks ago"
145
+ - < 12 months → "next month" / "last month" / "in X months" / "X months ago"
146
+ - ≥ 12 months → "next year" / "last year" / "in X years" / "X years ago"
147
+
148
+ **Example:**
149
+ ```typescript
150
+ import { intlFormatDistance } from '@gobrand/tiempo';
151
+
152
+ const later = Temporal.Instant.from('2025-01-20T12:00:00Z');
153
+ const earlier = Temporal.Instant.from('2025-01-20T11:00:00Z');
154
+
155
+ // Basic usage
156
+ intlFormatDistance(later, earlier);
157
+ // => "in 1 hour"
158
+
159
+ intlFormatDistance(earlier, later);
160
+ // => "1 hour ago"
161
+
162
+ // With different locales
163
+ intlFormatDistance(later, earlier, { locale: 'es' });
164
+ // => "dentro de 1 hora"
165
+
166
+ intlFormatDistance(later, earlier, { locale: 'ja' });
167
+ // => "1 時間後"
168
+
169
+ // Force numeric format
170
+ const tomorrow = Temporal.Instant.from('2025-01-21T00:00:00Z');
171
+ const today = Temporal.Instant.from('2025-01-20T00:00:00Z');
172
+
173
+ intlFormatDistance(tomorrow, today, { numeric: 'auto' });
174
+ // => "tomorrow"
175
+
176
+ intlFormatDistance(tomorrow, today, { numeric: 'always' });
177
+ // => "in 1 day"
178
+
179
+ // Different styles
180
+ const future = Temporal.Instant.from('2027-01-20T00:00:00Z');
181
+ const now = Temporal.Instant.from('2025-01-20T00:00:00Z');
182
+
183
+ intlFormatDistance(future, now, { style: 'long' });
184
+ // => "in 2 years"
185
+
186
+ intlFormatDistance(future, now, { style: 'short' });
187
+ // => "in 2 yr."
188
+
189
+ intlFormatDistance(future, now, { style: 'narrow' });
190
+ // => "in 2y"
191
+
192
+ // Force specific units
193
+ intlFormatDistance(future, now, { unit: 'quarter' });
194
+ // => "in 8 quarters"
195
+
196
+ const dayLater = Temporal.Instant.from('2025-01-21T00:00:00Z');
197
+ intlFormatDistance(dayLater, today, { unit: 'hour' });
198
+ // => "in 24 hours"
199
+ ```
200
+
123
201
  #### `format(input, formatStr, options?)`
124
202
 
125
203
  Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.
@@ -270,32 +348,178 @@ endOfYear(zoned); // 2025-12-31T23:59:59.999999999-05:00[America/New_York]
270
348
 
271
349
  ### Comparison Utilities
272
350
 
273
- #### `isBefore(date1, date2)`
351
+ #### `isBefore(date1, date2)` / `isAfter(date1, date2)`
274
352
 
275
- Check if the first datetime is before the second. Compares the underlying instant in time.
353
+ Check if the first datetime is before or after the second. Compares the underlying instant in time.
276
354
 
277
355
  ```typescript
278
- import { isBefore } from '@gobrand/tiempo';
356
+ import { isBefore, isAfter } from '@gobrand/tiempo';
279
357
 
280
358
  const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
281
359
  const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
282
360
 
283
361
  isBefore(earlier, later); // true
284
362
  isBefore(later, earlier); // false
363
+
364
+ isAfter(later, earlier); // true
365
+ isAfter(earlier, later); // false
285
366
  ```
286
367
 
287
- #### `isAfter(date1, date2)`
368
+ ### Difference Utilities
288
369
 
289
- Check if the first datetime is after the second. Compares the underlying instant in time.
370
+ All difference functions compare the underlying instant in time and return a positive value if laterDate is after earlierDate, negative if before.
371
+
372
+ #### Time-based precision (instant comparison)
373
+
374
+ ##### `differenceInNanoseconds(laterDate, earlierDate)`
375
+
376
+ Returns the difference in nanoseconds as a BigInt. Provides the highest precision available in Temporal.
290
377
 
291
378
  ```typescript
292
- import { isAfter } from '@gobrand/tiempo';
379
+ import { differenceInNanoseconds } from '@gobrand/tiempo';
293
380
 
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]');
381
+ const later = Temporal.Instant.from('2025-01-20T12:30:20.000000500Z');
382
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000000Z');
383
+ differenceInNanoseconds(later, earlier); // 500n
384
+ ```
296
385
 
297
- isAfter(later, earlier); // true
298
- isAfter(earlier, later); // false
386
+ ##### `differenceInMicroseconds(laterDate, earlierDate)`
387
+
388
+ Returns the difference in microseconds (1/1,000,000 second).
389
+
390
+ ```typescript
391
+ import { differenceInMicroseconds } from '@gobrand/tiempo';
392
+
393
+ const later = Temporal.Instant.from('2025-01-20T12:30:20.001000Z');
394
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.000000Z');
395
+ differenceInMicroseconds(later, earlier); // 1000
396
+ ```
397
+
398
+ ##### `differenceInMilliseconds(laterDate, earlierDate)`
399
+
400
+ Returns the difference in milliseconds (1/1,000 second).
401
+
402
+ ```typescript
403
+ import { differenceInMilliseconds } from '@gobrand/tiempo';
404
+
405
+ const later = Temporal.Instant.from('2025-01-20T12:30:21.700Z');
406
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20.600Z');
407
+ differenceInMilliseconds(later, earlier); // 1100
408
+ ```
409
+
410
+ ##### `differenceInSeconds(laterDate, earlierDate)`
411
+
412
+ Returns the difference in seconds (truncates sub-second precision).
413
+
414
+ ```typescript
415
+ import { differenceInSeconds } from '@gobrand/tiempo';
416
+
417
+ const later = Temporal.Instant.from('2025-01-20T12:30:25Z');
418
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:20Z');
419
+ differenceInSeconds(later, earlier); // 5
420
+ ```
421
+
422
+ ##### `differenceInMinutes(laterDate, earlierDate)`
423
+
424
+ Returns the difference in minutes (truncates sub-minute precision).
425
+
426
+ ```typescript
427
+ import { differenceInMinutes } from '@gobrand/tiempo';
428
+
429
+ const later = Temporal.Instant.from('2025-01-20T12:45:00Z');
430
+ const earlier = Temporal.Instant.from('2025-01-20T12:30:00Z');
431
+ differenceInMinutes(later, earlier); // 15
432
+ ```
433
+
434
+ ##### `differenceInHours(laterDate, earlierDate)`
435
+
436
+ Returns the difference in hours (truncates sub-hour precision).
437
+
438
+ ```typescript
439
+ import { differenceInHours } from '@gobrand/tiempo';
440
+
441
+ const later = Temporal.Instant.from('2025-01-20T18:00:00Z');
442
+ const earlier = Temporal.Instant.from('2025-01-20T15:00:00Z');
443
+ differenceInHours(later, earlier); // 3
444
+ ```
445
+
446
+ #### Calendar-aware precision
447
+
448
+ These functions use Temporal's `until()` method to account for variable-length calendar units.
449
+
450
+ ##### `differenceInDays(laterDate, earlierDate)`
451
+
452
+ Returns the difference in days. Calendar-aware, so it properly handles DST transitions where days can be 23, 24, or 25 hours.
453
+
454
+ ```typescript
455
+ import { differenceInDays } from '@gobrand/tiempo';
456
+
457
+ const later = Temporal.Instant.from('2025-01-25T12:00:00Z');
458
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
459
+ differenceInDays(later, earlier); // 5
460
+
461
+ // Handles DST transitions correctly
462
+ const afterDst = Temporal.ZonedDateTime.from('2025-03-10T12:00:00-04:00[America/New_York]');
463
+ const beforeDst = Temporal.ZonedDateTime.from('2025-03-08T12:00:00-05:00[America/New_York]');
464
+ differenceInDays(afterDst, beforeDst); // 2 (calendar days, not 48 hours)
465
+ ```
466
+
467
+ ##### `differenceInWeeks(laterDate, earlierDate)`
468
+
469
+ Returns the difference in weeks (7-day periods).
470
+
471
+ ```typescript
472
+ import { differenceInWeeks } from '@gobrand/tiempo';
473
+
474
+ const later = Temporal.Instant.from('2025-02-10T12:00:00Z');
475
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
476
+ differenceInWeeks(later, earlier); // 3
477
+ ```
478
+
479
+ ##### `differenceInMonths(laterDate, earlierDate)`
480
+
481
+ Returns the difference in months. Calendar-aware, properly handling months with different numbers of days (28-31).
482
+
483
+ ```typescript
484
+ import { differenceInMonths } from '@gobrand/tiempo';
485
+
486
+ const later = Temporal.Instant.from('2025-04-20T12:00:00Z');
487
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
488
+ differenceInMonths(later, earlier); // 3
489
+ ```
490
+
491
+ ##### `differenceInYears(laterDate, earlierDate)`
492
+
493
+ Returns the difference in years. Calendar-aware, properly handling leap years (366 days) and regular years (365 days).
494
+
495
+ ```typescript
496
+ import { differenceInYears } from '@gobrand/tiempo';
497
+
498
+ const later = Temporal.Instant.from('2028-01-20T12:00:00Z');
499
+ const earlier = Temporal.Instant.from('2025-01-20T12:00:00Z');
500
+ differenceInYears(later, earlier); // 3
501
+
502
+ // Calculate age
503
+ const today = Temporal.ZonedDateTime.from('2025-01-20T12:00:00Z[UTC]');
504
+ const birthdate = Temporal.ZonedDateTime.from('1990-01-20T12:00:00Z[UTC]');
505
+ differenceInYears(today, birthdate); // 35
506
+ ```
507
+
508
+ #### `isFuture(date)` / `isPast(date)`
509
+
510
+ Check if a datetime is in the future or past relative to the current moment. Compares against `Temporal.Now.instant()`.
511
+
512
+ ```typescript
513
+ import { isFuture, isPast } from '@gobrand/tiempo';
514
+
515
+ const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });
516
+ const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });
517
+
518
+ isFuture(tomorrow); // true
519
+ isFuture(yesterday); // false
520
+
521
+ isPast(yesterday); // true
522
+ isPast(tomorrow); // false
299
523
  ```
300
524
 
301
525
  #### `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,94 @@
1
+ import {
2
+ differenceInWeeks
3
+ } from "./chunk-PVAOUYXF.js";
4
+ import {
5
+ differenceInYears
6
+ } from "./chunk-CHW2EN2O.js";
7
+ import {
8
+ differenceInDays
9
+ } from "./chunk-6IP245MS.js";
10
+ import {
11
+ differenceInHours
12
+ } from "./chunk-PIDXROVB.js";
13
+ import {
14
+ differenceInMinutes
15
+ } from "./chunk-RJY62CDU.js";
16
+ import {
17
+ differenceInMonths
18
+ } from "./chunk-BIAPE4MR.js";
19
+ import {
20
+ differenceInSeconds
21
+ } from "./chunk-ZHRMURYP.js";
22
+ import {
23
+ normalizeTemporalInput
24
+ } from "./chunk-MJSZNWCV.js";
25
+
26
+ // src/intlFormatDistance.ts
27
+ function intlFormatDistance(laterDate, earlierDate, options) {
28
+ const zoned1 = normalizeTemporalInput(laterDate);
29
+ const zoned2 = normalizeTemporalInput(earlierDate);
30
+ let unit = options?.unit;
31
+ if (!unit) {
32
+ const absSeconds = Math.abs(differenceInSeconds(zoned1, zoned2));
33
+ const absMinutes = Math.abs(differenceInMinutes(zoned1, zoned2));
34
+ const absHours = Math.abs(differenceInHours(zoned1, zoned2));
35
+ const absDays = Math.abs(differenceInDays(zoned1, zoned2));
36
+ const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2));
37
+ const absMonths = Math.abs(differenceInMonths(zoned1, zoned2));
38
+ if (absSeconds < 60) {
39
+ unit = "second";
40
+ } else if (absMinutes < 60) {
41
+ unit = "minute";
42
+ } else if (absHours < 24) {
43
+ unit = "hour";
44
+ } else if (absDays < 7) {
45
+ unit = "day";
46
+ } else if (absWeeks < 4) {
47
+ unit = "week";
48
+ } else if (absMonths < 12) {
49
+ unit = "month";
50
+ } else {
51
+ unit = "year";
52
+ }
53
+ }
54
+ let value;
55
+ switch (unit) {
56
+ case "second":
57
+ value = differenceInSeconds(zoned1, zoned2);
58
+ break;
59
+ case "minute":
60
+ value = differenceInMinutes(zoned1, zoned2);
61
+ break;
62
+ case "hour":
63
+ value = differenceInHours(zoned1, zoned2);
64
+ break;
65
+ case "day":
66
+ value = differenceInDays(zoned1, zoned2);
67
+ break;
68
+ case "week":
69
+ value = differenceInWeeks(zoned1, zoned2);
70
+ break;
71
+ case "month":
72
+ value = differenceInMonths(zoned1, zoned2);
73
+ break;
74
+ case "quarter":
75
+ value = Math.round(differenceInMonths(zoned1, zoned2) / 3);
76
+ break;
77
+ case "year":
78
+ value = differenceInYears(zoned1, zoned2);
79
+ break;
80
+ default:
81
+ value = differenceInSeconds(zoned1, zoned2);
82
+ }
83
+ const formatter = new Intl.RelativeTimeFormat(options?.locale, {
84
+ localeMatcher: options?.localeMatcher,
85
+ numeric: options?.numeric ?? "auto",
86
+ style: options?.style
87
+ });
88
+ return formatter.format(value, unit);
89
+ }
90
+
91
+ export {
92
+ intlFormatDistance
93
+ };
94
+ //# sourceMappingURL=chunk-NL5LWPJI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intlFormatDistance.ts"],"sourcesContent":["import type { Temporal } from '@js-temporal/polyfill';\nimport { differenceInDays } from './differenceInDays.js';\nimport { differenceInHours } from './differenceInHours.js';\nimport { differenceInMinutes } from './differenceInMinutes.js';\nimport { differenceInMonths } from './differenceInMonths.js';\nimport { differenceInSeconds } from './differenceInSeconds.js';\nimport { differenceInWeeks } from './differenceInWeeks.js';\nimport { differenceInYears } from './differenceInYears.js';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput.js';\n\nexport interface IntlFormatDistanceOptions {\n /**\n * The unit to force formatting in. If not specified, the unit will be automatically selected.\n */\n unit?: Intl.RelativeTimeFormatUnit;\n /**\n * The locale to use for formatting. Defaults to the system locale.\n */\n locale?: string | string[];\n /**\n * The locale matching algorithm to use.\n */\n localeMatcher?: 'best fit' | 'lookup';\n /**\n * Whether to use numeric values always, or use special strings like \"yesterday\", \"tomorrow\", etc.\n * Defaults to 'auto'.\n */\n numeric?: 'always' | 'auto';\n /**\n * The formatting style to use.\n */\n style?: 'long' | 'short' | 'narrow';\n}\n\n/**\n * Formats the distance between two dates as a human-readable, internationalized string.\n *\n * The function automatically picks the most appropriate unit based on the distance between dates.\n * For example, if the distance is a few hours, it returns \"in X hours\". If the distance is a few\n * months, it returns \"in X months\".\n *\n * You can force a specific unit using the `options.unit` parameter.\n *\n * @param laterDate - The later date to compare\n * @param earlierDate - The earlier date to compare with\n * @param options - Formatting options\n * @returns The formatted distance string\n *\n * @example\n * ```typescript\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier);\n * // => 'in 1 hour'\n *\n * intlFormatDistance(earlier, later);\n * // => '1 hour ago'\n * ```\n *\n * @example\n * ```typescript\n * // Force a specific unit\n * const later = Temporal.Instant.from('2025-01-01T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { unit: 'quarter' });\n * // => 'in 4 quarters'\n * ```\n *\n * @example\n * ```typescript\n * // Use a different locale\n * const later = Temporal.Instant.from('2024-01-01T12:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T11:00:00Z');\n *\n * intlFormatDistance(later, earlier, { locale: 'es' });\n * // => 'dentro de 1 hora'\n * ```\n *\n * @example\n * ```typescript\n * // Use numeric: 'always' to avoid special strings\n * const later = Temporal.Instant.from('2024-01-02T00:00:00Z');\n * const earlier = Temporal.Instant.from('2024-01-01T00:00:00Z');\n *\n * intlFormatDistance(later, earlier, { numeric: 'auto' });\n * // => 'tomorrow'\n *\n * intlFormatDistance(later, earlier, { numeric: 'always' });\n * // => 'in 1 day'\n * ```\n */\nexport function intlFormatDistance(\n laterDate: Temporal.Instant | Temporal.ZonedDateTime,\n earlierDate: Temporal.Instant | Temporal.ZonedDateTime,\n options?: IntlFormatDistanceOptions\n): string {\n const zoned1 = normalizeTemporalInput(laterDate);\n const zoned2 = normalizeTemporalInput(earlierDate);\n\n // Determine unit if not specified\n let unit = options?.unit;\n if (!unit) {\n const absSeconds = Math.abs(differenceInSeconds(zoned1, zoned2));\n const absMinutes = Math.abs(differenceInMinutes(zoned1, zoned2));\n const absHours = Math.abs(differenceInHours(zoned1, zoned2));\n const absDays = Math.abs(differenceInDays(zoned1, zoned2));\n const absWeeks = Math.abs(differenceInWeeks(zoned1, zoned2));\n const absMonths = Math.abs(differenceInMonths(zoned1, zoned2));\n\n if (absSeconds < 60) {\n unit = 'second';\n } else if (absMinutes < 60) {\n unit = 'minute';\n } else if (absHours < 24) {\n unit = 'hour';\n } else if (absDays < 7) {\n unit = 'day';\n } else if (absWeeks < 4) {\n unit = 'week';\n } else if (absMonths < 12) {\n unit = 'month';\n } else {\n unit = 'year';\n }\n }\n\n // Calculate value for the selected unit\n let value: number;\n switch (unit) {\n case 'second':\n value = differenceInSeconds(zoned1, zoned2);\n break;\n case 'minute':\n value = differenceInMinutes(zoned1, zoned2);\n break;\n case 'hour':\n value = differenceInHours(zoned1, zoned2);\n break;\n case 'day':\n value = differenceInDays(zoned1, zoned2);\n break;\n case 'week':\n value = differenceInWeeks(zoned1, zoned2);\n break;\n case 'month':\n value = differenceInMonths(zoned1, zoned2);\n break;\n case 'quarter':\n value = Math.round(differenceInMonths(zoned1, zoned2) / 3);\n break;\n case 'year':\n value = differenceInYears(zoned1, zoned2);\n break;\n default:\n // For any other unit type, try to use it directly\n value = differenceInSeconds(zoned1, zoned2);\n }\n\n // Format using Intl.RelativeTimeFormat\n const formatter = new Intl.RelativeTimeFormat(options?.locale, {\n localeMatcher: options?.localeMatcher,\n numeric: options?.numeric ?? 'auto',\n style: options?.style,\n });\n\n return formatter.format(value, unit);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6FO,SAAS,mBACd,WACA,aACA,SACQ;AACR,QAAM,SAAS,uBAAuB,SAAS;AAC/C,QAAM,SAAS,uBAAuB,WAAW;AAGjD,MAAI,OAAO,SAAS;AACpB,MAAI,CAAC,MAAM;AACT,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,aAAa,KAAK,IAAI,oBAAoB,QAAQ,MAAM,CAAC;AAC/D,UAAM,WAAW,KAAK,IAAI,kBAAkB,QAAQ,MAAM,CAAC;AAC3D,UAAM,UAAU,KAAK,IAAI,iBAAiB,QAAQ,MAAM,CAAC;AACzD,UAAM,WAAW,KAAK,IAAI,kBAAkB,QAAQ,MAAM,CAAC;AAC3D,UAAM,YAAY,KAAK,IAAI,mBAAmB,QAAQ,MAAM,CAAC;AAE7D,QAAI,aAAa,IAAI;AACnB,aAAO;AAAA,IACT,WAAW,aAAa,IAAI;AAC1B,aAAO;AAAA,IACT,WAAW,WAAW,IAAI;AACxB,aAAO;AAAA,IACT,WAAW,UAAU,GAAG;AACtB,aAAO;AAAA,IACT,WAAW,WAAW,GAAG;AACvB,aAAO;AAAA,IACT,WAAW,YAAY,IAAI;AACzB,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AAGA,MAAI;AACJ,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,cAAQ,oBAAoB,QAAQ,MAAM;AAC1C;AAAA,IACF,KAAK;AACH,cAAQ,oBAAoB,QAAQ,MAAM;AAC1C;AAAA,IACF,KAAK;AACH,cAAQ,kBAAkB,QAAQ,MAAM;AACxC;AAAA,IACF,KAAK;AACH,cAAQ,iBAAiB,QAAQ,MAAM;AACvC;AAAA,IACF,KAAK;AACH,cAAQ,kBAAkB,QAAQ,MAAM;AACxC;AAAA,IACF,KAAK;AACH,cAAQ,mBAAmB,QAAQ,MAAM;AACzC;AAAA,IACF,KAAK;AACH,cAAQ,KAAK,MAAM,mBAAmB,QAAQ,MAAM,IAAI,CAAC;AACzD;AAAA,IACF,KAAK;AACH,cAAQ,kBAAkB,QAAQ,MAAM;AACxC;AAAA,IACF;AAEE,cAAQ,oBAAoB,QAAQ,MAAM;AAAA,EAC9C;AAGA,QAAM,YAAY,IAAI,KAAK,mBAAmB,SAAS,QAAQ;AAAA,IAC7D,eAAe,SAAS;AAAA,IACxB,SAAS,SAAS,WAAW;AAAA,IAC7B,OAAO,SAAS;AAAA,EAClB,CAAC;AAED,SAAO,UAAU,OAAO,OAAO,IAAI;AACrC;","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":[]}