@gobrand/tiempo 2.6.2 → 2.7.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 (65) hide show
  1. package/dist/{chunk-IBO2U23N.js → chunk-5C3TQSWA.js} +4 -4
  2. package/dist/chunk-BUX26GTD.js +30 -0
  3. package/dist/chunk-BUX26GTD.js.map +1 -0
  4. package/dist/chunk-DKYVFYWM.js +25 -0
  5. package/dist/chunk-DKYVFYWM.js.map +1 -0
  6. package/dist/chunk-G2JUEBC5.js +26 -0
  7. package/dist/chunk-G2JUEBC5.js.map +1 -0
  8. package/dist/{chunk-MGMLT4L6.js → chunk-JA7SVLAF.js} +4 -4
  9. package/dist/chunk-OLEOU3XE.js +28 -0
  10. package/dist/chunk-OLEOU3XE.js.map +1 -0
  11. package/dist/chunk-TNCLJK4Y.js +38 -0
  12. package/dist/chunk-TNCLJK4Y.js.map +1 -0
  13. package/dist/chunk-Y7CIJQ67.js +26 -0
  14. package/dist/chunk-Y7CIJQ67.js.map +1 -0
  15. package/dist/chunk-YQBM63DC.js +57 -0
  16. package/dist/chunk-YQBM63DC.js.map +1 -0
  17. package/dist/eachDayOfInterval.d.ts +69 -0
  18. package/dist/eachDayOfInterval.d.ts.map +1 -0
  19. package/dist/eachDayOfInterval.js +8 -0
  20. package/dist/eachDayOfInterval.js.map +1 -0
  21. package/dist/eachDayOfInterval.test.d.ts +2 -0
  22. package/dist/eachDayOfInterval.test.d.ts.map +1 -0
  23. package/dist/eachHourOfInterval.d.ts +51 -0
  24. package/dist/eachHourOfInterval.d.ts.map +1 -0
  25. package/dist/eachHourOfInterval.js +8 -0
  26. package/dist/eachHourOfInterval.js.map +1 -0
  27. package/dist/eachHourOfInterval.test.d.ts +2 -0
  28. package/dist/eachHourOfInterval.test.d.ts.map +1 -0
  29. package/dist/eachMinuteOfInterval.d.ts +50 -0
  30. package/dist/eachMinuteOfInterval.d.ts.map +1 -0
  31. package/dist/eachMinuteOfInterval.js +8 -0
  32. package/dist/eachMinuteOfInterval.js.map +1 -0
  33. package/dist/eachMinuteOfInterval.test.d.ts +2 -0
  34. package/dist/eachMinuteOfInterval.test.d.ts.map +1 -0
  35. package/dist/eachMonthOfInterval.d.ts +46 -0
  36. package/dist/eachMonthOfInterval.d.ts.map +1 -0
  37. package/dist/eachMonthOfInterval.js +8 -0
  38. package/dist/eachMonthOfInterval.js.map +1 -0
  39. package/dist/eachMonthOfInterval.test.d.ts +2 -0
  40. package/dist/eachMonthOfInterval.test.d.ts.map +1 -0
  41. package/dist/eachWeekOfInterval.d.ts +58 -0
  42. package/dist/eachWeekOfInterval.d.ts.map +1 -0
  43. package/dist/eachWeekOfInterval.js +8 -0
  44. package/dist/eachWeekOfInterval.js.map +1 -0
  45. package/dist/eachWeekOfInterval.test.d.ts +2 -0
  46. package/dist/eachWeekOfInterval.test.d.ts.map +1 -0
  47. package/dist/eachYearOfInterval.d.ts +55 -0
  48. package/dist/eachYearOfInterval.d.ts.map +1 -0
  49. package/dist/eachYearOfInterval.js +8 -0
  50. package/dist/eachYearOfInterval.js.map +1 -0
  51. package/dist/eachYearOfInterval.test.d.ts +2 -0
  52. package/dist/eachYearOfInterval.test.d.ts.map +1 -0
  53. package/dist/index.d.ts +7 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +69 -45
  56. package/dist/isFuture.js +2 -2
  57. package/dist/isWithinInterval.js +2 -2
  58. package/dist/simpleFormat.d.ts +48 -37
  59. package/dist/simpleFormat.d.ts.map +1 -1
  60. package/dist/simpleFormat.js +1 -1
  61. package/package.json +1 -1
  62. package/dist/chunk-TFSZ55L7.js +0 -46
  63. package/dist/chunk-TFSZ55L7.js.map +0 -1
  64. /package/dist/{chunk-IBO2U23N.js.map → chunk-5C3TQSWA.js.map} +0 -0
  65. /package/dist/{chunk-MGMLT4L6.js.map → chunk-JA7SVLAF.js.map} +0 -0
@@ -1,46 +0,0 @@
1
- // src/simpleFormat.ts
2
- import { Temporal } from "@js-temporal/polyfill";
3
- function simpleFormat(input, options = {}) {
4
- const locale = options.locale ?? "en-US";
5
- const time = "time" in options ? options.time : void 0;
6
- const timeZone = "timeZone" in options ? options.timeZone : void 0;
7
- const yearOption = "year" in options ? options.year : void 0;
8
- let year;
9
- let dateTimeForFormat;
10
- if (input instanceof Temporal.Instant) {
11
- const tz = timeZone ?? "UTC";
12
- const zoned = input.toZonedDateTimeISO(tz);
13
- year = zoned.year;
14
- dateTimeForFormat = zoned;
15
- } else if (input instanceof Temporal.ZonedDateTime) {
16
- if (timeZone) {
17
- const zoned = input.toInstant().toZonedDateTimeISO(timeZone);
18
- year = zoned.year;
19
- dateTimeForFormat = zoned;
20
- } else {
21
- year = input.year;
22
- dateTimeForFormat = input;
23
- }
24
- } else {
25
- year = input.year;
26
- dateTimeForFormat = input;
27
- }
28
- const currentYear = Temporal.Now.plainDateISO().year;
29
- const showYear = yearOption === "always" ? true : yearOption === "never" ? false : year !== currentYear;
30
- const dateOptions = {
31
- day: "numeric",
32
- month: "short",
33
- year: showYear ? "numeric" : void 0
34
- };
35
- if (time && !(input instanceof Temporal.PlainDate)) {
36
- dateOptions.hour = "numeric";
37
- dateOptions.minute = "2-digit";
38
- dateOptions.hour12 = time === "12h";
39
- }
40
- return dateTimeForFormat.toLocaleString(locale, dateOptions);
41
- }
42
-
43
- export {
44
- simpleFormat
45
- };
46
- //# sourceMappingURL=chunk-TFSZ55L7.js.map
@@ -1 +0,0 @@
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":[]}