@internationalized/date 3.5.3-nightly.4555 → 3.5.3-nightly.4558

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 (96) hide show
  1. package/dist/BuddhistCalendar.main.js +54 -0
  2. package/dist/BuddhistCalendar.main.js.map +1 -0
  3. package/dist/BuddhistCalendar.mjs +49 -0
  4. package/dist/BuddhistCalendar.module.js +49 -0
  5. package/dist/BuddhistCalendar.module.js.map +1 -0
  6. package/dist/CalendarDate.main.js +260 -0
  7. package/dist/CalendarDate.main.js.map +1 -0
  8. package/dist/CalendarDate.mjs +252 -0
  9. package/dist/CalendarDate.module.js +252 -0
  10. package/dist/CalendarDate.module.js.map +1 -0
  11. package/dist/DateFormatter.main.js +145 -0
  12. package/dist/DateFormatter.main.js.map +1 -0
  13. package/dist/DateFormatter.mjs +140 -0
  14. package/dist/DateFormatter.module.js +140 -0
  15. package/dist/DateFormatter.module.js.map +1 -0
  16. package/dist/EthiopicCalendar.main.js +170 -0
  17. package/dist/EthiopicCalendar.main.js.map +1 -0
  18. package/dist/EthiopicCalendar.mjs +163 -0
  19. package/dist/EthiopicCalendar.module.js +163 -0
  20. package/dist/EthiopicCalendar.module.js.map +1 -0
  21. package/dist/GregorianCalendar.main.js +143 -0
  22. package/dist/GregorianCalendar.main.js.map +1 -0
  23. package/dist/GregorianCalendar.mjs +134 -0
  24. package/dist/GregorianCalendar.module.js +134 -0
  25. package/dist/GregorianCalendar.module.js.map +1 -0
  26. package/dist/HebrewCalendar.main.js +149 -0
  27. package/dist/HebrewCalendar.main.js.map +1 -0
  28. package/dist/HebrewCalendar.mjs +144 -0
  29. package/dist/HebrewCalendar.module.js +144 -0
  30. package/dist/HebrewCalendar.module.js.map +1 -0
  31. package/dist/IndianCalendar.main.js +107 -0
  32. package/dist/IndianCalendar.main.js.map +1 -0
  33. package/dist/IndianCalendar.mjs +102 -0
  34. package/dist/IndianCalendar.module.js +102 -0
  35. package/dist/IndianCalendar.module.js.map +1 -0
  36. package/dist/IslamicCalendar.main.js +164 -0
  37. package/dist/IslamicCalendar.main.js.map +1 -0
  38. package/dist/IslamicCalendar.mjs +157 -0
  39. package/dist/IslamicCalendar.module.js +157 -0
  40. package/dist/IslamicCalendar.module.js.map +1 -0
  41. package/dist/JapaneseCalendar.main.js +180 -0
  42. package/dist/JapaneseCalendar.main.js.map +1 -0
  43. package/dist/JapaneseCalendar.mjs +175 -0
  44. package/dist/JapaneseCalendar.module.js +175 -0
  45. package/dist/JapaneseCalendar.module.js.map +1 -0
  46. package/dist/PersianCalendar.main.js +81 -0
  47. package/dist/PersianCalendar.main.js.map +1 -0
  48. package/dist/PersianCalendar.mjs +76 -0
  49. package/dist/PersianCalendar.module.js +76 -0
  50. package/dist/PersianCalendar.module.js.map +1 -0
  51. package/dist/TaiwanCalendar.main.js +81 -0
  52. package/dist/TaiwanCalendar.main.js.map +1 -0
  53. package/dist/TaiwanCalendar.mjs +76 -0
  54. package/dist/TaiwanCalendar.module.js +76 -0
  55. package/dist/TaiwanCalendar.module.js.map +1 -0
  56. package/dist/conversion.main.js +236 -0
  57. package/dist/conversion.main.js.map +1 -0
  58. package/dist/conversion.mjs +218 -0
  59. package/dist/conversion.module.js +218 -0
  60. package/dist/conversion.module.js.map +1 -0
  61. package/dist/createCalendar.main.js +69 -0
  62. package/dist/createCalendar.main.js.map +1 -0
  63. package/dist/createCalendar.mjs +64 -0
  64. package/dist/createCalendar.module.js +64 -0
  65. package/dist/createCalendar.module.js.map +1 -0
  66. package/dist/import.mjs +15 -2534
  67. package/dist/main.js +75 -2594
  68. package/dist/main.js.map +1 -1
  69. package/dist/manipulation.main.js +362 -0
  70. package/dist/manipulation.main.js.map +1 -0
  71. package/dist/manipulation.mjs +344 -0
  72. package/dist/manipulation.module.js +344 -0
  73. package/dist/manipulation.module.js.map +1 -0
  74. package/dist/module.js +15 -2534
  75. package/dist/module.js.map +1 -1
  76. package/dist/queries.main.js +287 -0
  77. package/dist/queries.main.js.map +1 -0
  78. package/dist/queries.mjs +256 -0
  79. package/dist/queries.module.js +256 -0
  80. package/dist/queries.module.js.map +1 -0
  81. package/dist/string.main.js +171 -0
  82. package/dist/string.main.js.map +1 -0
  83. package/dist/string.mjs +156 -0
  84. package/dist/string.module.js +156 -0
  85. package/dist/string.module.js.map +1 -0
  86. package/dist/utils.main.js +33 -0
  87. package/dist/utils.main.js.map +1 -0
  88. package/dist/utils.mjs +28 -0
  89. package/dist/utils.module.js +28 -0
  90. package/dist/utils.module.js.map +1 -0
  91. package/dist/weekStartData.main.js +118 -0
  92. package/dist/weekStartData.main.js.map +1 -0
  93. package/dist/weekStartData.mjs +113 -0
  94. package/dist/weekStartData.module.js +113 -0
  95. package/dist/weekStartData.module.js.map +1 -0
  96. package/package.json +2 -2
@@ -0,0 +1,145 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "DateFormatter", () => $8f23a04ae90a588b$export$ad991b66133851cf);
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ let $8f23a04ae90a588b$var$formatterCache = new Map();
18
+ class $8f23a04ae90a588b$export$ad991b66133851cf {
19
+ /** Formats a date as a string according to the locale and format options passed to the constructor. */ format(value) {
20
+ return this.formatter.format(value);
21
+ }
22
+ /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) {
23
+ return this.formatter.formatToParts(value);
24
+ }
25
+ /** Formats a date range as a string. */ formatRange(start, end) {
26
+ // @ts-ignore
27
+ if (typeof this.formatter.formatRange === "function") // @ts-ignore
28
+ return this.formatter.formatRange(start, end);
29
+ if (end < start) throw new RangeError("End date must be >= start date");
30
+ // Very basic fallback for old browsers.
31
+ return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
32
+ }
33
+ /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
34
+ // @ts-ignore
35
+ if (typeof this.formatter.formatRangeToParts === "function") // @ts-ignore
36
+ return this.formatter.formatRangeToParts(start, end);
37
+ if (end < start) throw new RangeError("End date must be >= start date");
38
+ let startParts = this.formatter.formatToParts(start);
39
+ let endParts = this.formatter.formatToParts(end);
40
+ return [
41
+ ...startParts.map((p)=>({
42
+ ...p,
43
+ source: "startRange"
44
+ })),
45
+ {
46
+ type: "literal",
47
+ value: " \u2013 ",
48
+ source: "shared"
49
+ },
50
+ ...endParts.map((p)=>({
51
+ ...p,
52
+ source: "endRange"
53
+ }))
54
+ ];
55
+ }
56
+ /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
57
+ let resolvedOptions = this.formatter.resolvedOptions();
58
+ if ($8f23a04ae90a588b$var$hasBuggyResolvedHourCycle()) {
59
+ if (!this.resolvedHourCycle) this.resolvedHourCycle = $8f23a04ae90a588b$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
60
+ resolvedOptions.hourCycle = this.resolvedHourCycle;
61
+ resolvedOptions.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12";
62
+ }
63
+ // Safari uses a different name for the Ethiopic (Amete Alem) calendar.
64
+ // https://bugs.webkit.org/show_bug.cgi?id=241564
65
+ if (resolvedOptions.calendar === "ethiopic-amete-alem") resolvedOptions.calendar = "ethioaa";
66
+ return resolvedOptions;
67
+ }
68
+ constructor(locale, options = {}){
69
+ this.formatter = $8f23a04ae90a588b$var$getCachedDateFormatter(locale, options);
70
+ this.options = options;
71
+ }
72
+ }
73
+ // There are multiple bugs involving the hour12 and hourCycle options in various browser engines.
74
+ // - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)
75
+ // rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)
76
+ // rather than h12 (12:00 - 11:59).
77
+ // - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal
78
+ // in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]
79
+ // [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791
80
+ // [2] https://github.com/tc39/ecma402/issues/402
81
+ // [3] https://bugs.webkit.org/show_bug.cgi?id=229313
82
+ // https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802
83
+ const $8f23a04ae90a588b$var$hour12Preferences = {
84
+ true: {
85
+ // Only Japanese uses the h11 style for 12 hour time. All others use h12.
86
+ ja: "h11"
87
+ },
88
+ false: {
89
+ }
90
+ };
91
+ function $8f23a04ae90a588b$var$getCachedDateFormatter(locale, options = {}) {
92
+ // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
93
+ // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
94
+ if (typeof options.hour12 === "boolean" && $8f23a04ae90a588b$var$hasBuggyHour12Behavior()) {
95
+ options = {
96
+ ...options
97
+ };
98
+ let pref = $8f23a04ae90a588b$var$hour12Preferences[String(options.hour12)][locale.split("-")[0]];
99
+ let defaultHourCycle = options.hour12 ? "h12" : "h23";
100
+ options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
101
+ delete options.hour12;
102
+ }
103
+ let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
104
+ if ($8f23a04ae90a588b$var$formatterCache.has(cacheKey)) return $8f23a04ae90a588b$var$formatterCache.get(cacheKey);
105
+ let numberFormatter = new Intl.DateTimeFormat(locale, options);
106
+ $8f23a04ae90a588b$var$formatterCache.set(cacheKey, numberFormatter);
107
+ return numberFormatter;
108
+ }
109
+ let $8f23a04ae90a588b$var$_hasBuggyHour12Behavior = null;
110
+ function $8f23a04ae90a588b$var$hasBuggyHour12Behavior() {
111
+ if ($8f23a04ae90a588b$var$_hasBuggyHour12Behavior == null) $8f23a04ae90a588b$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat("en-US", {
112
+ hour: "numeric",
113
+ hour12: false
114
+ }).format(new Date(2020, 2, 3, 0)) === "24";
115
+ return $8f23a04ae90a588b$var$_hasBuggyHour12Behavior;
116
+ }
117
+ let $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle = null;
118
+ function $8f23a04ae90a588b$var$hasBuggyResolvedHourCycle() {
119
+ if ($8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle == null) $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat("fr", {
120
+ hour: "numeric",
121
+ hour12: false
122
+ }).resolvedOptions().hourCycle === "h12";
123
+ return $8f23a04ae90a588b$var$_hasBuggyResolvedHourCycle;
124
+ }
125
+ function $8f23a04ae90a588b$var$getResolvedHourCycle(locale, options) {
126
+ if (!options.timeStyle && !options.hour) return undefined;
127
+ // Work around buggy results in resolved hourCycle and hour12 options in WebKit.
128
+ // Format the minimum possible hour and maximum possible hour in a day and parse the results.
129
+ locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, "");
130
+ locale += (locale.includes("-u-") ? "" : "-u") + "-nu-latn";
131
+ let formatter = $8f23a04ae90a588b$var$getCachedDateFormatter(locale, {
132
+ ...options,
133
+ timeZone: undefined // use local timezone
134
+ });
135
+ let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === "hour").value, 10);
136
+ let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === "hour").value, 10);
137
+ if (min === 0 && max === 23) return "h23";
138
+ if (min === 24 && max === 23) return "h24";
139
+ if (min === 0 && max === 11) return "h11";
140
+ if (min === 12 && max === 11) return "h12";
141
+ throw new Error("Unexpected hour cycle result");
142
+ }
143
+
144
+
145
+ //# sourceMappingURL=DateFormatter.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAWlB,MAAM;IAUX,qGAAqG,GACrG,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E;IAEA,+CAA+C,GAC/C,mBAAmB,KAAW,EAAE,GAAS,EAAyB;QAChE,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,KAAK,YAC/C,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO;QAGlD,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;QAC9C,IAAI,WAAW,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;QAC5C,OAAO;eACF,WAAW,GAAG,CAAC,CAAA,IAAM,CAAA;oBAAC,GAAG,CAA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BAAqB;IAC3C;IAEA,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IACzG,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IAE1G,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.DateTimeFormat>();\n\ninterface ResolvedDateTimeFormatOptions extends Intl.ResolvedDateTimeFormatOptions {\n hourCycle?: Intl.DateTimeFormatOptions['hourCycle']\n}\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /** Formats a date as a string according to the locale and format options passed to the constructor. */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as DateRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as DateRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions() as ResolvedDateTimeFormatOptions;\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(locale: string, options: Intl.DateTimeFormatOptions = {}): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle = (new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions() as ResolvedDateTimeFormatOptions).hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value, 10);\n let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value, 10);\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.main.js.map"}
@@ -0,0 +1,140 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ let $fb18d541ea1ad717$var$formatterCache = new Map();
12
+ class $fb18d541ea1ad717$export$ad991b66133851cf {
13
+ /** Formats a date as a string according to the locale and format options passed to the constructor. */ format(value) {
14
+ return this.formatter.format(value);
15
+ }
16
+ /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) {
17
+ return this.formatter.formatToParts(value);
18
+ }
19
+ /** Formats a date range as a string. */ formatRange(start, end) {
20
+ // @ts-ignore
21
+ if (typeof this.formatter.formatRange === "function") // @ts-ignore
22
+ return this.formatter.formatRange(start, end);
23
+ if (end < start) throw new RangeError("End date must be >= start date");
24
+ // Very basic fallback for old browsers.
25
+ return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
26
+ }
27
+ /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
28
+ // @ts-ignore
29
+ if (typeof this.formatter.formatRangeToParts === "function") // @ts-ignore
30
+ return this.formatter.formatRangeToParts(start, end);
31
+ if (end < start) throw new RangeError("End date must be >= start date");
32
+ let startParts = this.formatter.formatToParts(start);
33
+ let endParts = this.formatter.formatToParts(end);
34
+ return [
35
+ ...startParts.map((p)=>({
36
+ ...p,
37
+ source: "startRange"
38
+ })),
39
+ {
40
+ type: "literal",
41
+ value: " \u2013 ",
42
+ source: "shared"
43
+ },
44
+ ...endParts.map((p)=>({
45
+ ...p,
46
+ source: "endRange"
47
+ }))
48
+ ];
49
+ }
50
+ /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
51
+ let resolvedOptions = this.formatter.resolvedOptions();
52
+ if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
53
+ if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
54
+ resolvedOptions.hourCycle = this.resolvedHourCycle;
55
+ resolvedOptions.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12";
56
+ }
57
+ // Safari uses a different name for the Ethiopic (Amete Alem) calendar.
58
+ // https://bugs.webkit.org/show_bug.cgi?id=241564
59
+ if (resolvedOptions.calendar === "ethiopic-amete-alem") resolvedOptions.calendar = "ethioaa";
60
+ return resolvedOptions;
61
+ }
62
+ constructor(locale, options = {}){
63
+ this.formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options);
64
+ this.options = options;
65
+ }
66
+ }
67
+ // There are multiple bugs involving the hour12 and hourCycle options in various browser engines.
68
+ // - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)
69
+ // rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)
70
+ // rather than h12 (12:00 - 11:59).
71
+ // - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal
72
+ // in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]
73
+ // [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791
74
+ // [2] https://github.com/tc39/ecma402/issues/402
75
+ // [3] https://bugs.webkit.org/show_bug.cgi?id=229313
76
+ // https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802
77
+ const $fb18d541ea1ad717$var$hour12Preferences = {
78
+ true: {
79
+ // Only Japanese uses the h11 style for 12 hour time. All others use h12.
80
+ ja: "h11"
81
+ },
82
+ false: {
83
+ }
84
+ };
85
+ function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
86
+ // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
87
+ // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
88
+ if (typeof options.hour12 === "boolean" && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
89
+ options = {
90
+ ...options
91
+ };
92
+ let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split("-")[0]];
93
+ let defaultHourCycle = options.hour12 ? "h12" : "h23";
94
+ options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
95
+ delete options.hour12;
96
+ }
97
+ let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
98
+ if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
99
+ let numberFormatter = new Intl.DateTimeFormat(locale, options);
100
+ $fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
101
+ return numberFormatter;
102
+ }
103
+ let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
104
+ function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
105
+ if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat("en-US", {
106
+ hour: "numeric",
107
+ hour12: false
108
+ }).format(new Date(2020, 2, 3, 0)) === "24";
109
+ return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
110
+ }
111
+ let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
112
+ function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
113
+ if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat("fr", {
114
+ hour: "numeric",
115
+ hour12: false
116
+ }).resolvedOptions().hourCycle === "h12";
117
+ return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
118
+ }
119
+ function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
120
+ if (!options.timeStyle && !options.hour) return undefined;
121
+ // Work around buggy results in resolved hourCycle and hour12 options in WebKit.
122
+ // Format the minimum possible hour and maximum possible hour in a day and parse the results.
123
+ locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, "");
124
+ locale += (locale.includes("-u-") ? "" : "-u") + "-nu-latn";
125
+ let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
126
+ ...options,
127
+ timeZone: undefined // use local timezone
128
+ });
129
+ let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === "hour").value, 10);
130
+ let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === "hour").value, 10);
131
+ if (min === 0 && max === 23) return "h23";
132
+ if (min === 24 && max === 23) return "h24";
133
+ if (min === 0 && max === 11) return "h11";
134
+ if (min === 12 && max === 11) return "h12";
135
+ throw new Error("Unexpected hour cycle result");
136
+ }
137
+
138
+
139
+ export {$fb18d541ea1ad717$export$ad991b66133851cf as DateFormatter};
140
+ //# sourceMappingURL=DateFormatter.mjs.map
@@ -0,0 +1,140 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ let $fb18d541ea1ad717$var$formatterCache = new Map();
12
+ class $fb18d541ea1ad717$export$ad991b66133851cf {
13
+ /** Formats a date as a string according to the locale and format options passed to the constructor. */ format(value) {
14
+ return this.formatter.format(value);
15
+ }
16
+ /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) {
17
+ return this.formatter.formatToParts(value);
18
+ }
19
+ /** Formats a date range as a string. */ formatRange(start, end) {
20
+ // @ts-ignore
21
+ if (typeof this.formatter.formatRange === "function") // @ts-ignore
22
+ return this.formatter.formatRange(start, end);
23
+ if (end < start) throw new RangeError("End date must be >= start date");
24
+ // Very basic fallback for old browsers.
25
+ return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
26
+ }
27
+ /** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
28
+ // @ts-ignore
29
+ if (typeof this.formatter.formatRangeToParts === "function") // @ts-ignore
30
+ return this.formatter.formatRangeToParts(start, end);
31
+ if (end < start) throw new RangeError("End date must be >= start date");
32
+ let startParts = this.formatter.formatToParts(start);
33
+ let endParts = this.formatter.formatToParts(end);
34
+ return [
35
+ ...startParts.map((p)=>({
36
+ ...p,
37
+ source: "startRange"
38
+ })),
39
+ {
40
+ type: "literal",
41
+ value: " \u2013 ",
42
+ source: "shared"
43
+ },
44
+ ...endParts.map((p)=>({
45
+ ...p,
46
+ source: "endRange"
47
+ }))
48
+ ];
49
+ }
50
+ /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
51
+ let resolvedOptions = this.formatter.resolvedOptions();
52
+ if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
53
+ if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
54
+ resolvedOptions.hourCycle = this.resolvedHourCycle;
55
+ resolvedOptions.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12";
56
+ }
57
+ // Safari uses a different name for the Ethiopic (Amete Alem) calendar.
58
+ // https://bugs.webkit.org/show_bug.cgi?id=241564
59
+ if (resolvedOptions.calendar === "ethiopic-amete-alem") resolvedOptions.calendar = "ethioaa";
60
+ return resolvedOptions;
61
+ }
62
+ constructor(locale, options = {}){
63
+ this.formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options);
64
+ this.options = options;
65
+ }
66
+ }
67
+ // There are multiple bugs involving the hour12 and hourCycle options in various browser engines.
68
+ // - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)
69
+ // rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)
70
+ // rather than h12 (12:00 - 11:59).
71
+ // - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal
72
+ // in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]
73
+ // [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791
74
+ // [2] https://github.com/tc39/ecma402/issues/402
75
+ // [3] https://bugs.webkit.org/show_bug.cgi?id=229313
76
+ // https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802
77
+ const $fb18d541ea1ad717$var$hour12Preferences = {
78
+ true: {
79
+ // Only Japanese uses the h11 style for 12 hour time. All others use h12.
80
+ ja: "h11"
81
+ },
82
+ false: {
83
+ }
84
+ };
85
+ function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
86
+ // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.
87
+ // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.
88
+ if (typeof options.hour12 === "boolean" && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
89
+ options = {
90
+ ...options
91
+ };
92
+ let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split("-")[0]];
93
+ let defaultHourCycle = options.hour12 ? "h12" : "h23";
94
+ options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
95
+ delete options.hour12;
96
+ }
97
+ let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
98
+ if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
99
+ let numberFormatter = new Intl.DateTimeFormat(locale, options);
100
+ $fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
101
+ return numberFormatter;
102
+ }
103
+ let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
104
+ function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
105
+ if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat("en-US", {
106
+ hour: "numeric",
107
+ hour12: false
108
+ }).format(new Date(2020, 2, 3, 0)) === "24";
109
+ return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
110
+ }
111
+ let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
112
+ function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
113
+ if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat("fr", {
114
+ hour: "numeric",
115
+ hour12: false
116
+ }).resolvedOptions().hourCycle === "h12";
117
+ return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
118
+ }
119
+ function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
120
+ if (!options.timeStyle && !options.hour) return undefined;
121
+ // Work around buggy results in resolved hourCycle and hour12 options in WebKit.
122
+ // Format the minimum possible hour and maximum possible hour in a day and parse the results.
123
+ locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, "");
124
+ locale += (locale.includes("-u-") ? "" : "-u") + "-nu-latn";
125
+ let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
126
+ ...options,
127
+ timeZone: undefined // use local timezone
128
+ });
129
+ let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p)=>p.type === "hour").value, 10);
130
+ let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p)=>p.type === "hour").value, 10);
131
+ if (min === 0 && max === 23) return "h23";
132
+ if (min === 24 && max === 23) return "h24";
133
+ if (min === 0 && max === 11) return "h11";
134
+ if (min === 12 && max === 11) return "h12";
135
+ throw new Error("Unexpected hour cycle result");
136
+ }
137
+
138
+
139
+ export {$fb18d541ea1ad717$export$ad991b66133851cf as DateFormatter};
140
+ //# sourceMappingURL=DateFormatter.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAWlB,MAAM;IAUX,qGAAqG,GACrG,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1E;IAEA,+CAA+C,GAC/C,mBAAmB,KAAW,EAAE,GAAS,EAAyB;QAChE,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,KAAK,YAC/C,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO;QAGlD,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,IAAI,aAAa,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;QAC9C,IAAI,WAAW,IAAI,CAAC,SAAS,CAAC,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IAAG,IAAK;IACjD,IAAI,YAAY,6CAAuB,QAAQ;QAC7C,GAAG,OAAO;QACV,UAAU,UAAU,qBAAqB;IAC3C;IAEA,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IACzG,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IAE1G,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.DateTimeFormat>();\n\ninterface ResolvedDateTimeFormatOptions extends Intl.ResolvedDateTimeFormatOptions {\n hourCycle?: Intl.DateTimeFormatOptions['hourCycle']\n}\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /** Formats a date as a string according to the locale and format options passed to the constructor. */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as DateRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as DateRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions() as ResolvedDateTimeFormatOptions;\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(locale: string, options: Intl.DateTimeFormatOptions = {}): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle = (new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions() as ResolvedDateTimeFormatOptions).hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value, 10);\n let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value, 10);\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.module.js.map"}
@@ -0,0 +1,170 @@
1
+ var $625ad1e1f4c43bc1$exports = require("./CalendarDate.main.js");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "EthiopicCalendar", () => $4db04d1051af0f2f$export$26ba6eab5e20cd7d);
9
+ $parcel$export(module.exports, "EthiopicAmeteAlemCalendar", () => $4db04d1051af0f2f$export$d72e0c37005a4914);
10
+ $parcel$export(module.exports, "CopticCalendar", () => $4db04d1051af0f2f$export$fe6243cbe1a4b7c1);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */ // Portions of the code in this file are based on code from ICU.
22
+ // Original licensing can be found in the NOTICE file in the root directory of this source tree.
23
+
24
+ const $4db04d1051af0f2f$var$ETHIOPIC_EPOCH = 1723856;
25
+ const $4db04d1051af0f2f$var$COPTIC_EPOCH = 1824665;
26
+ // The delta between Amete Alem 1 and Amete Mihret 1
27
+ // AA 5501 = AM 1
28
+ const $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA = 5500;
29
+ function $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, month, day) {
30
+ return epoch // difference from Julian epoch to 1,1,1
31
+ + 365 * year // number of days from years
32
+ + Math.floor(year / 4) // extra day of leap year
33
+ + 30 * (month - 1 // number of days from months (1 based)
34
+ ) + day - 1 // number of days for present month (1 based)
35
+ ;
36
+ }
37
+ function $4db04d1051af0f2f$var$julianDayToCE(epoch, jd) {
38
+ let year = Math.floor(4 * (jd - epoch) / 1461);
39
+ let month = 1 + Math.floor((jd - $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, 1, 1)) / 30);
40
+ let day = jd + 1 - $4db04d1051af0f2f$var$ceToJulianDay(epoch, year, month, 1);
41
+ return [
42
+ year,
43
+ month,
44
+ day
45
+ ];
46
+ }
47
+ function $4db04d1051af0f2f$var$getLeapDay(year) {
48
+ return Math.floor(year % 4 / 3);
49
+ }
50
+ function $4db04d1051af0f2f$var$getDaysInMonth(year, month) {
51
+ // The Ethiopian and Coptic calendars have 13 months, 12 of 30 days each and
52
+ // an intercalary month at the end of the year of 5 or 6 days, depending whether
53
+ // the year is a leap year or not. The Leap Year follows the same rules as the
54
+ // Julian Calendar so that the extra month always has six days in the year before
55
+ // a Julian Leap Year.
56
+ if (month % 13 !== 0) // not intercalary month
57
+ return 30;
58
+ else // intercalary month 5 days + possible leap day
59
+ return $4db04d1051af0f2f$var$getLeapDay(year) + 5;
60
+ }
61
+ class $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
62
+ fromJulianDay(jd) {
63
+ let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, jd);
64
+ let era = "AM";
65
+ if (year <= 0) {
66
+ era = "AA";
67
+ year += $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
68
+ }
69
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, era, year, month, day);
70
+ }
71
+ toJulianDay(date) {
72
+ let year = date.year;
73
+ if (date.era === "AA") year -= $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
74
+ return $4db04d1051af0f2f$var$ceToJulianDay($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, year, date.month, date.day);
75
+ }
76
+ getDaysInMonth(date) {
77
+ return $4db04d1051af0f2f$var$getDaysInMonth(date.year, date.month);
78
+ }
79
+ getMonthsInYear() {
80
+ return 13;
81
+ }
82
+ getDaysInYear(date) {
83
+ return 365 + $4db04d1051af0f2f$var$getLeapDay(date.year);
84
+ }
85
+ getYearsInEra(date) {
86
+ // 9999-12-31 gregorian is 9992-20-02 ethiopic.
87
+ // Round down to 9991 for the last full year.
88
+ // AA 9999-01-01 ethiopic is 4506-09-30 gregorian.
89
+ return date.era === "AA" ? 9999 : 9991;
90
+ }
91
+ getEras() {
92
+ return [
93
+ "AA",
94
+ "AM"
95
+ ];
96
+ }
97
+ constructor(){
98
+ this.identifier = "ethiopic";
99
+ }
100
+ }
101
+ class $4db04d1051af0f2f$export$d72e0c37005a4914 extends $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
102
+ fromJulianDay(jd) {
103
+ let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$ETHIOPIC_EPOCH, jd);
104
+ year += $4db04d1051af0f2f$var$AMETE_MIHRET_DELTA;
105
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, "AA", year, month, day);
106
+ }
107
+ getEras() {
108
+ return [
109
+ "AA"
110
+ ];
111
+ }
112
+ getYearsInEra() {
113
+ // 9999-13-04 ethioaa is the maximum date, which is equivalent to 4506-09-29 gregorian.
114
+ return 9999;
115
+ }
116
+ constructor(...args){
117
+ super(...args);
118
+ this.identifier = "ethioaa" // also known as 'ethiopic-amete-alem' in ICU
119
+ ;
120
+ }
121
+ }
122
+ class $4db04d1051af0f2f$export$fe6243cbe1a4b7c1 extends $4db04d1051af0f2f$export$26ba6eab5e20cd7d {
123
+ fromJulianDay(jd) {
124
+ let [year, month, day] = $4db04d1051af0f2f$var$julianDayToCE($4db04d1051af0f2f$var$COPTIC_EPOCH, jd);
125
+ let era = "CE";
126
+ if (year <= 0) {
127
+ era = "BCE";
128
+ year = 1 - year;
129
+ }
130
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, era, year, month, day);
131
+ }
132
+ toJulianDay(date) {
133
+ let year = date.year;
134
+ if (date.era === "BCE") year = 1 - year;
135
+ return $4db04d1051af0f2f$var$ceToJulianDay($4db04d1051af0f2f$var$COPTIC_EPOCH, year, date.month, date.day);
136
+ }
137
+ getDaysInMonth(date) {
138
+ let year = date.year;
139
+ if (date.era === "BCE") year = 1 - year;
140
+ return $4db04d1051af0f2f$var$getDaysInMonth(year, date.month);
141
+ }
142
+ isInverseEra(date) {
143
+ return date.era === "BCE";
144
+ }
145
+ balanceDate(date) {
146
+ if (date.year <= 0) {
147
+ date.era = date.era === "BCE" ? "CE" : "BCE";
148
+ date.year = 1 - date.year;
149
+ }
150
+ }
151
+ getEras() {
152
+ return [
153
+ "BCE",
154
+ "CE"
155
+ ];
156
+ }
157
+ getYearsInEra(date) {
158
+ // 9999-12-30 gregorian is 9716-02-20 coptic.
159
+ // Round down to 9715 for the last full year.
160
+ // BCE 9999-01-01 coptic is BC 9716-06-15 gregorian.
161
+ return date.era === "BCE" ? 9999 : 9715;
162
+ }
163
+ constructor(...args){
164
+ super(...args);
165
+ this.identifier = "coptic";
166
+ }
167
+ }
168
+
169
+
170
+ //# sourceMappingURL=EthiopicCalendar.main.js.map