@gobrand/tiempo 2.2.0 → 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 (122) hide show
  1. package/README.md +199 -10
  2. package/dist/chunk-2H4KLXGL.js +16 -0
  3. package/dist/chunk-2H4KLXGL.js.map +1 -0
  4. package/dist/chunk-3YGPHHB6.js +13 -0
  5. package/dist/chunk-3YGPHHB6.js.map +1 -0
  6. package/dist/{chunk-ANLD6IWG.js → chunk-67QHALIG.js} +4 -4
  7. package/dist/chunk-67QHALIG.js.map +1 -0
  8. package/dist/chunk-6IP245MS.js +17 -0
  9. package/dist/chunk-6IP245MS.js.map +1 -0
  10. package/dist/chunk-BIAPE4MR.js +17 -0
  11. package/dist/chunk-BIAPE4MR.js.map +1 -0
  12. package/dist/chunk-CHW2EN2O.js +17 -0
  13. package/dist/chunk-CHW2EN2O.js.map +1 -0
  14. package/dist/chunk-D7DPB2JR.js +16 -0
  15. package/dist/chunk-D7DPB2JR.js.map +1 -0
  16. package/dist/chunk-OABS374T.js +16 -0
  17. package/dist/chunk-OABS374T.js.map +1 -0
  18. package/dist/chunk-PIDXROVB.js +16 -0
  19. package/dist/chunk-PIDXROVB.js.map +1 -0
  20. package/dist/chunk-PVAOUYXF.js +17 -0
  21. package/dist/chunk-PVAOUYXF.js.map +1 -0
  22. package/dist/chunk-R5XN76EV.js +16 -0
  23. package/dist/chunk-R5XN76EV.js.map +1 -0
  24. package/dist/chunk-RJY62CDU.js +16 -0
  25. package/dist/chunk-RJY62CDU.js.map +1 -0
  26. package/dist/chunk-ZGR4NZTS.js +17 -0
  27. package/dist/chunk-ZGR4NZTS.js.map +1 -0
  28. package/dist/chunk-ZHRMURYP.js +16 -0
  29. package/dist/chunk-ZHRMURYP.js.map +1 -0
  30. package/dist/differenceInDays.d.ts +43 -0
  31. package/dist/differenceInDays.d.ts.map +1 -0
  32. package/dist/differenceInDays.js +8 -0
  33. package/dist/differenceInDays.test.d.ts +2 -0
  34. package/dist/differenceInDays.test.d.ts.map +1 -0
  35. package/dist/differenceInHours.d.ts +37 -0
  36. package/dist/differenceInHours.d.ts.map +1 -0
  37. package/dist/differenceInHours.js +8 -0
  38. package/dist/differenceInHours.js.map +1 -0
  39. package/dist/differenceInHours.test.d.ts +2 -0
  40. package/dist/differenceInHours.test.d.ts.map +1 -0
  41. package/dist/differenceInMicroseconds.d.ts +37 -0
  42. package/dist/differenceInMicroseconds.d.ts.map +1 -0
  43. package/dist/differenceInMicroseconds.js +8 -0
  44. package/dist/differenceInMicroseconds.js.map +1 -0
  45. package/dist/differenceInMicroseconds.test.d.ts +2 -0
  46. package/dist/differenceInMicroseconds.test.d.ts.map +1 -0
  47. package/dist/differenceInMilliseconds.d.ts +37 -0
  48. package/dist/differenceInMilliseconds.d.ts.map +1 -0
  49. package/dist/differenceInMilliseconds.js +8 -0
  50. package/dist/differenceInMilliseconds.js.map +1 -0
  51. package/dist/differenceInMilliseconds.test.d.ts +2 -0
  52. package/dist/differenceInMilliseconds.test.d.ts.map +1 -0
  53. package/dist/differenceInMinutes.d.ts +37 -0
  54. package/dist/differenceInMinutes.d.ts.map +1 -0
  55. package/dist/differenceInMinutes.js +8 -0
  56. package/dist/differenceInMinutes.js.map +1 -0
  57. package/dist/differenceInMinutes.test.d.ts +2 -0
  58. package/dist/differenceInMinutes.test.d.ts.map +1 -0
  59. package/dist/differenceInMonths.d.ts +43 -0
  60. package/dist/differenceInMonths.d.ts.map +1 -0
  61. package/dist/differenceInMonths.js +8 -0
  62. package/dist/differenceInMonths.js.map +1 -0
  63. package/dist/differenceInMonths.test.d.ts +2 -0
  64. package/dist/differenceInMonths.test.d.ts.map +1 -0
  65. package/dist/differenceInNanoseconds.d.ts +37 -0
  66. package/dist/differenceInNanoseconds.d.ts.map +1 -0
  67. package/dist/differenceInNanoseconds.js +8 -0
  68. package/dist/differenceInNanoseconds.js.map +1 -0
  69. package/dist/differenceInNanoseconds.test.d.ts +2 -0
  70. package/dist/differenceInNanoseconds.test.d.ts.map +1 -0
  71. package/dist/differenceInSeconds.d.ts +37 -0
  72. package/dist/differenceInSeconds.d.ts.map +1 -0
  73. package/dist/differenceInSeconds.js +8 -0
  74. package/dist/differenceInSeconds.js.map +1 -0
  75. package/dist/differenceInSeconds.test.d.ts +2 -0
  76. package/dist/differenceInSeconds.test.d.ts.map +1 -0
  77. package/dist/differenceInWeeks.d.ts +43 -0
  78. package/dist/differenceInWeeks.d.ts.map +1 -0
  79. package/dist/differenceInWeeks.js +8 -0
  80. package/dist/differenceInWeeks.js.map +1 -0
  81. package/dist/differenceInWeeks.test.d.ts +2 -0
  82. package/dist/differenceInWeeks.test.d.ts.map +1 -0
  83. package/dist/differenceInYears.d.ts +43 -0
  84. package/dist/differenceInYears.d.ts.map +1 -0
  85. package/dist/differenceInYears.js +8 -0
  86. package/dist/differenceInYears.js.map +1 -0
  87. package/dist/differenceInYears.test.d.ts +2 -0
  88. package/dist/differenceInYears.test.d.ts.map +1 -0
  89. package/dist/index.d.ts +14 -1
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +65 -13
  92. package/dist/isFuture.d.ts +35 -0
  93. package/dist/isFuture.d.ts.map +1 -0
  94. package/dist/isFuture.js +8 -0
  95. package/dist/isFuture.js.map +1 -0
  96. package/dist/isFuture.test.d.ts +2 -0
  97. package/dist/isFuture.test.d.ts.map +1 -0
  98. package/dist/isPast.d.ts +35 -0
  99. package/dist/isPast.d.ts.map +1 -0
  100. package/dist/isPast.js +8 -0
  101. package/dist/isPast.js.map +1 -0
  102. package/dist/isPast.test.d.ts +2 -0
  103. package/dist/isPast.test.d.ts.map +1 -0
  104. package/dist/now.d.ts +21 -0
  105. package/dist/now.d.ts.map +1 -0
  106. package/dist/now.js +7 -0
  107. package/dist/now.js.map +1 -0
  108. package/dist/now.test.d.ts +2 -0
  109. package/dist/now.test.d.ts.map +1 -0
  110. package/dist/{getToday.d.ts → today.d.ts} +5 -5
  111. package/dist/today.d.ts.map +1 -0
  112. package/dist/today.js +7 -0
  113. package/dist/today.js.map +1 -0
  114. package/dist/today.test.d.ts +2 -0
  115. package/dist/today.test.d.ts.map +1 -0
  116. package/package.json +1 -1
  117. package/dist/chunk-ANLD6IWG.js.map +0 -1
  118. package/dist/getToday.d.ts.map +0 -1
  119. package/dist/getToday.js +0 -7
  120. package/dist/getToday.test.d.ts +0 -2
  121. package/dist/getToday.test.d.ts.map +0 -1
  122. /package/dist/{getToday.js.map → differenceInDays.js.map} +0 -0
package/README.md CHANGED
@@ -173,6 +173,49 @@ format(instant, "yyyy-MM-dd HH:mm", { timeZone: "Asia/Tokyo" }); // "2025-01-21
173
173
 
174
174
  ### Start/End Utilities
175
175
 
176
+ #### `today(timezone?)`
177
+
178
+ Get today's date in the system's local timezone or a specified timezone.
179
+
180
+ **Parameters:**
181
+ - `timezone` (string, optional): An IANA timezone identifier (e.g., `"America/New_York"`, `"Europe/Madrid"`) or `"UTC"`. If not provided, uses the system's local timezone.
182
+
183
+ **Returns:** `Temporal.PlainDate` - A Temporal.PlainDate representing today's date
184
+
185
+ **Example:**
186
+ ```typescript
187
+ import { today } from '@gobrand/tiempo';
188
+
189
+ const date = today(); // 2025-01-20
190
+ date.year; // 2025
191
+ date.month; // 1
192
+ date.day; // 20
193
+
194
+ // Get today in a specific timezone
195
+ const dateInTokyo = today("Asia/Tokyo"); // 2025-01-21 (next day due to timezone)
196
+ ```
197
+
198
+ #### `now(timezone?)`
199
+
200
+ Get the current date and time in the system's local timezone or a specified timezone.
201
+
202
+ **Parameters:**
203
+ - `timezone` (string, optional): An IANA timezone identifier (e.g., `"America/New_York"`, `"Europe/Madrid"`) or `"UTC"`. If not provided, uses the system's local timezone.
204
+
205
+ **Returns:** `Temporal.ZonedDateTime` - A Temporal.ZonedDateTime representing the current date and time
206
+
207
+ **Example:**
208
+ ```typescript
209
+ import { now } from '@gobrand/tiempo';
210
+
211
+ const current = now(); // 2025-01-20T15:30:45.123-05:00[America/New_York]
212
+ current.hour; // 15
213
+ current.minute; // 30
214
+
215
+ // Get current time in a specific timezone
216
+ const currentInTokyo = now("Asia/Tokyo"); // 2025-01-21T05:30:45.123+09:00[Asia/Tokyo]
217
+ ```
218
+
176
219
  #### `startOfDay(input)` / `endOfDay(input)`
177
220
 
178
221
  Get the start or end of the day for a given datetime.
@@ -227,32 +270,178 @@ endOfYear(zoned); // 2025-12-31T23:59:59.999999999-05:00[America/New_York]
227
270
 
228
271
  ### Comparison Utilities
229
272
 
230
- #### `isBefore(date1, date2)`
273
+ #### `isBefore(date1, date2)` / `isAfter(date1, date2)`
231
274
 
232
- 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.
233
276
 
234
277
  ```typescript
235
- import { isBefore } from '@gobrand/tiempo';
278
+ import { isBefore, isAfter } from '@gobrand/tiempo';
236
279
 
237
280
  const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
238
281
  const later = Temporal.ZonedDateTime.from('2025-01-20T15:00:00-05:00[America/New_York]');
239
282
 
240
283
  isBefore(earlier, later); // true
241
284
  isBefore(later, earlier); // false
285
+
286
+ isAfter(later, earlier); // true
287
+ isAfter(earlier, later); // false
242
288
  ```
243
289
 
244
- #### `isAfter(date1, date2)`
290
+ ### Difference Utilities
245
291
 
246
- Check if the first datetime is after the second. Compares the underlying instant in time.
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)
295
+
296
+ ##### `differenceInNanoseconds(laterDate, earlierDate)`
297
+
298
+ Returns the difference in nanoseconds as a BigInt. Provides the highest precision available in Temporal.
247
299
 
248
300
  ```typescript
249
- import { isAfter } from '@gobrand/tiempo';
301
+ import { differenceInNanoseconds } from '@gobrand/tiempo';
250
302
 
251
- const earlier = Temporal.ZonedDateTime.from('2025-01-20T10:00:00-05:00[America/New_York]');
252
- 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
+ ```
253
307
 
254
- isAfter(later, earlier); // true
255
- 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
256
445
  ```
257
446
 
258
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,13 @@
1
+ // src/now.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ function now(timezone) {
4
+ if (timezone) {
5
+ return Temporal.Now.zonedDateTimeISO(timezone);
6
+ }
7
+ return Temporal.Now.zonedDateTimeISO();
8
+ }
9
+
10
+ export {
11
+ now
12
+ };
13
+ //# sourceMappingURL=chunk-3YGPHHB6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/now.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Get the current date and time in the system's local timezone or a specified timezone.\n *\n * @param timezone - Optional IANA timezone identifier (e.g., \"America/Asuncion\", \"Europe/Madrid\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime representing the current date and time\n *\n * @example\n * ```typescript\n * // Get now in local timezone\n * const current = now();\n *\n * // Get now in Madrid\n * const nowInMadrid = now(\"Europe/Madrid\");\n *\n * // Get now in UTC\n * const nowUtc = now(\"UTC\");\n * ```\n */\nexport function now(timezone?: 'UTC' | string): Temporal.ZonedDateTime {\n if (timezone) {\n return Temporal.Now.zonedDateTimeISO(timezone);\n }\n return Temporal.Now.zonedDateTimeISO();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,IAAI,UAAmD;AACrE,MAAI,UAAU;AACZ,WAAO,SAAS,IAAI,iBAAiB,QAAQ;AAAA,EAC/C;AACA,SAAO,SAAS,IAAI,iBAAiB;AACvC;","names":[]}
@@ -1,6 +1,6 @@
1
- // src/getToday.ts
1
+ // src/today.ts
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
- function getToday(timezone) {
3
+ function today(timezone) {
4
4
  if (timezone) {
5
5
  return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();
6
6
  }
@@ -8,6 +8,6 @@ function getToday(timezone) {
8
8
  }
9
9
 
10
10
  export {
11
- getToday
11
+ today
12
12
  };
13
- //# sourceMappingURL=chunk-ANLD6IWG.js.map
13
+ //# sourceMappingURL=chunk-67QHALIG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/today.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Get today's date in the system's local timezone or a specified timezone.\n *\n * @param timezone - Optional IANA timezone identifier (e.g., \"America/Asuncion\", \"Europe/Madrid\") or \"UTC\"\n * @returns A Temporal.PlainDate representing today's date\n *\n * @example\n * ```typescript\n * // Get today in local timezone\n * const date = today();\n *\n * // Get today in Madrid\n * const todayInMadrid = today(\"Europe/Madrid\");\n *\n * // Get today in UTC\n * const todayUtc = today(\"UTC\");\n * ```\n */\nexport function today(timezone?: \"UTC\" | string): Temporal.PlainDate {\n if (timezone) {\n return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();\n }\n return Temporal.Now.plainDateISO();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,MAAM,UAA+C;AACnE,MAAI,UAAU;AACZ,WAAO,SAAS,IAAI,iBAAiB,QAAQ,EAAE,YAAY;AAAA,EAC7D;AACA,SAAO,SAAS,IAAI,aAAa;AACnC;","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