@gobrand/tiempo 2.4.0 → 2.5.0

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/browserTimezone.d.ts +23 -0
  3. package/dist/browserTimezone.d.ts.map +1 -0
  4. package/dist/browserTimezone.js +7 -0
  5. package/dist/browserTimezone.js.map +1 -0
  6. package/dist/browserTimezone.test.d.ts +2 -0
  7. package/dist/browserTimezone.test.d.ts.map +1 -0
  8. package/dist/chunk-FSD3DDFC.js +10 -0
  9. package/dist/chunk-FSD3DDFC.js.map +1 -0
  10. package/dist/chunk-JGQPEN2G.js +9 -0
  11. package/dist/chunk-JGQPEN2G.js.map +1 -0
  12. package/dist/chunk-KZB6NERH.js +10 -0
  13. package/dist/chunk-KZB6NERH.js.map +1 -0
  14. package/dist/{chunk-2MP3ESL7.js → chunk-MXQFENCR.js} +1 -1
  15. package/dist/chunk-MXQFENCR.js.map +1 -0
  16. package/dist/{chunk-XEDXPI5G.js → chunk-TDQXOSO3.js} +4 -4
  17. package/dist/{chunk-GQBO2UXH.js → chunk-TFSZ55L7.js} +1 -1
  18. package/dist/chunk-TFSZ55L7.js.map +1 -0
  19. package/dist/{chunk-2G5RJGPR.js → chunk-ZC6KWXCW.js} +1 -1
  20. package/dist/chunk-ZC6KWXCW.js.map +1 -0
  21. package/dist/format.d.ts +2 -1
  22. package/dist/format.d.ts.map +1 -1
  23. package/dist/format.js +1 -1
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +26 -22
  27. package/dist/intlFormatDistance.js +2 -2
  28. package/dist/now.d.ts +15 -9
  29. package/dist/now.d.ts.map +1 -1
  30. package/dist/now.js +1 -1
  31. package/dist/simpleFormat.d.ts +3 -2
  32. package/dist/simpleFormat.d.ts.map +1 -1
  33. package/dist/simpleFormat.js +1 -1
  34. package/dist/toZonedTime.d.ts +15 -7
  35. package/dist/toZonedTime.d.ts.map +1 -1
  36. package/dist/toZonedTime.js +1 -1
  37. package/dist/today.d.ts +15 -9
  38. package/dist/today.d.ts.map +1 -1
  39. package/dist/today.js +1 -1
  40. package/dist/types/iana-timezones.d.ts +12 -0
  41. package/dist/types/iana-timezones.d.ts.map +1 -0
  42. package/dist/types/iana-timezones.js +1 -0
  43. package/dist/types/iana-timezones.js.map +1 -0
  44. package/dist/types.d.ts +17 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +1 -0
  47. package/dist/types.js.map +1 -0
  48. package/package.json +4 -2
  49. package/dist/chunk-2G5RJGPR.js.map +0 -1
  50. package/dist/chunk-2MP3ESL7.js.map +0 -1
  51. package/dist/chunk-3YGPHHB6.js +0 -13
  52. package/dist/chunk-3YGPHHB6.js.map +0 -1
  53. package/dist/chunk-67QHALIG.js +0 -13
  54. package/dist/chunk-67QHALIG.js.map +0 -1
  55. package/dist/chunk-GQBO2UXH.js.map +0 -1
  56. /package/dist/{chunk-XEDXPI5G.js.map → chunk-TDQXOSO3.js.map} +0 -0
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![CI](https://github.com/go-brand/tiempo/actions/workflows/ci.yml/badge.svg)](https://github.com/go-brand/tiempo/actions/workflows/ci.yml)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- ![tiempo clock visualization](./clock-visualization.png)
7
+ ![tiempo banner](./tiempo_banner.png)
8
8
 
9
9
  **Timezone conversions that don't suck.** Built on the [Temporal API](https://tc39.es/proposal-temporal/docs/).
10
10
 
@@ -0,0 +1,23 @@
1
+ import type { IANATimezone } from './types/iana-timezones';
2
+ /**
3
+ * Get the browser/device timezone.
4
+ *
5
+ * Returns the IANA timezone identifier configured on the user's device.
6
+ * This is primarily useful in client-side code (browsers, React Native).
7
+ *
8
+ * **Warning:** On servers, this returns the server's configured timezone
9
+ * (often "UTC"), which is rarely what you want. For user-specific timezones
10
+ * on the server, retrieve the timezone from user preferences or request headers.
11
+ *
12
+ * @returns The IANA timezone identifier (e.g., "America/New_York", "Europe/London")
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';
17
+ *
18
+ * // Convert UTC to the user's local timezone
19
+ * const userTime = toZonedTime("2025-01-20T20:00:00Z", browserTimezone());
20
+ * ```
21
+ */
22
+ export declare function browserTimezone(): IANATimezone;
23
+ //# sourceMappingURL=browserTimezone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserTimezone.d.ts","sourceRoot":"","sources":["../src/browserTimezone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
@@ -0,0 +1,7 @@
1
+ import {
2
+ browserTimezone
3
+ } from "./chunk-JGQPEN2G.js";
4
+ export {
5
+ browserTimezone
6
+ };
7
+ //# sourceMappingURL=browserTimezone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=browserTimezone.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserTimezone.test.d.ts","sourceRoot":"","sources":["../src/browserTimezone.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ // src/now.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ function now(timezone) {
4
+ return Temporal.Now.zonedDateTimeISO(timezone);
5
+ }
6
+
7
+ export {
8
+ now
9
+ };
10
+ //# sourceMappingURL=chunk-FSD3DDFC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/now.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n/**\n * Get the current date and time in the specified timezone.\n *\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime representing the current date and time\n *\n * @example\n * ```typescript\n * import { now, browserTimezone } from '@gobrand/tiempo';\n *\n * // Server-side: Get now in UTC\n * const nowUtc = now(\"UTC\");\n *\n * // Server-side: Get now in user's timezone (from DB/preferences)\n * const nowUser = now(user.timezone);\n *\n * // Client-side: Get now in browser's timezone\n * const nowLocal = now(browserTimezone());\n *\n * // Get now in a specific timezone\n * const nowInMadrid = now(\"Europe/Madrid\");\n * ```\n */\nexport function now(timezone: Timezone): Temporal.ZonedDateTime {\n return Temporal.Now.zonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA0BlB,SAAS,IAAI,UAA4C;AAC9D,SAAO,SAAS,IAAI,iBAAiB,QAAQ;AAC/C;","names":[]}
@@ -0,0 +1,9 @@
1
+ // src/browserTimezone.ts
2
+ function browserTimezone() {
3
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
4
+ }
5
+
6
+ export {
7
+ browserTimezone
8
+ };
9
+ //# sourceMappingURL=chunk-JGQPEN2G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/browserTimezone.ts"],"sourcesContent":["import type { IANATimezone } from './types/iana-timezones';\n\n/**\n * Get the browser/device timezone.\n *\n * Returns the IANA timezone identifier configured on the user's device.\n * This is primarily useful in client-side code (browsers, React Native).\n *\n * **Warning:** On servers, this returns the server's configured timezone\n * (often \"UTC\"), which is rarely what you want. For user-specific timezones\n * on the server, retrieve the timezone from user preferences or request headers.\n *\n * @returns The IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")\n *\n * @example\n * ```typescript\n * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';\n *\n * // Convert UTC to the user's local timezone\n * const userTime = toZonedTime(\"2025-01-20T20:00:00Z\", browserTimezone());\n * ```\n */\nexport function browserTimezone(): IANATimezone {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as IANATimezone;\n}\n"],"mappings":";AAsBO,SAAS,kBAAgC;AAC9C,SAAO,KAAK,eAAe,EAAE,gBAAgB,EAAE;AACjD;","names":[]}
@@ -0,0 +1,10 @@
1
+ // src/today.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ function today(timezone) {
4
+ return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();
5
+ }
6
+
7
+ export {
8
+ today
9
+ };
10
+ //# sourceMappingURL=chunk-KZB6NERH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/today.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n/**\n * Get today's date in the specified timezone.\n *\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") or \"UTC\"\n * @returns A Temporal.PlainDate representing today's date\n *\n * @example\n * ```typescript\n * import { today, browserTimezone } from '@gobrand/tiempo';\n *\n * // Server-side: Get today in UTC\n * const todayUtc = today(\"UTC\");\n *\n * // Server-side: Get today in user's timezone (from DB/preferences)\n * const todayUser = today(user.timezone);\n *\n * // Client-side: Get today in browser's timezone\n * const todayLocal = today(browserTimezone());\n *\n * // Get today in a specific timezone\n * const todayInMadrid = today(\"Europe/Madrid\");\n * ```\n */\nexport function today(timezone: Timezone): Temporal.PlainDate {\n return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA0BlB,SAAS,MAAM,UAAwC;AAC5D,SAAO,SAAS,IAAI,iBAAiB,QAAQ,EAAE,YAAY;AAC7D;","names":[]}
@@ -16,4 +16,4 @@ function toZonedTime(input, timezone) {
16
16
  export {
17
17
  toZonedTime
18
18
  };
19
- //# sourceMappingURL=chunk-2MP3ESL7.js.map
19
+ //# sourceMappingURL=chunk-MXQFENCR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toZonedTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n/**\n * Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.\n *\n * @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime in the specified timezone\n *\n * @example\n * ```typescript\n * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';\n *\n * // Server-side: Convert to UTC\n * const utcTime = toZonedTime(\"2025-01-20T20:00:00Z\", \"UTC\");\n *\n * // Server-side: Convert to user's timezone (from DB/preferences)\n * const userTime = toZonedTime(\"2025-01-20T20:00:00Z\", user.timezone);\n *\n * // Client-side: Convert to browser's timezone\n * const localTime = toZonedTime(\"2025-01-20T20:00:00Z\", browserTimezone());\n *\n * // From Date (e.g., from Drizzle ORM)\n * const date = new Date(\"2025-01-20T20:00:00.000Z\");\n * const zoned = toZonedTime(date, \"America/New_York\");\n *\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const zoned = toZonedTime(instant, \"Asia/Tokyo\");\n *\n * // From ZonedDateTime (convert to different timezone)\n * const nyTime = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const tokyoTime = toZonedTime(nyTime, \"Asia/Tokyo\");\n * ```\n */\nexport function toZonedTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: Timezone\n): Temporal.ZonedDateTime {\n if (typeof input === 'string') {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Temporal.Instant) {\n return input.toZonedDateTimeISO(timezone);\n }\n\n return input.toInstant().toZonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoClB,SAAS,YACd,OACA,UACwB;AACxB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ;AAAA,EACjE;AAEA,MAAI,iBAAiB,MAAM;AACzB,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ;AAAA,EAC/E;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,mBAAmB,QAAQ;AAAA,EAC1C;AAEA,SAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AACtD;","names":[]}
@@ -1,3 +1,6 @@
1
+ import {
2
+ differenceInMonths
3
+ } from "./chunk-BIAPE4MR.js";
1
4
  import {
2
5
  differenceInSeconds
3
6
  } from "./chunk-ZHRMURYP.js";
@@ -16,9 +19,6 @@ import {
16
19
  import {
17
20
  differenceInMinutes
18
21
  } from "./chunk-RJY62CDU.js";
19
- import {
20
- differenceInMonths
21
- } from "./chunk-BIAPE4MR.js";
22
22
  import {
23
23
  normalizeTemporalInput
24
24
  } from "./chunk-MJSZNWCV.js";
@@ -91,4 +91,4 @@ function intlFormatDistance(laterDate, earlierDate, options) {
91
91
  export {
92
92
  intlFormatDistance
93
93
  };
94
- //# sourceMappingURL=chunk-XEDXPI5G.js.map
94
+ //# sourceMappingURL=chunk-TDQXOSO3.js.map
@@ -43,4 +43,4 @@ function simpleFormat(input, options = {}) {
43
43
  export {
44
44
  simpleFormat
45
45
  };
46
- //# sourceMappingURL=chunk-GQBO2UXH.js.map
46
+ //# sourceMappingURL=chunk-TFSZ55L7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/simpleFormat.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport type { Timezone } from './types';\n\n// simpleFormat options - discriminated by input type\ninterface PlainDateOptions {\n locale?: string;\n year?: 'auto' | 'always' | 'never';\n}\n\ninterface ZonedDateTimeOptions {\n locale?: string;\n time?: '12h' | '24h';\n timeZone?: Timezone;\n year?: 'auto' | 'always' | 'never';\n}\n\ninterface InstantOptions {\n locale?: string;\n time?: '12h' | '24h';\n timeZone: Timezone; // required for Instant\n year?: 'auto' | 'always' | 'never';\n}\n\n/**\n * Format a Temporal date in a human-friendly way: \"Dec 23\" or \"Dec 23, 2020\"\n *\n * By default (year: 'auto'), shows the year only if the date is not in the current year.\n * Use year: 'always' to always show the year, or year: 'never' to always hide it.\n * Optionally includes time in 12-hour or 24-hour format.\n *\n * @example\n * ```typescript\n * // Assuming current year is 2026\n * const date2026 = Temporal.ZonedDateTime.from(\"2026-12-23T15:30:00[America/New_York]\");\n * const date2020 = Temporal.ZonedDateTime.from(\"2020-12-23T15:30:00[America/New_York]\");\n *\n * simpleFormat(date2026); // \"Dec 23\"\n * simpleFormat(date2020); // \"Dec 23, 2020\"\n * simpleFormat(date2026, { time: '12h' }); // \"Dec 23, 3:30 PM\"\n * simpleFormat(date2026, { time: '24h' }); // \"Dec 23, 15:30\"\n *\n * // Control year display\n * simpleFormat(date2026, { year: 'always' }); // \"Dec 23, 2026\"\n * simpleFormat(date2020, { year: 'never' }); // \"Dec 23\"\n * simpleFormat(date2020, { year: 'auto' }); // \"Dec 23, 2020\" (default behavior)\n *\n * // With Instant (timeZone required)\n * const instant = Temporal.Instant.from(\"2026-12-23T20:30:00Z\");\n * simpleFormat(instant, { timeZone: 'America/New_York' }); // \"Dec 23\"\n * simpleFormat(instant, { timeZone: 'America/New_York', time: '12h' }); // \"Dec 23, 3:30 PM\"\n *\n * // With PlainDate (no time option)\n * const plain = Temporal.PlainDate.from(\"2020-12-23\");\n * simpleFormat(plain); // \"Dec 23, 2020\"\n * ```\n */\nexport function simpleFormat(input: Temporal.PlainDate, options?: PlainDateOptions): string;\nexport function simpleFormat(input: Temporal.ZonedDateTime, options?: ZonedDateTimeOptions): string;\nexport function simpleFormat(input: Temporal.Instant, options: InstantOptions): string;\nexport function simpleFormat(\n input: Temporal.PlainDate | Temporal.ZonedDateTime | Temporal.Instant,\n options: PlainDateOptions | ZonedDateTimeOptions | InstantOptions = {}\n): string {\n const locale = options.locale ?? 'en-US';\n const time = 'time' in options ? options.time : undefined;\n const timeZone = 'timeZone' in options ? options.timeZone : undefined;\n const yearOption = 'year' in options ? options.year : undefined;\n\n // Get year from the input (converting Instant to ZonedDateTime if needed)\n let year: number;\n let dateTimeForFormat: Temporal.PlainDate | Temporal.ZonedDateTime;\n\n if (input instanceof Temporal.Instant) {\n const tz = timeZone ?? 'UTC';\n const zoned = input.toZonedDateTimeISO(tz);\n year = zoned.year;\n dateTimeForFormat = zoned;\n } else if (input instanceof Temporal.ZonedDateTime) {\n if (timeZone) {\n const zoned = input.toInstant().toZonedDateTimeISO(timeZone);\n year = zoned.year;\n dateTimeForFormat = zoned;\n } else {\n year = input.year;\n dateTimeForFormat = input;\n }\n } else {\n year = input.year;\n dateTimeForFormat = input;\n }\n\n // Determine if year should be shown\n const currentYear = Temporal.Now.plainDateISO().year;\n const showYear =\n yearOption === 'always' ? true : yearOption === 'never' ? false : year !== currentYear;\n\n const dateOptions: Intl.DateTimeFormatOptions = {\n day: 'numeric',\n month: 'short',\n year: showYear ? 'numeric' : undefined,\n };\n\n // Add time options if requested and input supports it\n if (time && !(input instanceof Temporal.PlainDate)) {\n dateOptions.hour = 'numeric';\n dateOptions.minute = '2-digit';\n dateOptions.hour12 = time === '12h';\n }\n\n return dateTimeForFormat.toLocaleString(locale, dateOptions);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA2DlB,SAAS,aACd,OACA,UAAoE,CAAC,GAC7D;AACR,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,OAAO,UAAU,UAAU,QAAQ,OAAO;AAChD,QAAM,WAAW,cAAc,UAAU,QAAQ,WAAW;AAC5D,QAAM,aAAa,UAAU,UAAU,QAAQ,OAAO;AAGtD,MAAI;AACJ,MAAI;AAEJ,MAAI,iBAAiB,SAAS,SAAS;AACrC,UAAM,KAAK,YAAY;AACvB,UAAM,QAAQ,MAAM,mBAAmB,EAAE;AACzC,WAAO,MAAM;AACb,wBAAoB;AAAA,EACtB,WAAW,iBAAiB,SAAS,eAAe;AAClD,QAAI,UAAU;AACZ,YAAM,QAAQ,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AAC3D,aAAO,MAAM;AACb,0BAAoB;AAAA,IACtB,OAAO;AACL,aAAO,MAAM;AACb,0BAAoB;AAAA,IACtB;AAAA,EACF,OAAO;AACL,WAAO,MAAM;AACb,wBAAoB;AAAA,EACtB;AAGA,QAAM,cAAc,SAAS,IAAI,aAAa,EAAE;AAChD,QAAM,WACJ,eAAe,WAAW,OAAO,eAAe,UAAU,QAAQ,SAAS;AAE7E,QAAM,cAA0C;AAAA,IAC9C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM,WAAW,YAAY;AAAA,EAC/B;AAGA,MAAI,QAAQ,EAAE,iBAAiB,SAAS,YAAY;AAClD,gBAAY,OAAO;AACnB,gBAAY,SAAS;AACrB,gBAAY,SAAS,SAAS;AAAA,EAChC;AAEA,SAAO,kBAAkB,eAAe,QAAQ,WAAW;AAC7D;","names":[]}
@@ -330,4 +330,4 @@ function getTimezoneOffset(zonedDateTime) {
330
330
  export {
331
331
  format
332
332
  };
333
- //# sourceMappingURL=chunk-2G5RJGPR.js.map
333
+ //# sourceMappingURL=chunk-ZC6KWXCW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/format.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\nimport type { Timezone } from './types';\n\nexport interface FormatOptions {\n locale?: string;\n timeZone?: Timezone;\n}\n\n/**\n * Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.\n * Uses Intl.DateTimeFormat under the hood via Temporal's toLocaleString() for zero dependencies.\n *\n * @param input - A Temporal.Instant or Temporal.ZonedDateTime to format\n * @param formatStr - Format string using date-fns tokens (e.g., \"yyyy-MM-dd HH:mm:ss\")\n * @param options - Optional configuration for locale and timezone\n * @returns Formatted date string\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * format(zoned, \"yyyy-MM-dd\"); // \"2025-01-20\"\n * format(zoned, \"MMMM d, yyyy\"); // \"January 20, 2025\"\n * format(zoned, \"h:mm a\"); // \"3:00 PM\"\n * format(zoned, \"EEEE, MMMM do, yyyy 'at' h:mm a\"); // \"Monday, January 20th, 2025 at 3:00 PM\"\n *\n * // With locale\n * format(zoned, \"MMMM d, yyyy\", { locale: \"es-ES\" }); // \"enero 20, 2025\"\n * ```\n */\nexport function format(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n formatStr: string,\n options: FormatOptions = {}\n): string {\n const { locale = 'en-US', timeZone } = options;\n\n // Convert to ZonedDateTime, applying custom timezone if provided\n let zonedDateTime: Temporal.ZonedDateTime;\n if (timeZone) {\n // If custom timezone specified, convert via Instant\n const instant = input instanceof Temporal.Instant ? input : input.toInstant();\n zonedDateTime = instant.toZonedDateTimeISO(timeZone);\n } else {\n // No custom timezone: normalize to ZonedDateTime (Instant -> UTC, ZonedDateTime -> keep as-is)\n zonedDateTime = normalizeTemporalInput(input);\n }\n\n let result = '';\n let i = 0;\n const len = formatStr.length;\n\n while (i < len) {\n const char = formatStr[i];\n if (!char) break;\n\n // Handle escaped text\n if (char === \"'\") {\n // Check for double single quote (not inside a string, just '')\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n continue;\n }\n // Find closing quote, handling '' inside the string\n i++;\n while (i < len) {\n if (formatStr[i] === \"'\") {\n // Check if it's a doubled quote ''\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n } else {\n // End of quoted string\n i++;\n break;\n }\n } else {\n result += formatStr[i];\n i++;\n }\n }\n continue;\n }\n\n // Check for tokens by looking ahead\n const token = consumeToken(formatStr, i, char);\n if (token !== null) {\n result += formatToken(token, zonedDateTime, locale);\n i += token.length;\n } else {\n result += char;\n i++;\n }\n }\n\n return result;\n}\n\nfunction consumeToken(formatStr: string, start: number, char: string): string | null {\n // Special case for 'Mo' and 'do' - these end with 'o'\n if (char === 'M' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'Mo';\n }\n if (char === 'd' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'do';\n }\n\n // Count how many consecutive identical characters\n let end = start;\n while (end < formatStr.length && formatStr[end] === char) {\n end++;\n }\n const count = end - start;\n\n // Check if this is a valid token pattern\n const validTokens = [\n 'GGGGG',\n 'GGGG',\n 'GGG',\n 'GG',\n 'G',\n 'yyyy',\n 'yyy',\n 'yy',\n 'y',\n 'QQQQQ',\n 'QQQQ',\n 'QQQ',\n 'QQ',\n 'Q',\n 'MMMMM',\n 'MMMM',\n 'MMM',\n 'MM',\n 'M',\n 'dd',\n 'd',\n 'EEEEEE',\n 'EEEEE',\n 'EEEE',\n 'EEE',\n 'EE',\n 'E',\n 'aaaaa',\n 'aaaa',\n 'aaa',\n 'aa',\n 'a',\n 'HH',\n 'H',\n 'hh',\n 'h',\n 'mm',\n 'm',\n 'ss',\n 's',\n 'SSS',\n 'SS',\n 'S',\n 'XXXXX',\n 'XXXX',\n 'XXX',\n 'XX',\n 'X',\n 'xxxxx',\n 'xxxx',\n 'xxx',\n 'xx',\n 'x',\n 'zzzz',\n 'zzz',\n 'zz',\n 'z',\n 'T',\n 't',\n ];\n\n // Try to match from longest to shortest\n for (let len = Math.min(count, 6); len > 0; len--) {\n const candidate = char.repeat(len);\n if (validTokens.includes(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nfunction formatToken(token: string, zonedDateTime: Temporal.ZonedDateTime, locale: string): string {\n switch (token) {\n // Era\n case 'GGGGG':\n return formatPart(zonedDateTime, 'era', 'narrow', locale);\n case 'GGGG':\n return formatPart(zonedDateTime, 'era', 'long', locale);\n case 'GGG':\n case 'GG':\n case 'G':\n return formatPart(zonedDateTime, 'era', 'short', locale);\n\n // Year\n case 'yyyy':\n return zonedDateTime.year.toString().padStart(4, '0');\n case 'yyy':\n return zonedDateTime.year.toString().padStart(3, '0');\n case 'yy':\n return (zonedDateTime.year % 100).toString().padStart(2, '0');\n case 'y':\n return zonedDateTime.year.toString();\n\n // Quarter\n case 'QQQQQ':\n return Math.ceil(zonedDateTime.month / 3).toString();\n case 'QQQQ': {\n const quarter = Math.ceil(zonedDateTime.month / 3);\n return `${quarter}${getOrdinalSuffix(quarter)} quarter`;\n }\n case 'QQQ':\n return `Q${Math.ceil(zonedDateTime.month / 3)}`;\n case 'QQ':\n return Math.ceil(zonedDateTime.month / 3)\n .toString()\n .padStart(2, '0');\n case 'Q':\n return Math.ceil(zonedDateTime.month / 3).toString();\n\n // Month\n case 'MMMMM':\n return formatPart(zonedDateTime, 'month', 'narrow', locale);\n case 'MMMM':\n return formatPart(zonedDateTime, 'month', 'long', locale);\n case 'MMM':\n return formatPart(zonedDateTime, 'month', 'short', locale);\n case 'MM':\n return zonedDateTime.month.toString().padStart(2, '0');\n case 'Mo':\n return `${zonedDateTime.month}${getOrdinalSuffix(zonedDateTime.month)}`;\n case 'M':\n return zonedDateTime.month.toString();\n\n // Day of month\n case 'do':\n return `${zonedDateTime.day}${getOrdinalSuffix(zonedDateTime.day)}`;\n case 'dd':\n return zonedDateTime.day.toString().padStart(2, '0');\n case 'd':\n return zonedDateTime.day.toString();\n\n // Day of week\n case 'EEEEEE':\n return formatPart(zonedDateTime, 'weekday', 'short', locale).slice(0, 2);\n case 'EEEEE':\n return formatPart(zonedDateTime, 'weekday', 'narrow', locale);\n case 'EEEE':\n return formatPart(zonedDateTime, 'weekday', 'long', locale);\n case 'EEE':\n case 'EE':\n case 'E':\n return formatPart(zonedDateTime, 'weekday', 'short', locale);\n\n // AM/PM\n case 'aaaaa': {\n const period = formatPart(zonedDateTime, 'dayPeriod', 'narrow', locale).toLowerCase();\n return period.charAt(0);\n }\n case 'aaaa': {\n const period = formatPart(zonedDateTime, 'dayPeriod', 'short', locale);\n return period === 'AM' ? 'a.m.' : 'p.m.';\n }\n case 'aaa':\n return formatPart(zonedDateTime, 'dayPeriod', 'short', locale).toLowerCase();\n case 'aa':\n case 'a':\n return formatPart(zonedDateTime, 'dayPeriod', 'short', locale);\n\n // Hour [0-23]\n case 'HH':\n return zonedDateTime.hour.toString().padStart(2, '0');\n case 'H':\n return zonedDateTime.hour.toString();\n\n // Hour [1-12]\n case 'hh': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString().padStart(2, '0');\n }\n case 'h': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString();\n }\n\n // Minute\n case 'mm':\n return zonedDateTime.minute.toString().padStart(2, '0');\n case 'm':\n return zonedDateTime.minute.toString();\n\n // Second\n case 'ss':\n return zonedDateTime.second.toString().padStart(2, '0');\n case 's':\n return zonedDateTime.second.toString();\n\n // Fractional seconds\n case 'SSS':\n return zonedDateTime.millisecond.toString().padStart(3, '0');\n case 'SS':\n return Math.floor(zonedDateTime.millisecond / 10)\n .toString()\n .padStart(2, '0');\n case 'S':\n return Math.floor(zonedDateTime.millisecond / 100).toString();\n\n // Timezone\n case 'XXXXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XXXX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'XXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'X': {\n const offset = getTimezoneOffset(zonedDateTime);\n if (offset === '+00:00') return 'Z';\n const [hours] = offset.split(':');\n return hours || '+00';\n }\n case 'xxxxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xxxx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'xxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'x': {\n const offset = getTimezoneOffset(zonedDateTime);\n const [hours] = offset.split(':');\n return hours || '+00';\n }\n case 'zzzz':\n return formatPart(zonedDateTime, 'timeZoneName', 'long', locale);\n case 'zzz':\n case 'zz':\n case 'z':\n return formatPart(zonedDateTime, 'timeZoneName', 'short', locale);\n\n // Timestamps\n case 'T':\n return zonedDateTime.epochMilliseconds.toString();\n case 't':\n return Math.floor(zonedDateTime.epochMilliseconds / 1000).toString();\n\n default:\n return token;\n }\n}\n\nfunction formatPart(\n zonedDateTime: Temporal.ZonedDateTime,\n part: 'era' | 'year' | 'month' | 'weekday' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'timeZoneName',\n style: 'narrow' | 'short' | 'long' | 'numeric' | '2-digit',\n locale: string\n): string {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (part === 'dayPeriod') {\n // dayPeriod needs hour to be present\n options.hour = 'numeric';\n options.hour12 = true;\n } else {\n options[part] = style as any;\n }\n\n const formatted = zonedDateTime.toLocaleString(locale, options);\n\n if (part === 'dayPeriod') {\n // Extract just the AM/PM part\n const match = formatted.match(/\\b(AM|PM|am|pm|a\\.m\\.|p\\.m\\.)\\b/);\n return match ? match[0] : formatted.split(' ').pop() || '';\n }\n\n return formatted;\n}\n\nfunction getOrdinalSuffix(num: number): string {\n const j = num % 10;\n const k = num % 100;\n if (j === 1 && k !== 11) return 'st';\n if (j === 2 && k !== 12) return 'nd';\n if (j === 3 && k !== 13) return 'rd';\n return 'th';\n}\n\nfunction getTimezoneOffset(zonedDateTime: Temporal.ZonedDateTime): string {\n const offsetNs = zonedDateTime.offsetNanoseconds;\n const offsetMinutes = offsetNs / (60 * 1e9);\n const sign = offsetMinutes >= 0 ? '+' : '-';\n const absMinutes = Math.abs(offsetMinutes);\n const hours = Math.floor(absMinutes / 60);\n const minutes = absMinutes % 60;\n return `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n}\n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K;AACvC,QAAM,OAAO,iBAAiB,IAAI,MAAM;AACxC,QAAM,aAAa,KAAK,IAAI,aAAa;AACzC,QAAM,QAAQ,KAAK,MAAM,aAAa,EAAE;AACxC,QAAM,UAAU,aAAa;AAC7B,SAAO,GAAG,IAAI,GAAG,MAAM,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,QAAQ,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAC3F;","names":[]}
package/dist/format.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Temporal } from '@js-temporal/polyfill';
2
+ import type { Timezone } from './types';
2
3
  export interface FormatOptions {
3
4
  locale?: string;
4
- timeZone?: string;
5
+ timeZone?: Timezone;
5
6
  }
6
7
  /**
7
8
  * Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChD,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CA+DR"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChD,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,GAC1B,MAAM,CA+DR"}
package/dist/format.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  format
3
- } from "./chunk-2G5RJGPR.js";
3
+ } from "./chunk-ZC6KWXCW.js";
4
4
  import "./chunk-MJSZNWCV.js";
5
5
  export {
6
6
  format
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { toZonedTime } from './toZonedTime';
2
+ export type { Timezone, IANATimezone } from './types';
3
+ export { browserTimezone } from './browserTimezone';
2
4
  export { toUtc } from './toUtc';
3
5
  export { toIso, type IsoMode, type ToIsoOptions } from './toIso';
4
6
  export { toIso9075, type ToIso9075Options, type Iso9075Representation, type Iso9075Mode, } from './toIso9075';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CA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CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ toIso
3
+ } from "./chunk-BSV32PSO.js";
1
4
  import {
2
5
  toIso9075
3
6
  } from "./chunk-DFLGGK4F.js";
@@ -6,10 +9,13 @@ import {
6
9
  } from "./chunk-BW5SFCKS.js";
7
10
  import {
8
11
  toZonedTime
9
- } from "./chunk-2MP3ESL7.js";
12
+ } from "./chunk-MXQFENCR.js";
10
13
  import {
11
14
  today
12
- } from "./chunk-67QHALIG.js";
15
+ } from "./chunk-KZB6NERH.js";
16
+ import {
17
+ subMinutes
18
+ } from "./chunk-J6G2I2TU.js";
13
19
  import {
14
20
  subMonths
15
21
  } from "./chunk-52NEOY34.js";
@@ -29,8 +35,8 @@ import {
29
35
  toDate
30
36
  } from "./chunk-TGKWBQ7L.js";
31
37
  import {
32
- toIso
33
- } from "./chunk-BSV32PSO.js";
38
+ startOfDay
39
+ } from "./chunk-TW5EV3DH.js";
34
40
  import {
35
41
  startOfMonth
36
42
  } from "./chunk-TU2UNOOW.js";
@@ -53,8 +59,8 @@ import {
53
59
  subMilliseconds
54
60
  } from "./chunk-HDBH7RTY.js";
55
61
  import {
56
- subMinutes
57
- } from "./chunk-J6G2I2TU.js";
62
+ isSameMinute
63
+ } from "./chunk-LDO6PRNJ.js";
58
64
  import {
59
65
  isSameMonth
60
66
  } from "./chunk-ADQTZVMH.js";
@@ -72,13 +78,13 @@ import {
72
78
  } from "./chunk-VLZ3HQQA.js";
73
79
  import {
74
80
  now
75
- } from "./chunk-3YGPHHB6.js";
81
+ } from "./chunk-FSD3DDFC.js";
76
82
  import {
77
83
  simpleFormat
78
- } from "./chunk-GQBO2UXH.js";
84
+ } from "./chunk-TFSZ55L7.js";
79
85
  import {
80
- startOfDay
81
- } from "./chunk-TW5EV3DH.js";
86
+ isPast
87
+ } from "./chunk-2H4KLXGL.js";
82
88
  import {
83
89
  isPlainDateAfter
84
90
  } from "./chunk-BPZ7BRJW.js";
@@ -101,17 +107,17 @@ import {
101
107
  isSameMillisecond
102
108
  } from "./chunk-ISHZRFVN.js";
103
109
  import {
104
- isSameMinute
105
- } from "./chunk-LDO6PRNJ.js";
110
+ endOfYear
111
+ } from "./chunk-XDVUGTUV.js";
106
112
  import {
107
113
  format
108
- } from "./chunk-2G5RJGPR.js";
114
+ } from "./chunk-ZC6KWXCW.js";
109
115
  import {
110
116
  formatPlainDate
111
117
  } from "./chunk-3A6X6WV5.js";
112
118
  import {
113
119
  intlFormatDistance
114
- } from "./chunk-XEDXPI5G.js";
120
+ } from "./chunk-TDQXOSO3.js";
115
121
  import {
116
122
  isAfter
117
123
  } from "./chunk-BBNNR2QH.js";
@@ -122,8 +128,8 @@ import {
122
128
  isFuture
123
129
  } from "./chunk-R5XN76EV.js";
124
130
  import {
125
- isPast
126
- } from "./chunk-2H4KLXGL.js";
131
+ differenceInMonths
132
+ } from "./chunk-BIAPE4MR.js";
127
133
  import {
128
134
  differenceInNanoseconds
129
135
  } from "./chunk-OABS374T.js";
@@ -145,9 +151,6 @@ import {
145
151
  import {
146
152
  endOfWeek
147
153
  } from "./chunk-XVJJR7H6.js";
148
- import {
149
- endOfYear
150
- } from "./chunk-XDVUGTUV.js";
151
154
  import "./chunk-AVGNRINZ.js";
152
155
  import {
153
156
  addWeeks
@@ -155,6 +158,9 @@ import {
155
158
  import {
156
159
  addYears
157
160
  } from "./chunk-Q2F3HEXB.js";
161
+ import {
162
+ browserTimezone
163
+ } from "./chunk-JGQPEN2G.js";
158
164
  import {
159
165
  differenceInDays
160
166
  } from "./chunk-6IP245MS.js";
@@ -170,9 +176,6 @@ import {
170
176
  import {
171
177
  differenceInMinutes
172
178
  } from "./chunk-RJY62CDU.js";
173
- import {
174
- differenceInMonths
175
- } from "./chunk-BIAPE4MR.js";
176
179
  import {
177
180
  addDays
178
181
  } from "./chunk-L4SVABDH.js";
@@ -209,6 +212,7 @@ export {
209
212
  addSeconds,
210
213
  addWeeks,
211
214
  addYears,
215
+ browserTimezone,
212
216
  differenceInDays,
213
217
  differenceInHours,
214
218
  differenceInMicroseconds,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  intlFormatDistance
3
- } from "./chunk-XEDXPI5G.js";
3
+ } from "./chunk-TDQXOSO3.js";
4
+ import "./chunk-BIAPE4MR.js";
4
5
  import "./chunk-ZHRMURYP.js";
5
6
  import "./chunk-PVAOUYXF.js";
6
7
  import "./chunk-CHW2EN2O.js";
7
8
  import "./chunk-6IP245MS.js";
8
9
  import "./chunk-PIDXROVB.js";
9
10
  import "./chunk-RJY62CDU.js";
10
- import "./chunk-BIAPE4MR.js";
11
11
  import "./chunk-MJSZNWCV.js";
12
12
  export {
13
13
  intlFormatDistance
package/dist/now.d.ts CHANGED
@@ -1,21 +1,27 @@
1
1
  import { Temporal } from '@js-temporal/polyfill';
2
+ import type { Timezone } from './types';
2
3
  /**
3
- * Get the current date and time in the system's local timezone or a specified timezone.
4
+ * Get the current date and time in the specified timezone.
4
5
  *
5
- * @param timezone - Optional IANA timezone identifier (e.g., "America/Asuncion", "Europe/Madrid") or "UTC"
6
+ * @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London") or "UTC"
6
7
  * @returns A Temporal.ZonedDateTime representing the current date and time
7
8
  *
8
9
  * @example
9
10
  * ```typescript
10
- * // Get now in local timezone
11
- * const current = now();
11
+ * import { now, browserTimezone } from '@gobrand/tiempo';
12
12
  *
13
- * // Get now in Madrid
14
- * const nowInMadrid = now("Europe/Madrid");
15
- *
16
- * // Get now in UTC
13
+ * // Server-side: Get now in UTC
17
14
  * const nowUtc = now("UTC");
15
+ *
16
+ * // Server-side: Get now in user's timezone (from DB/preferences)
17
+ * const nowUser = now(user.timezone);
18
+ *
19
+ * // Client-side: Get now in browser's timezone
20
+ * const nowLocal = now(browserTimezone());
21
+ *
22
+ * // Get now in a specific timezone
23
+ * const nowInMadrid = now("Europe/Madrid");
18
24
  * ```
19
25
  */
20
- export declare function now(timezone?: 'UTC' | string): Temporal.ZonedDateTime;
26
+ export declare function now(timezone: Timezone): Temporal.ZonedDateTime;
21
27
  //# sourceMappingURL=now.d.ts.map
package/dist/now.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"now.d.ts","sourceRoot":"","sources":["../src/now.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC,aAAa,CAKrE"}
1
+ {"version":3,"file":"now.d.ts","sourceRoot":"","sources":["../src/now.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAE9D"}
package/dist/now.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  now
3
- } from "./chunk-3YGPHHB6.js";
3
+ } from "./chunk-FSD3DDFC.js";
4
4
  export {
5
5
  now
6
6
  };
@@ -1,4 +1,5 @@
1
1
  import { Temporal } from '@js-temporal/polyfill';
2
+ import type { Timezone } from './types';
2
3
  interface PlainDateOptions {
3
4
  locale?: string;
4
5
  year?: 'auto' | 'always' | 'never';
@@ -6,13 +7,13 @@ interface PlainDateOptions {
6
7
  interface ZonedDateTimeOptions {
7
8
  locale?: string;
8
9
  time?: '12h' | '24h';
9
- timeZone?: string;
10
+ timeZone?: Timezone;
10
11
  year?: 'auto' | 'always' | 'never';
11
12
  }
12
13
  interface InstantOptions {
13
14
  locale?: string;
14
15
  time?: '12h' | '24h';
15
- timeZone: string;
16
+ timeZone: Timezone;
16
17
  year?: 'auto' | 'always' | 'never';
17
18
  }
18
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"simpleFormat.d.ts","sourceRoot":"","sources":["../src/simpleFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;AAC5F,wBAAgB,YAAY,CAA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AAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  simpleFormat
3
- } from "./chunk-GQBO2UXH.js";
3
+ } from "./chunk-TFSZ55L7.js";
4
4
  export {
5
5
  simpleFormat
6
6
  };
@@ -1,29 +1,37 @@
1
1
  import { Temporal } from '@js-temporal/polyfill';
2
+ import type { Timezone } from './types';
2
3
  /**
3
4
  * Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.
4
5
  *
5
6
  * @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime
6
- * @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London")
7
+ * @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London") or "UTC"
7
8
  * @returns A Temporal.ZonedDateTime in the specified timezone
8
9
  *
9
10
  * @example
10
11
  * ```typescript
11
- * // From ISO string
12
- * const zoned = toZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
13
- * // zoned.hour === 15 (3 PM in New York)
12
+ * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';
13
+ *
14
+ * // Server-side: Convert to UTC
15
+ * const utcTime = toZonedTime("2025-01-20T20:00:00Z", "UTC");
16
+ *
17
+ * // Server-side: Convert to user's timezone (from DB/preferences)
18
+ * const userTime = toZonedTime("2025-01-20T20:00:00Z", user.timezone);
19
+ *
20
+ * // Client-side: Convert to browser's timezone
21
+ * const localTime = toZonedTime("2025-01-20T20:00:00Z", browserTimezone());
14
22
  *
15
23
  * // From Date (e.g., from Drizzle ORM)
16
24
  * const date = new Date("2025-01-20T20:00:00.000Z");
17
- * const zoned2 = toZonedTime(date, "America/New_York");
25
+ * const zoned = toZonedTime(date, "America/New_York");
18
26
  *
19
27
  * // From Instant
20
28
  * const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
21
- * const zoned3 = toZonedTime(instant, "Asia/Tokyo");
29
+ * const zoned = toZonedTime(instant, "Asia/Tokyo");
22
30
  *
23
31
  * // From ZonedDateTime (convert to different timezone)
24
32
  * const nyTime = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
25
33
  * const tokyoTime = toZonedTime(nyTime, "Asia/Tokyo");
26
34
  * ```
27
35
  */
28
- export declare function toZonedTime(input: string | Date | Temporal.Instant | Temporal.ZonedDateTime, timezone: string): Temporal.ZonedDateTime;
36
+ export declare function toZonedTime(input: string | Date | Temporal.Instant | Temporal.ZonedDateTime, timezone: Timezone): Temporal.ZonedDateTime;
29
37
  //# sourceMappingURL=toZonedTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toZonedTime.d.ts","sourceRoot":"","sources":["../src/toZonedTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChE,QAAQ,EAAE,MAAM,GACf,QAAQ,CAAC,aAAa,CAcxB"}
1
+ {"version":3,"file":"toZonedTime.d.ts","sourceRoot":"","sources":["../src/toZonedTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChE,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAAC,aAAa,CAcxB"}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toZonedTime
3
- } from "./chunk-2MP3ESL7.js";
3
+ } from "./chunk-MXQFENCR.js";
4
4
  export {
5
5
  toZonedTime
6
6
  };
package/dist/today.d.ts CHANGED
@@ -1,21 +1,27 @@
1
1
  import { Temporal } from '@js-temporal/polyfill';
2
+ import type { Timezone } from './types';
2
3
  /**
3
- * Get today's date in the system's local timezone or a specified timezone.
4
+ * Get today's date in the specified timezone.
4
5
  *
5
- * @param timezone - Optional IANA timezone identifier (e.g., "America/Asuncion", "Europe/Madrid") or "UTC"
6
+ * @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London") or "UTC"
6
7
  * @returns A Temporal.PlainDate representing today's date
7
8
  *
8
9
  * @example
9
10
  * ```typescript
10
- * // Get today in local timezone
11
- * const date = today();
11
+ * import { today, browserTimezone } from '@gobrand/tiempo';
12
12
  *
13
- * // Get today in Madrid
14
- * const todayInMadrid = today("Europe/Madrid");
15
- *
16
- * // Get today in UTC
13
+ * // Server-side: Get today in UTC
17
14
  * const todayUtc = today("UTC");
15
+ *
16
+ * // Server-side: Get today in user's timezone (from DB/preferences)
17
+ * const todayUser = today(user.timezone);
18
+ *
19
+ * // Client-side: Get today in browser's timezone
20
+ * const todayLocal = today(browserTimezone());
21
+ *
22
+ * // Get today in a specific timezone
23
+ * const todayInMadrid = today("Europe/Madrid");
18
24
  * ```
19
25
  */
20
- export declare function today(timezone?: "UTC" | string): Temporal.PlainDate;
26
+ export declare function today(timezone: Timezone): Temporal.PlainDate;
21
27
  //# sourceMappingURL=today.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"today.d.ts","sourceRoot":"","sources":["../src/today.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC,SAAS,CAKnE"}
1
+ {"version":3,"file":"today.d.ts","sourceRoot":"","sources":["../src/today.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAE5D"}
package/dist/today.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  today
3
- } from "./chunk-67QHALIG.js";
3
+ } from "./chunk-KZB6NERH.js";
4
4
  export {
5
5
  today
6
6
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auto-generated IANA timezone identifiers.
3
+ *
4
+ * Generated from Intl.supportedValuesOf('timeZone')
5
+ * Total: 418 timezones
6
+ *
7
+ * To regenerate: pnpm generate:timezones
8
+ *
9
+ * @see https://www.iana.org/time-zones
10
+ */
11
+ export type IANATimezone = 'Africa/Abidjan' | 'Africa/Accra' | 'Africa/Addis_Ababa' | 'Africa/Algiers' | 'Africa/Asmera' | 'Africa/Bamako' | 'Africa/Bangui' | 'Africa/Banjul' | 'Africa/Bissau' | 'Africa/Blantyre' | 'Africa/Brazzaville' | 'Africa/Bujumbura' | 'Africa/Cairo' | 'Africa/Casablanca' | 'Africa/Ceuta' | 'Africa/Conakry' | 'Africa/Dakar' | 'Africa/Dar_es_Salaam' | 'Africa/Djibouti' | 'Africa/Douala' | 'Africa/El_Aaiun' | 'Africa/Freetown' | 'Africa/Gaborone' | 'Africa/Harare' | 'Africa/Johannesburg' | 'Africa/Juba' | 'Africa/Kampala' | 'Africa/Khartoum' | 'Africa/Kigali' | 'Africa/Kinshasa' | 'Africa/Lagos' | 'Africa/Libreville' | 'Africa/Lome' | 'Africa/Luanda' | 'Africa/Lubumbashi' | 'Africa/Lusaka' | 'Africa/Malabo' | 'Africa/Maputo' | 'Africa/Maseru' | 'Africa/Mbabane' | 'Africa/Mogadishu' | 'Africa/Monrovia' | 'Africa/Nairobi' | 'Africa/Ndjamena' | 'Africa/Niamey' | 'Africa/Nouakchott' | 'Africa/Ouagadougou' | 'Africa/Porto-Novo' | 'Africa/Sao_Tome' | 'Africa/Tripoli' | 'Africa/Tunis' | 'Africa/Windhoek' | 'America/Adak' | 'America/Anchorage' | 'America/Anguilla' | 'America/Antigua' | 'America/Araguaina' | 'America/Argentina/La_Rioja' | 'America/Argentina/Rio_Gallegos' | 'America/Argentina/Salta' | 'America/Argentina/San_Juan' | 'America/Argentina/San_Luis' | 'America/Argentina/Tucuman' | 'America/Argentina/Ushuaia' | 'America/Aruba' | 'America/Asuncion' | 'America/Bahia' | 'America/Bahia_Banderas' | 'America/Barbados' | 'America/Belem' | 'America/Belize' | 'America/Blanc-Sablon' | 'America/Boa_Vista' | 'America/Bogota' | 'America/Boise' | 'America/Buenos_Aires' | 'America/Cambridge_Bay' | 'America/Campo_Grande' | 'America/Cancun' | 'America/Caracas' | 'America/Catamarca' | 'America/Cayenne' | 'America/Cayman' | 'America/Chicago' | 'America/Chihuahua' | 'America/Ciudad_Juarez' | 'America/Coral_Harbour' | 'America/Cordoba' | 'America/Costa_Rica' | 'America/Coyhaique' | 'America/Creston' | 'America/Cuiaba' | 'America/Curacao' | 'America/Danmarkshavn' | 'America/Dawson' | 'America/Dawson_Creek' | 'America/Denver' | 'America/Detroit' | 'America/Dominica' | 'America/Edmonton' | 'America/Eirunepe' | 'America/El_Salvador' | 'America/Fort_Nelson' | 'America/Fortaleza' | 'America/Glace_Bay' | 'America/Godthab' | 'America/Goose_Bay' | 'America/Grand_Turk' | 'America/Grenada' | 'America/Guadeloupe' | 'America/Guatemala' | 'America/Guayaquil' | 'America/Guyana' | 'America/Halifax' | 'America/Havana' | 'America/Hermosillo' | 'America/Indiana/Knox' | 'America/Indiana/Marengo' | 'America/Indiana/Petersburg' | 'America/Indiana/Tell_City' | 'America/Indiana/Vevay' | 'America/Indiana/Vincennes' | 'America/Indiana/Winamac' | 'America/Indianapolis' | 'America/Inuvik' | 'America/Iqaluit' | 'America/Jamaica' | 'America/Jujuy' | 'America/Juneau' | 'America/Kentucky/Monticello' | 'America/Kralendijk' | 'America/La_Paz' | 'America/Lima' | 'America/Los_Angeles' | 'America/Louisville' | 'America/Lower_Princes' | 'America/Maceio' | 'America/Managua' | 'America/Manaus' | 'America/Marigot' | 'America/Martinique' | 'America/Matamoros' | 'America/Mazatlan' | 'America/Mendoza' | 'America/Menominee' | 'America/Merida' | 'America/Metlakatla' | 'America/Mexico_City' | 'America/Miquelon' | 'America/Moncton' | 'America/Monterrey' | 'America/Montevideo' | 'America/Montserrat' | 'America/Nassau' | 'America/New_York' | 'America/Nome' | 'America/Noronha' | 'America/North_Dakota/Beulah' | 'America/North_Dakota/Center' | 'America/North_Dakota/New_Salem' | 'America/Ojinaga' | 'America/Panama' | 'America/Paramaribo' | 'America/Phoenix' | 'America/Port-au-Prince' | 'America/Port_of_Spain' | 'America/Porto_Velho' | 'America/Puerto_Rico' | 'America/Punta_Arenas' | 'America/Rankin_Inlet' | 'America/Recife' | 'America/Regina' | 'America/Resolute' | 'America/Rio_Branco' | 'America/Santarem' | 'America/Santiago' | 'America/Santo_Domingo' | 'America/Sao_Paulo' | 'America/Scoresbysund' | 'America/Sitka' | 'America/St_Barthelemy' | 'America/St_Johns' | 'America/St_Kitts' | 'America/St_Lucia' | 'America/St_Thomas' | 'America/St_Vincent' | 'America/Swift_Current' | 'America/Tegucigalpa' | 'America/Thule' | 'America/Tijuana' | 'America/Toronto' | 'America/Tortola' | 'America/Vancouver' | 'America/Whitehorse' | 'America/Winnipeg' | 'America/Yakutat' | 'Antarctica/Casey' | 'Antarctica/Davis' | 'Antarctica/DumontDUrville' | 'Antarctica/Macquarie' | 'Antarctica/Mawson' | 'Antarctica/McMurdo' | 'Antarctica/Palmer' | 'Antarctica/Rothera' | 'Antarctica/Syowa' | 'Antarctica/Troll' | 'Antarctica/Vostok' | 'Arctic/Longyearbyen' | 'Asia/Aden' | 'Asia/Almaty' | 'Asia/Amman' | 'Asia/Anadyr' | 'Asia/Aqtau' | 'Asia/Aqtobe' | 'Asia/Ashgabat' | 'Asia/Atyrau' | 'Asia/Baghdad' | 'Asia/Bahrain' | 'Asia/Baku' | 'Asia/Bangkok' | 'Asia/Barnaul' | 'Asia/Beirut' | 'Asia/Bishkek' | 'Asia/Brunei' | 'Asia/Calcutta' | 'Asia/Chita' | 'Asia/Colombo' | 'Asia/Damascus' | 'Asia/Dhaka' | 'Asia/Dili' | 'Asia/Dubai' | 'Asia/Dushanbe' | 'Asia/Famagusta' | 'Asia/Gaza' | 'Asia/Hebron' | 'Asia/Hong_Kong' | 'Asia/Hovd' | 'Asia/Irkutsk' | 'Asia/Jakarta' | 'Asia/Jayapura' | 'Asia/Jerusalem' | 'Asia/Kabul' | 'Asia/Kamchatka' | 'Asia/Karachi' | 'Asia/Katmandu' | 'Asia/Khandyga' | 'Asia/Krasnoyarsk' | 'Asia/Kuala_Lumpur' | 'Asia/Kuching' | 'Asia/Kuwait' | 'Asia/Macau' | 'Asia/Magadan' | 'Asia/Makassar' | 'Asia/Manila' | 'Asia/Muscat' | 'Asia/Nicosia' | 'Asia/Novokuznetsk' | 'Asia/Novosibirsk' | 'Asia/Omsk' | 'Asia/Oral' | 'Asia/Phnom_Penh' | 'Asia/Pontianak' | 'Asia/Pyongyang' | 'Asia/Qatar' | 'Asia/Qostanay' | 'Asia/Qyzylorda' | 'Asia/Rangoon' | 'Asia/Riyadh' | 'Asia/Saigon' | 'Asia/Sakhalin' | 'Asia/Samarkand' | 'Asia/Seoul' | 'Asia/Shanghai' | 'Asia/Singapore' | 'Asia/Srednekolymsk' | 'Asia/Taipei' | 'Asia/Tashkent' | 'Asia/Tbilisi' | 'Asia/Tehran' | 'Asia/Thimphu' | 'Asia/Tokyo' | 'Asia/Tomsk' | 'Asia/Ulaanbaatar' | 'Asia/Urumqi' | 'Asia/Ust-Nera' | 'Asia/Vientiane' | 'Asia/Vladivostok' | 'Asia/Yakutsk' | 'Asia/Yekaterinburg' | 'Asia/Yerevan' | 'Atlantic/Azores' | 'Atlantic/Bermuda' | 'Atlantic/Canary' | 'Atlantic/Cape_Verde' | 'Atlantic/Faeroe' | 'Atlantic/Madeira' | 'Atlantic/Reykjavik' | 'Atlantic/South_Georgia' | 'Atlantic/St_Helena' | 'Atlantic/Stanley' | 'Australia/Adelaide' | 'Australia/Brisbane' | 'Australia/Broken_Hill' | 'Australia/Darwin' | 'Australia/Eucla' | 'Australia/Hobart' | 'Australia/Lindeman' | 'Australia/Lord_Howe' | 'Australia/Melbourne' | 'Australia/Perth' | 'Australia/Sydney' | 'Europe/Amsterdam' | 'Europe/Andorra' | 'Europe/Astrakhan' | 'Europe/Athens' | 'Europe/Belgrade' | 'Europe/Berlin' | 'Europe/Bratislava' | 'Europe/Brussels' | 'Europe/Bucharest' | 'Europe/Budapest' | 'Europe/Busingen' | 'Europe/Chisinau' | 'Europe/Copenhagen' | 'Europe/Dublin' | 'Europe/Gibraltar' | 'Europe/Guernsey' | 'Europe/Helsinki' | 'Europe/Isle_of_Man' | 'Europe/Istanbul' | 'Europe/Jersey' | 'Europe/Kaliningrad' | 'Europe/Kiev' | 'Europe/Kirov' | 'Europe/Lisbon' | 'Europe/Ljubljana' | 'Europe/London' | 'Europe/Luxembourg' | 'Europe/Madrid' | 'Europe/Malta' | 'Europe/Mariehamn' | 'Europe/Minsk' | 'Europe/Monaco' | 'Europe/Moscow' | 'Europe/Oslo' | 'Europe/Paris' | 'Europe/Podgorica' | 'Europe/Prague' | 'Europe/Riga' | 'Europe/Rome' | 'Europe/Samara' | 'Europe/San_Marino' | 'Europe/Sarajevo' | 'Europe/Saratov' | 'Europe/Simferopol' | 'Europe/Skopje' | 'Europe/Sofia' | 'Europe/Stockholm' | 'Europe/Tallinn' | 'Europe/Tirane' | 'Europe/Ulyanovsk' | 'Europe/Vaduz' | 'Europe/Vatican' | 'Europe/Vienna' | 'Europe/Vilnius' | 'Europe/Volgograd' | 'Europe/Warsaw' | 'Europe/Zagreb' | 'Europe/Zurich' | 'Indian/Antananarivo' | 'Indian/Chagos' | 'Indian/Christmas' | 'Indian/Cocos' | 'Indian/Comoro' | 'Indian/Kerguelen' | 'Indian/Mahe' | 'Indian/Maldives' | 'Indian/Mauritius' | 'Indian/Mayotte' | 'Indian/Reunion' | 'Pacific/Apia' | 'Pacific/Auckland' | 'Pacific/Bougainville' | 'Pacific/Chatham' | 'Pacific/Easter' | 'Pacific/Efate' | 'Pacific/Enderbury' | 'Pacific/Fakaofo' | 'Pacific/Fiji' | 'Pacific/Funafuti' | 'Pacific/Galapagos' | 'Pacific/Gambier' | 'Pacific/Guadalcanal' | 'Pacific/Guam' | 'Pacific/Honolulu' | 'Pacific/Kiritimati' | 'Pacific/Kosrae' | 'Pacific/Kwajalein' | 'Pacific/Majuro' | 'Pacific/Marquesas' | 'Pacific/Midway' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Norfolk' | 'Pacific/Noumea' | 'Pacific/Pago_Pago' | 'Pacific/Palau' | 'Pacific/Pitcairn' | 'Pacific/Ponape' | 'Pacific/Port_Moresby' | 'Pacific/Rarotonga' | 'Pacific/Saipan' | 'Pacific/Tahiti' | 'Pacific/Tarawa' | 'Pacific/Tongatapu' | 'Pacific/Truk' | 'Pacific/Wake' | 'Pacific/Wallis' | (string & {});
12
+ //# sourceMappingURL=iana-timezones.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iana-timezones.d.ts","sourceRoot":"","sources":["../../src/types/iana-timezones.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,eAAe,GACf,eAAe,GACf,eAAe,GACf,iBAAiB,GACjB,oBAAoB,GACpB,kBAAkB,GAClB,cAAc,GACd,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,sBAAsB,GACtB,iBAAiB,GACjB,eAAe,GACf,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB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ACjB,qBAAqB,GACrB,cAAc,GACd,kBAAkB,GAClB,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,kBAAkB,GAClB,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=iana-timezones.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,17 @@
1
+ import type { IANATimezone } from './types/iana-timezones';
2
+ /**
3
+ * Timezone identifier.
4
+ *
5
+ * Includes all IANA timezone identifiers with full autocomplete support,
6
+ * plus a string fallback for forward compatibility with new timezones.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const tz1: Timezone = 'America/New_York'; // Autocomplete works!
11
+ * const tz2: Timezone = 'Europe/London';
12
+ * const tz3: Timezone = 'UTC';
13
+ * ```
14
+ */
15
+ export type Timezone = 'UTC' | IANATimezone;
16
+ export type { IANATimezone };
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,YAAY,CAAC;AAE5C,YAAY,EAAE,YAAY,EAAE,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobrand/tiempo",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Lightweight utility functions for converting between UTC and timezone-aware datetimes using the Temporal API",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -30,7 +30,8 @@
30
30
  },
31
31
  "homepage": "https://eng.gobrand.app/tiempo",
32
32
  "scripts": {
33
- "build": "tsup && tsc --emitDeclarationOnly",
33
+ "generate:timezones": "tsx scripts/generate-timezone-types.ts",
34
+ "build": "pnpm generate:timezones && tsup && tsc --emitDeclarationOnly",
34
35
  "clean": "git clean -xdf .cache .turbo dist node_modules tsconfig.tsbuildinfo",
35
36
  "test": "vitest",
36
37
  "typecheck": "tsc --noEmit",
@@ -42,6 +43,7 @@
42
43
  "devDependencies": {
43
44
  "@types/node": "^22.10.5",
44
45
  "tsup": "^8.5.0",
46
+ "tsx": "^4.21.0",
45
47
  "typescript": "^5.9.3",
46
48
  "vitest": "^3.2.4"
47
49
  },
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/format.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\nimport { normalizeTemporalInput } from './shared/normalizeTemporalInput';\n\nexport interface FormatOptions {\n locale?: string;\n timeZone?: string;\n}\n\n/**\n * Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.\n * Uses Intl.DateTimeFormat under the hood via Temporal's toLocaleString() for zero dependencies.\n *\n * @param input - A Temporal.Instant or Temporal.ZonedDateTime to format\n * @param formatStr - Format string using date-fns tokens (e.g., \"yyyy-MM-dd HH:mm:ss\")\n * @param options - Optional configuration for locale and timezone\n * @returns Formatted date string\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * format(zoned, \"yyyy-MM-dd\"); // \"2025-01-20\"\n * format(zoned, \"MMMM d, yyyy\"); // \"January 20, 2025\"\n * format(zoned, \"h:mm a\"); // \"3:00 PM\"\n * format(zoned, \"EEEE, MMMM do, yyyy 'at' h:mm a\"); // \"Monday, January 20th, 2025 at 3:00 PM\"\n *\n * // With locale\n * format(zoned, \"MMMM d, yyyy\", { locale: \"es-ES\" }); // \"enero 20, 2025\"\n * ```\n */\nexport function format(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n formatStr: string,\n options: FormatOptions = {}\n): string {\n const { locale = 'en-US', timeZone } = options;\n\n // Convert to ZonedDateTime, applying custom timezone if provided\n let zonedDateTime: Temporal.ZonedDateTime;\n if (timeZone) {\n // If custom timezone specified, convert via Instant\n const instant = input instanceof Temporal.Instant ? input : input.toInstant();\n zonedDateTime = instant.toZonedDateTimeISO(timeZone);\n } else {\n // No custom timezone: normalize to ZonedDateTime (Instant -> UTC, ZonedDateTime -> keep as-is)\n zonedDateTime = normalizeTemporalInput(input);\n }\n\n let result = '';\n let i = 0;\n const len = formatStr.length;\n\n while (i < len) {\n const char = formatStr[i];\n if (!char) break;\n\n // Handle escaped text\n if (char === \"'\") {\n // Check for double single quote (not inside a string, just '')\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n continue;\n }\n // Find closing quote, handling '' inside the string\n i++;\n while (i < len) {\n if (formatStr[i] === \"'\") {\n // Check if it's a doubled quote ''\n if (i + 1 < len && formatStr[i + 1] === \"'\") {\n result += \"'\";\n i += 2;\n } else {\n // End of quoted string\n i++;\n break;\n }\n } else {\n result += formatStr[i];\n i++;\n }\n }\n continue;\n }\n\n // Check for tokens by looking ahead\n const token = consumeToken(formatStr, i, char);\n if (token !== null) {\n result += formatToken(token, zonedDateTime, locale);\n i += token.length;\n } else {\n result += char;\n i++;\n }\n }\n\n return result;\n}\n\nfunction consumeToken(formatStr: string, start: number, char: string): string | null {\n // Special case for 'Mo' and 'do' - these end with 'o'\n if (char === 'M' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'Mo';\n }\n if (char === 'd' && start + 1 < formatStr.length && formatStr[start + 1] === 'o') {\n return 'do';\n }\n\n // Count how many consecutive identical characters\n let end = start;\n while (end < formatStr.length && formatStr[end] === char) {\n end++;\n }\n const count = end - start;\n\n // Check if this is a valid token pattern\n const validTokens = [\n 'GGGGG',\n 'GGGG',\n 'GGG',\n 'GG',\n 'G',\n 'yyyy',\n 'yyy',\n 'yy',\n 'y',\n 'QQQQQ',\n 'QQQQ',\n 'QQQ',\n 'QQ',\n 'Q',\n 'MMMMM',\n 'MMMM',\n 'MMM',\n 'MM',\n 'M',\n 'dd',\n 'd',\n 'EEEEEE',\n 'EEEEE',\n 'EEEE',\n 'EEE',\n 'EE',\n 'E',\n 'aaaaa',\n 'aaaa',\n 'aaa',\n 'aa',\n 'a',\n 'HH',\n 'H',\n 'hh',\n 'h',\n 'mm',\n 'm',\n 'ss',\n 's',\n 'SSS',\n 'SS',\n 'S',\n 'XXXXX',\n 'XXXX',\n 'XXX',\n 'XX',\n 'X',\n 'xxxxx',\n 'xxxx',\n 'xxx',\n 'xx',\n 'x',\n 'zzzz',\n 'zzz',\n 'zz',\n 'z',\n 'T',\n 't',\n ];\n\n // Try to match from longest to shortest\n for (let len = Math.min(count, 6); len > 0; len--) {\n const candidate = char.repeat(len);\n if (validTokens.includes(candidate)) {\n return candidate;\n }\n }\n\n return null;\n}\n\nfunction formatToken(token: string, zonedDateTime: Temporal.ZonedDateTime, locale: string): string {\n switch (token) {\n // Era\n case 'GGGGG':\n return formatPart(zonedDateTime, 'era', 'narrow', locale);\n case 'GGGG':\n return formatPart(zonedDateTime, 'era', 'long', locale);\n case 'GGG':\n case 'GG':\n case 'G':\n return formatPart(zonedDateTime, 'era', 'short', locale);\n\n // Year\n case 'yyyy':\n return zonedDateTime.year.toString().padStart(4, '0');\n case 'yyy':\n return zonedDateTime.year.toString().padStart(3, '0');\n case 'yy':\n return (zonedDateTime.year % 100).toString().padStart(2, '0');\n case 'y':\n return zonedDateTime.year.toString();\n\n // Quarter\n case 'QQQQQ':\n return Math.ceil(zonedDateTime.month / 3).toString();\n case 'QQQQ': {\n const quarter = Math.ceil(zonedDateTime.month / 3);\n return `${quarter}${getOrdinalSuffix(quarter)} quarter`;\n }\n case 'QQQ':\n return `Q${Math.ceil(zonedDateTime.month / 3)}`;\n case 'QQ':\n return Math.ceil(zonedDateTime.month / 3)\n .toString()\n .padStart(2, '0');\n case 'Q':\n return Math.ceil(zonedDateTime.month / 3).toString();\n\n // Month\n case 'MMMMM':\n return formatPart(zonedDateTime, 'month', 'narrow', locale);\n case 'MMMM':\n return formatPart(zonedDateTime, 'month', 'long', locale);\n case 'MMM':\n return formatPart(zonedDateTime, 'month', 'short', locale);\n case 'MM':\n return zonedDateTime.month.toString().padStart(2, '0');\n case 'Mo':\n return `${zonedDateTime.month}${getOrdinalSuffix(zonedDateTime.month)}`;\n case 'M':\n return zonedDateTime.month.toString();\n\n // Day of month\n case 'do':\n return `${zonedDateTime.day}${getOrdinalSuffix(zonedDateTime.day)}`;\n case 'dd':\n return zonedDateTime.day.toString().padStart(2, '0');\n case 'd':\n return zonedDateTime.day.toString();\n\n // Day of week\n case 'EEEEEE':\n return formatPart(zonedDateTime, 'weekday', 'short', locale).slice(0, 2);\n case 'EEEEE':\n return formatPart(zonedDateTime, 'weekday', 'narrow', locale);\n case 'EEEE':\n return formatPart(zonedDateTime, 'weekday', 'long', locale);\n case 'EEE':\n case 'EE':\n case 'E':\n return formatPart(zonedDateTime, 'weekday', 'short', locale);\n\n // AM/PM\n case 'aaaaa': {\n const period = formatPart(zonedDateTime, 'dayPeriod', 'narrow', locale).toLowerCase();\n return period.charAt(0);\n }\n case 'aaaa': {\n const period = formatPart(zonedDateTime, 'dayPeriod', 'short', locale);\n return period === 'AM' ? 'a.m.' : 'p.m.';\n }\n case 'aaa':\n return formatPart(zonedDateTime, 'dayPeriod', 'short', locale).toLowerCase();\n case 'aa':\n case 'a':\n return formatPart(zonedDateTime, 'dayPeriod', 'short', locale);\n\n // Hour [0-23]\n case 'HH':\n return zonedDateTime.hour.toString().padStart(2, '0');\n case 'H':\n return zonedDateTime.hour.toString();\n\n // Hour [1-12]\n case 'hh': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString().padStart(2, '0');\n }\n case 'h': {\n const hour12 = zonedDateTime.hour % 12 || 12;\n return hour12.toString();\n }\n\n // Minute\n case 'mm':\n return zonedDateTime.minute.toString().padStart(2, '0');\n case 'm':\n return zonedDateTime.minute.toString();\n\n // Second\n case 'ss':\n return zonedDateTime.second.toString().padStart(2, '0');\n case 's':\n return zonedDateTime.second.toString();\n\n // Fractional seconds\n case 'SSS':\n return zonedDateTime.millisecond.toString().padStart(3, '0');\n case 'SS':\n return Math.floor(zonedDateTime.millisecond / 10)\n .toString()\n .padStart(2, '0');\n case 'S':\n return Math.floor(zonedDateTime.millisecond / 100).toString();\n\n // Timezone\n case 'XXXXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XXXX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'XXX': {\n const offset = getTimezoneOffset(zonedDateTime);\n return offset === '+00:00' ? 'Z' : offset;\n }\n case 'XX': {\n const offset = getTimezoneOffset(zonedDateTime).replace(':', '');\n return offset === '+0000' ? 'Z' : offset;\n }\n case 'X': {\n const offset = getTimezoneOffset(zonedDateTime);\n if (offset === '+00:00') return 'Z';\n const [hours] = offset.split(':');\n return hours || '+00';\n }\n case 'xxxxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xxxx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'xxx':\n return getTimezoneOffset(zonedDateTime);\n case 'xx':\n return getTimezoneOffset(zonedDateTime).replace(':', '');\n case 'x': {\n const offset = getTimezoneOffset(zonedDateTime);\n const [hours] = offset.split(':');\n return hours || '+00';\n }\n case 'zzzz':\n return formatPart(zonedDateTime, 'timeZoneName', 'long', locale);\n case 'zzz':\n case 'zz':\n case 'z':\n return formatPart(zonedDateTime, 'timeZoneName', 'short', locale);\n\n // Timestamps\n case 'T':\n return zonedDateTime.epochMilliseconds.toString();\n case 't':\n return Math.floor(zonedDateTime.epochMilliseconds / 1000).toString();\n\n default:\n return token;\n }\n}\n\nfunction formatPart(\n zonedDateTime: Temporal.ZonedDateTime,\n part: 'era' | 'year' | 'month' | 'weekday' | 'day' | 'dayPeriod' | 'hour' | 'minute' | 'second' | 'timeZoneName',\n style: 'narrow' | 'short' | 'long' | 'numeric' | '2-digit',\n locale: string\n): string {\n const options: Intl.DateTimeFormatOptions = {};\n\n if (part === 'dayPeriod') {\n // dayPeriod needs hour to be present\n options.hour = 'numeric';\n options.hour12 = true;\n } else {\n options[part] = style as any;\n }\n\n const formatted = zonedDateTime.toLocaleString(locale, options);\n\n if (part === 'dayPeriod') {\n // Extract just the AM/PM part\n const match = formatted.match(/\\b(AM|PM|am|pm|a\\.m\\.|p\\.m\\.)\\b/);\n return match ? match[0] : formatted.split(' ').pop() || '';\n }\n\n return formatted;\n}\n\nfunction getOrdinalSuffix(num: number): string {\n const j = num % 10;\n const k = num % 100;\n if (j === 1 && k !== 11) return 'st';\n if (j === 2 && k !== 12) return 'nd';\n if (j === 3 && k !== 13) return 'rd';\n return 'th';\n}\n\nfunction getTimezoneOffset(zonedDateTime: Temporal.ZonedDateTime): string {\n const offsetNs = zonedDateTime.offsetNanoseconds;\n const offsetMinutes = offsetNs / (60 * 1e9);\n const sign = offsetMinutes >= 0 ? '+' : '-';\n const absMinutes = Math.abs(offsetMinutes);\n const hours = Math.floor(absMinutes / 60);\n const minutes = absMinutes % 60;\n return `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AA8BlB,SAAS,OACd,OACA,WACA,UAAyB,CAAC,GAClB;AACR,QAAM,EAAE,SAAS,SAAS,SAAS,IAAI;AAGvC,MAAI;AACJ,MAAI,UAAU;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O,GAAG,IAAI,GAAG,MAAM,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,QAAQ,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAC3F;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/toZonedTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.\n *\n * @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")\n * @returns A Temporal.ZonedDateTime in the specified timezone\n *\n * @example\n * ```typescript\n * // From ISO string\n * const zoned = toZonedTime(\"2025-01-20T20:00:00.000Z\", \"America/New_York\");\n * // zoned.hour === 15 (3 PM in New York)\n *\n * // From Date (e.g., from Drizzle ORM)\n * const date = new Date(\"2025-01-20T20:00:00.000Z\");\n * const zoned2 = toZonedTime(date, \"America/New_York\");\n *\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const zoned3 = toZonedTime(instant, \"Asia/Tokyo\");\n *\n * // From ZonedDateTime (convert to different timezone)\n * const nyTime = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const tokyoTime = toZonedTime(nyTime, \"Asia/Tokyo\");\n * ```\n */\nexport function toZonedTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: string\n): Temporal.ZonedDateTime {\n if (typeof input === 'string') {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Temporal.Instant) {\n return input.toZonedDateTimeISO(timezone);\n }\n\n return input.toInstant().toZonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA4BlB,SAAS,YACd,OACA,UACwB;AACxB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ;AAAA,EACjE;AAEA,MAAI,iBAAiB,MAAM;AACzB,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ;AAAA,EAC/E;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,mBAAmB,QAAQ;AAAA,EAC1C;AAEA,SAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AACtD;","names":[]}
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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,13 +0,0 @@
1
- // src/today.ts
2
- import { Temporal } from "@js-temporal/polyfill";
3
- function today(timezone) {
4
- if (timezone) {
5
- return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();
6
- }
7
- return Temporal.Now.plainDateISO();
8
- }
9
-
10
- export {
11
- today
12
- };
13
- //# sourceMappingURL=chunk-67QHALIG.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/simpleFormat.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n// simpleFormat options - discriminated by input type\ninterface PlainDateOptions {\n locale?: string;\n year?: 'auto' | 'always' | 'never';\n}\n\ninterface ZonedDateTimeOptions {\n locale?: string;\n time?: '12h' | '24h';\n timeZone?: string;\n year?: 'auto' | 'always' | 'never';\n}\n\ninterface InstantOptions {\n locale?: string;\n time?: '12h' | '24h';\n timeZone: string; // required for Instant\n year?: 'auto' | 'always' | 'never';\n}\n\n/**\n * Format a Temporal date in a human-friendly way: \"Dec 23\" or \"Dec 23, 2020\"\n *\n * By default (year: 'auto'), shows the year only if the date is not in the current year.\n * Use year: 'always' to always show the year, or year: 'never' to always hide it.\n * Optionally includes time in 12-hour or 24-hour format.\n *\n * @example\n * ```typescript\n * // Assuming current year is 2026\n * const date2026 = Temporal.ZonedDateTime.from(\"2026-12-23T15:30:00[America/New_York]\");\n * const date2020 = Temporal.ZonedDateTime.from(\"2020-12-23T15:30:00[America/New_York]\");\n *\n * simpleFormat(date2026); // \"Dec 23\"\n * simpleFormat(date2020); // \"Dec 23, 2020\"\n * simpleFormat(date2026, { time: '12h' }); // \"Dec 23, 3:30 PM\"\n * simpleFormat(date2026, { time: '24h' }); // \"Dec 23, 15:30\"\n *\n * // Control year display\n * simpleFormat(date2026, { year: 'always' }); // \"Dec 23, 2026\"\n * simpleFormat(date2020, { year: 'never' }); // \"Dec 23\"\n * simpleFormat(date2020, { year: 'auto' }); // \"Dec 23, 2020\" (default behavior)\n *\n * // With Instant (timeZone required)\n * const instant = Temporal.Instant.from(\"2026-12-23T20:30:00Z\");\n * simpleFormat(instant, { timeZone: 'America/New_York' }); // \"Dec 23\"\n * simpleFormat(instant, { timeZone: 'America/New_York', time: '12h' }); // \"Dec 23, 3:30 PM\"\n *\n * // With PlainDate (no time option)\n * const plain = Temporal.PlainDate.from(\"2020-12-23\");\n * simpleFormat(plain); // \"Dec 23, 2020\"\n * ```\n */\nexport function simpleFormat(input: Temporal.PlainDate, options?: PlainDateOptions): string;\nexport function simpleFormat(input: Temporal.ZonedDateTime, options?: ZonedDateTimeOptions): string;\nexport function simpleFormat(input: Temporal.Instant, options: InstantOptions): string;\nexport function simpleFormat(\n input: Temporal.PlainDate | Temporal.ZonedDateTime | Temporal.Instant,\n options: PlainDateOptions | ZonedDateTimeOptions | InstantOptions = {}\n): string {\n const locale = options.locale ?? 'en-US';\n const time = 'time' in options ? options.time : undefined;\n const timeZone = 'timeZone' in options ? options.timeZone : undefined;\n const yearOption = 'year' in options ? options.year : undefined;\n\n // Get year from the input (converting Instant to ZonedDateTime if needed)\n let year: number;\n let dateTimeForFormat: Temporal.PlainDate | Temporal.ZonedDateTime;\n\n if (input instanceof Temporal.Instant) {\n const tz = timeZone ?? 'UTC';\n const zoned = input.toZonedDateTimeISO(tz);\n year = zoned.year;\n dateTimeForFormat = zoned;\n } else if (input instanceof Temporal.ZonedDateTime) {\n if (timeZone) {\n const zoned = input.toInstant().toZonedDateTimeISO(timeZone);\n year = zoned.year;\n dateTimeForFormat = zoned;\n } else {\n year = input.year;\n dateTimeForFormat = input;\n }\n } else {\n year = input.year;\n dateTimeForFormat = input;\n }\n\n // Determine if year should be shown\n const currentYear = Temporal.Now.plainDateISO().year;\n const showYear =\n yearOption === 'always' ? true : yearOption === 'never' ? false : year !== currentYear;\n\n const dateOptions: Intl.DateTimeFormatOptions = {\n day: 'numeric',\n month: 'short',\n year: showYear ? 'numeric' : undefined,\n };\n\n // Add time options if requested and input supports it\n if (time && !(input instanceof Temporal.PlainDate)) {\n dateOptions.hour = 'numeric';\n dateOptions.minute = '2-digit';\n dateOptions.hour12 = time === '12h';\n }\n\n return dateTimeForFormat.toLocaleString(locale, dateOptions);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA0DlB,SAAS,aACd,OACA,UAAoE,CAAC,GAC7D;AACR,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,OAAO,UAAU,UAAU,QAAQ,OAAO;AAChD,QAAM,WAAW,cAAc,UAAU,QAAQ,WAAW;AAC5D,QAAM,aAAa,UAAU,UAAU,QAAQ,OAAO;AAGtD,MAAI;AACJ,MAAI;AAEJ,MAAI,iBAAiB,SAAS,SAAS;AACrC,UAAM,KAAK,YAAY;AACvB,UAAM,QAAQ,MAAM,mBAAmB,EAAE;AACzC,WAAO,MAAM;AACb,wBAAoB;AAAA,EACtB,WAAW,iBAAiB,SAAS,eAAe;AAClD,QAAI,UAAU;AACZ,YAAM,QAAQ,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AAC3D,aAAO,MAAM;AACb,0BAAoB;AAAA,IACtB,OAAO;AACL,aAAO,MAAM;AACb,0BAAoB;AAAA,IACtB;AAAA,EACF,OAAO;AACL,WAAO,MAAM;AACb,wBAAoB;AAAA,EACtB;AAGA,QAAM,cAAc,SAAS,IAAI,aAAa,EAAE;AAChD,QAAM,WACJ,eAAe,WAAW,OAAO,eAAe,UAAU,QAAQ,SAAS;AAE7E,QAAM,cAA0C;AAAA,IAC9C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM,WAAW,YAAY;AAAA,EAC/B;AAGA,MAAI,QAAQ,EAAE,iBAAiB,SAAS,YAAY;AAClD,gBAAY,OAAO;AACnB,gBAAY,SAAS;AACrB,gBAAY,SAAS,SAAS;AAAA,EAChC;AAEA,SAAO,kBAAkB,eAAe,QAAQ,WAAW;AAC7D;","names":[]}