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

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,81 @@
1
+ var $625ad1e1f4c43bc1$exports = require("./CalendarDate.main.js");
2
+ var $af14c9812fdceb33$exports = require("./GregorianCalendar.main.js");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "TaiwanCalendar", () => $9cc5d3577ec40243$export$65e01080afcb0799);
10
+ /*
11
+ * Copyright 2020 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */ // Portions of the code in this file are based on code from ICU.
21
+ // Original licensing can be found in the NOTICE file in the root directory of this source tree.
22
+
23
+
24
+ const $9cc5d3577ec40243$var$TAIWAN_ERA_START = 1911;
25
+ function $9cc5d3577ec40243$var$gregorianYear(date) {
26
+ return date.era === "minguo" ? date.year + $9cc5d3577ec40243$var$TAIWAN_ERA_START : 1 - date.year + $9cc5d3577ec40243$var$TAIWAN_ERA_START;
27
+ }
28
+ function $9cc5d3577ec40243$var$gregorianToTaiwan(year) {
29
+ let y = year - $9cc5d3577ec40243$var$TAIWAN_ERA_START;
30
+ if (y > 0) return [
31
+ "minguo",
32
+ y
33
+ ];
34
+ else return [
35
+ "before_minguo",
36
+ 1 - y
37
+ ];
38
+ }
39
+ class $9cc5d3577ec40243$export$65e01080afcb0799 extends (0, $af14c9812fdceb33$exports.GregorianCalendar) {
40
+ fromJulianDay(jd) {
41
+ let date = super.fromJulianDay(jd);
42
+ let extendedYear = (0, $af14c9812fdceb33$exports.getExtendedYear)(date.era, date.year);
43
+ let [era, year] = $9cc5d3577ec40243$var$gregorianToTaiwan(extendedYear);
44
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, era, year, date.month, date.day);
45
+ }
46
+ toJulianDay(date) {
47
+ return super.toJulianDay($9cc5d3577ec40243$var$toGregorian(date));
48
+ }
49
+ getEras() {
50
+ return [
51
+ "before_minguo",
52
+ "minguo"
53
+ ];
54
+ }
55
+ balanceDate(date) {
56
+ let [era, year] = $9cc5d3577ec40243$var$gregorianToTaiwan($9cc5d3577ec40243$var$gregorianYear(date));
57
+ date.era = era;
58
+ date.year = year;
59
+ }
60
+ isInverseEra(date) {
61
+ return date.era === "before_minguo";
62
+ }
63
+ getDaysInMonth(date) {
64
+ return super.getDaysInMonth($9cc5d3577ec40243$var$toGregorian(date));
65
+ }
66
+ getYearsInEra(date) {
67
+ return date.era === "before_minguo" ? 9999 : 9999 - $9cc5d3577ec40243$var$TAIWAN_ERA_START;
68
+ }
69
+ constructor(...args){
70
+ super(...args);
71
+ this.identifier = "roc" // Republic of China
72
+ ;
73
+ }
74
+ }
75
+ function $9cc5d3577ec40243$var$toGregorian(date) {
76
+ let [era, year] = (0, $af14c9812fdceb33$exports.fromExtendedYear)($9cc5d3577ec40243$var$gregorianYear(date));
77
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(era, year, date.month, date.day);
78
+ }
79
+
80
+
81
+ //# sourceMappingURL=TaiwanCalendar.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,2CAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,sCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAE;QACjC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAU;QACR,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAE;QAC1C,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;;aAjCA,aAAa,MAAO,oBAAoB;;;AAkC1C;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,0CAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,sCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.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\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras() {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.main.js.map"}
@@ -0,0 +1,76 @@
1
+ import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.mjs";
2
+ import {fromExtendedYear as $3b62074eb05584b2$export$4475b7e617eb123c, getExtendedYear as $3b62074eb05584b2$export$c36e0ecb2d4fa69d, GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */ // Portions of the code in this file are based on code from ICU.
15
+ // Original licensing can be found in the NOTICE file in the root directory of this source tree.
16
+
17
+
18
+ const $5f31bd6f0c8940b2$var$TAIWAN_ERA_START = 1911;
19
+ function $5f31bd6f0c8940b2$var$gregorianYear(date) {
20
+ return date.era === "minguo" ? date.year + $5f31bd6f0c8940b2$var$TAIWAN_ERA_START : 1 - date.year + $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
21
+ }
22
+ function $5f31bd6f0c8940b2$var$gregorianToTaiwan(year) {
23
+ let y = year - $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
24
+ if (y > 0) return [
25
+ "minguo",
26
+ y
27
+ ];
28
+ else return [
29
+ "before_minguo",
30
+ 1 - y
31
+ ];
32
+ }
33
+ class $5f31bd6f0c8940b2$export$65e01080afcb0799 extends (0, $3b62074eb05584b2$export$80ee6245ec4f29ec) {
34
+ fromJulianDay(jd) {
35
+ let date = super.fromJulianDay(jd);
36
+ let extendedYear = (0, $3b62074eb05584b2$export$c36e0ecb2d4fa69d)(date.era, date.year);
37
+ let [era, year] = $5f31bd6f0c8940b2$var$gregorianToTaiwan(extendedYear);
38
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, era, year, date.month, date.day);
39
+ }
40
+ toJulianDay(date) {
41
+ return super.toJulianDay($5f31bd6f0c8940b2$var$toGregorian(date));
42
+ }
43
+ getEras() {
44
+ return [
45
+ "before_minguo",
46
+ "minguo"
47
+ ];
48
+ }
49
+ balanceDate(date) {
50
+ let [era, year] = $5f31bd6f0c8940b2$var$gregorianToTaiwan($5f31bd6f0c8940b2$var$gregorianYear(date));
51
+ date.era = era;
52
+ date.year = year;
53
+ }
54
+ isInverseEra(date) {
55
+ return date.era === "before_minguo";
56
+ }
57
+ getDaysInMonth(date) {
58
+ return super.getDaysInMonth($5f31bd6f0c8940b2$var$toGregorian(date));
59
+ }
60
+ getYearsInEra(date) {
61
+ return date.era === "before_minguo" ? 9999 : 9999 - $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
62
+ }
63
+ constructor(...args){
64
+ super(...args);
65
+ this.identifier = "roc" // Republic of China
66
+ ;
67
+ }
68
+ }
69
+ function $5f31bd6f0c8940b2$var$toGregorian(date) {
70
+ let [era, year] = (0, $3b62074eb05584b2$export$4475b7e617eb123c)($5f31bd6f0c8940b2$var$gregorianYear(date));
71
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(era, year, date.month, date.day);
72
+ }
73
+
74
+
75
+ export {$5f31bd6f0c8940b2$export$65e01080afcb0799 as TaiwanCalendar};
76
+ //# sourceMappingURL=TaiwanCalendar.mjs.map
@@ -0,0 +1,76 @@
1
+ import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.module.js";
2
+ import {fromExtendedYear as $3b62074eb05584b2$export$4475b7e617eb123c, getExtendedYear as $3b62074eb05584b2$export$c36e0ecb2d4fa69d, GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.module.js";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */ // Portions of the code in this file are based on code from ICU.
15
+ // Original licensing can be found in the NOTICE file in the root directory of this source tree.
16
+
17
+
18
+ const $5f31bd6f0c8940b2$var$TAIWAN_ERA_START = 1911;
19
+ function $5f31bd6f0c8940b2$var$gregorianYear(date) {
20
+ return date.era === "minguo" ? date.year + $5f31bd6f0c8940b2$var$TAIWAN_ERA_START : 1 - date.year + $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
21
+ }
22
+ function $5f31bd6f0c8940b2$var$gregorianToTaiwan(year) {
23
+ let y = year - $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
24
+ if (y > 0) return [
25
+ "minguo",
26
+ y
27
+ ];
28
+ else return [
29
+ "before_minguo",
30
+ 1 - y
31
+ ];
32
+ }
33
+ class $5f31bd6f0c8940b2$export$65e01080afcb0799 extends (0, $3b62074eb05584b2$export$80ee6245ec4f29ec) {
34
+ fromJulianDay(jd) {
35
+ let date = super.fromJulianDay(jd);
36
+ let extendedYear = (0, $3b62074eb05584b2$export$c36e0ecb2d4fa69d)(date.era, date.year);
37
+ let [era, year] = $5f31bd6f0c8940b2$var$gregorianToTaiwan(extendedYear);
38
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, era, year, date.month, date.day);
39
+ }
40
+ toJulianDay(date) {
41
+ return super.toJulianDay($5f31bd6f0c8940b2$var$toGregorian(date));
42
+ }
43
+ getEras() {
44
+ return [
45
+ "before_minguo",
46
+ "minguo"
47
+ ];
48
+ }
49
+ balanceDate(date) {
50
+ let [era, year] = $5f31bd6f0c8940b2$var$gregorianToTaiwan($5f31bd6f0c8940b2$var$gregorianYear(date));
51
+ date.era = era;
52
+ date.year = year;
53
+ }
54
+ isInverseEra(date) {
55
+ return date.era === "before_minguo";
56
+ }
57
+ getDaysInMonth(date) {
58
+ return super.getDaysInMonth($5f31bd6f0c8940b2$var$toGregorian(date));
59
+ }
60
+ getYearsInEra(date) {
61
+ return date.era === "before_minguo" ? 9999 : 9999 - $5f31bd6f0c8940b2$var$TAIWAN_ERA_START;
62
+ }
63
+ constructor(...args){
64
+ super(...args);
65
+ this.identifier = "roc" // Republic of China
66
+ ;
67
+ }
68
+ }
69
+ function $5f31bd6f0c8940b2$var$toGregorian(date) {
70
+ let [era, year] = (0, $3b62074eb05584b2$export$4475b7e617eb123c)($5f31bd6f0c8940b2$var$gregorianYear(date));
71
+ return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(era, year, date.month, date.day);
72
+ }
73
+
74
+
75
+ export {$5f31bd6f0c8940b2$export$65e01080afcb0799 as TaiwanCalendar};
76
+ //# sourceMappingURL=TaiwanCalendar.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAOhG,MAAM,yCAAmB;AAEzB,SAAS,oCAAc,IAAqB;IAC1C,OAAO,KAAK,GAAG,KAAK,WAChB,KAAK,IAAI,GAAG,yCACZ,IAAI,KAAK,IAAI,GAAG;AACtB;AAEA,SAAS,wCAAkB,IAAY;IACrC,IAAI,IAAI,OAAO;IACf,IAAI,IAAI,GACN,OAAO;QAAC;QAAU;KAAE;SAEpB,OAAO;QAAC;QAAiB,IAAI;KAAE;AAEnC;AAOO,MAAM,kDAAuB,CAAA,GAAA,yCAAgB;IAGlD,cAAc,EAAU,EAAgB;QACtC,IAAI,OAAO,KAAK,CAAC,cAAc;QAC/B,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI;QACtD,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB;QACpC,OAAO,IAAI,CAAA,GAAA,yCAAW,EAAE,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,EAAE,KAAK,GAAG;IAC/D;IAEA,YAAY,IAAqB,EAAE;QACjC,OAAO,KAAK,CAAC,YAAY,kCAAY;IACvC;IAEA,UAAU;QACR,OAAO;YAAC;YAAiB;SAAS;IACpC;IAEA,YAAY,IAA8B,EAAE;QAC1C,IAAI,CAAC,KAAK,KAAK,GAAG,wCAAkB,oCAAc;QAClD,KAAK,GAAG,GAAG;QACX,KAAK,IAAI,GAAG;IACd;IAEA,aAAa,IAAqB,EAAW;QAC3C,OAAO,KAAK,GAAG,KAAK;IACtB;IAEA,eAAe,IAAqB,EAAU;QAC5C,OAAO,KAAK,CAAC,eAAe,kCAAY;IAC1C;IAEA,cAAc,IAAqB,EAAU;QAC3C,OAAO,KAAK,GAAG,KAAK,kBAAkB,OAAO,OAAO;IACtD;;;aAjCA,aAAa,MAAO,oBAAoB;;;AAkC1C;AAEA,SAAS,kCAAY,IAAqB;IACxC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAA,GAAA,yCAAe,EAAE,oCAAc;IACjD,OAAO,IAAI,CAAA,GAAA,yCAAW,EACpB,KACA,MACA,KAAK,KAAK,EACV,KAAK,GAAG;AAEZ","sources":["packages/@internationalized/date/src/calendars/TaiwanCalendar.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\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {fromExtendedYear, getExtendedYear, GregorianCalendar} from './GregorianCalendar';\nimport {Mutable} from '../utils';\n\nconst TAIWAN_ERA_START = 1911;\n\nfunction gregorianYear(date: AnyCalendarDate) {\n return date.era === 'minguo'\n ? date.year + TAIWAN_ERA_START\n : 1 - date.year + TAIWAN_ERA_START;\n}\n\nfunction gregorianToTaiwan(year: number): [string, number] {\n let y = year - TAIWAN_ERA_START;\n if (y > 0) {\n return ['minguo', y];\n } else {\n return ['before_minguo', 1 - y];\n }\n}\n\n/**\n * The Taiwanese calendar is the same as the Gregorian calendar, but years\n * are numbered starting from 1912 (Gregorian). Two eras are supported:\n * 'before_minguo' and 'minguo'.\n */\nexport class TaiwanCalendar extends GregorianCalendar {\n identifier = 'roc'; // Republic of China\n\n fromJulianDay(jd: number): CalendarDate {\n let date = super.fromJulianDay(jd);\n let extendedYear = getExtendedYear(date.era, date.year);\n let [era, year] = gregorianToTaiwan(extendedYear);\n return new CalendarDate(this, era, year, date.month, date.day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n return super.toJulianDay(toGregorian(date));\n }\n\n getEras() {\n return ['before_minguo', 'minguo'];\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n let [era, year] = gregorianToTaiwan(gregorianYear(date));\n date.era = era;\n date.year = year;\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'before_minguo';\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return super.getDaysInMonth(toGregorian(date));\n }\n\n getYearsInEra(date: AnyCalendarDate): number {\n return date.era === 'before_minguo' ? 9999 : 9999 - TAIWAN_ERA_START;\n }\n}\n\nfunction toGregorian(date: AnyCalendarDate) {\n let [era, year] = fromExtendedYear(gregorianYear(date));\n return new CalendarDate(\n era,\n year,\n date.month,\n date.day\n );\n}\n"],"names":[],"version":3,"file":"TaiwanCalendar.module.js.map"}
@@ -0,0 +1,236 @@
1
+ var $625ad1e1f4c43bc1$exports = require("./CalendarDate.main.js");
2
+ var $5c0571aa5b6fb5da$exports = require("./manipulation.main.js");
3
+ var $af14c9812fdceb33$exports = require("./GregorianCalendar.main.js");
4
+ var $1f0f7ebf1ae6c530$exports = require("./queries.main.js");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "epochFromDate", () => $4ae0260a69729f1d$export$bd4fb2bc8bb06fb);
12
+ $parcel$export(module.exports, "toCalendar", () => $4ae0260a69729f1d$export$b4a036af3fc0b032);
13
+ $parcel$export(module.exports, "possibleAbsolutes", () => $4ae0260a69729f1d$export$136f38efe7caf549);
14
+ $parcel$export(module.exports, "toAbsolute", () => $4ae0260a69729f1d$export$5107c82f94518f5c);
15
+ $parcel$export(module.exports, "toCalendarDateTime", () => $4ae0260a69729f1d$export$b21e0b124e224484);
16
+ $parcel$export(module.exports, "toDate", () => $4ae0260a69729f1d$export$e67a095c620b86fe);
17
+ $parcel$export(module.exports, "fromAbsolute", () => $4ae0260a69729f1d$export$1b96692a1ba042ac);
18
+ $parcel$export(module.exports, "fromDate", () => $4ae0260a69729f1d$export$e57ff100d91bd4b9);
19
+ $parcel$export(module.exports, "toCalendarDate", () => $4ae0260a69729f1d$export$93522d1a439f3617);
20
+ $parcel$export(module.exports, "toTime", () => $4ae0260a69729f1d$export$d33f79e3ffc3dc83);
21
+ $parcel$export(module.exports, "toZoned", () => $4ae0260a69729f1d$export$84c95a83c799e074);
22
+ $parcel$export(module.exports, "toTimeZone", () => $4ae0260a69729f1d$export$538b00033cc11c75);
23
+ $parcel$export(module.exports, "zonedToDate", () => $4ae0260a69729f1d$export$83aac07b4c37b25);
24
+ $parcel$export(module.exports, "toLocalTimeZone", () => $4ae0260a69729f1d$export$d9b67bc93c097491);
25
+ /*
26
+ * Copyright 2020 Adobe. All rights reserved.
27
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
+ * you may not use this file except in compliance with the License. You may obtain a copy
29
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software distributed under
32
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
+ * OF ANY KIND, either express or implied. See the License for the specific language
34
+ * governing permissions and limitations under the License.
35
+ */ // Portions of the code in this file are based on code from the TC39 Temporal proposal.
36
+ // Original licensing can be found in the NOTICE file in the root directory of this source tree.
37
+
38
+
39
+
40
+
41
+ function $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(date) {
42
+ date = $4ae0260a69729f1d$export$b4a036af3fc0b032(date, new (0, $af14c9812fdceb33$exports.GregorianCalendar)());
43
+ let year = (0, $af14c9812fdceb33$exports.getExtendedYear)(date.era, date.year);
44
+ return $4ae0260a69729f1d$var$epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
45
+ }
46
+ function $4ae0260a69729f1d$var$epochFromParts(year, month, day, hour, minute, second, millisecond) {
47
+ // Note: Date.UTC() interprets one and two-digit years as being in the
48
+ // 20th century, so don't use it
49
+ let date = new Date();
50
+ date.setUTCHours(hour, minute, second, millisecond);
51
+ date.setUTCFullYear(year, month - 1, day);
52
+ return date.getTime();
53
+ }
54
+ function $4ae0260a69729f1d$export$59c99f3515d3493f(ms, timeZone) {
55
+ // Fast path for UTC.
56
+ if (timeZone === "UTC") return 0;
57
+ // Fast path: for local timezone after 1970, use native Date.
58
+ if (ms > 0 && timeZone === (0, $1f0f7ebf1ae6c530$exports.getLocalTimeZone)()) return new Date(ms).getTimezoneOffset() * -60000;
59
+ let { year: year, month: month, day: day, hour: hour, minute: minute, second: second } = $4ae0260a69729f1d$var$getTimeZoneParts(ms, timeZone);
60
+ let utc = $4ae0260a69729f1d$var$epochFromParts(year, month, day, hour, minute, second, 0);
61
+ return utc - Math.floor(ms / 1000) * 1000;
62
+ }
63
+ const $4ae0260a69729f1d$var$formattersByTimeZone = new Map();
64
+ function $4ae0260a69729f1d$var$getTimeZoneParts(ms, timeZone) {
65
+ let formatter = $4ae0260a69729f1d$var$formattersByTimeZone.get(timeZone);
66
+ if (!formatter) {
67
+ formatter = new Intl.DateTimeFormat("en-US", {
68
+ timeZone: timeZone,
69
+ hour12: false,
70
+ era: "short",
71
+ year: "numeric",
72
+ month: "numeric",
73
+ day: "numeric",
74
+ hour: "numeric",
75
+ minute: "numeric",
76
+ second: "numeric"
77
+ });
78
+ $4ae0260a69729f1d$var$formattersByTimeZone.set(timeZone, formatter);
79
+ }
80
+ let parts = formatter.formatToParts(new Date(ms));
81
+ let namedParts = {};
82
+ for (let part of parts)if (part.type !== "literal") namedParts[part.type] = part.value;
83
+ return {
84
+ // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
85
+ year: namedParts.era === "BC" || namedParts.era === "B" ? -namedParts.year + 1 : +namedParts.year,
86
+ month: +namedParts.month,
87
+ day: +namedParts.day,
88
+ hour: namedParts.hour === "24" ? 0 : +namedParts.hour,
89
+ minute: +namedParts.minute,
90
+ second: +namedParts.second
91
+ };
92
+ }
93
+ const $4ae0260a69729f1d$var$DAYMILLIS = 86400000;
94
+ function $4ae0260a69729f1d$export$136f38efe7caf549(date, timeZone) {
95
+ let ms = $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(date);
96
+ let earlier = ms - $4ae0260a69729f1d$export$59c99f3515d3493f(ms - $4ae0260a69729f1d$var$DAYMILLIS, timeZone);
97
+ let later = ms - $4ae0260a69729f1d$export$59c99f3515d3493f(ms + $4ae0260a69729f1d$var$DAYMILLIS, timeZone);
98
+ return $4ae0260a69729f1d$var$getValidWallTimes(date, timeZone, earlier, later);
99
+ }
100
+ function $4ae0260a69729f1d$var$getValidWallTimes(date, timeZone, earlier, later) {
101
+ let found = earlier === later ? [
102
+ earlier
103
+ ] : [
104
+ earlier,
105
+ later
106
+ ];
107
+ return found.filter((absolute)=>$4ae0260a69729f1d$var$isValidWallTime(date, timeZone, absolute));
108
+ }
109
+ function $4ae0260a69729f1d$var$isValidWallTime(date, timeZone, absolute) {
110
+ let parts = $4ae0260a69729f1d$var$getTimeZoneParts(absolute, timeZone);
111
+ return date.year === parts.year && date.month === parts.month && date.day === parts.day && date.hour === parts.hour && date.minute === parts.minute && date.second === parts.second;
112
+ }
113
+ function $4ae0260a69729f1d$export$5107c82f94518f5c(date, timeZone, disambiguation = "compatible") {
114
+ let dateTime = $4ae0260a69729f1d$export$b21e0b124e224484(date);
115
+ // Fast path: if the time zone is UTC, use native Date.
116
+ if (timeZone === "UTC") return $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(dateTime);
117
+ // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.
118
+ if (timeZone === (0, $1f0f7ebf1ae6c530$exports.getLocalTimeZone)() && disambiguation === "compatible") {
119
+ dateTime = $4ae0260a69729f1d$export$b4a036af3fc0b032(dateTime, new (0, $af14c9812fdceb33$exports.GregorianCalendar)());
120
+ // Don't use Date constructor here because two-digit years are interpreted in the 20th century.
121
+ let date = new Date();
122
+ let year = (0, $af14c9812fdceb33$exports.getExtendedYear)(dateTime.era, dateTime.year);
123
+ date.setFullYear(year, dateTime.month - 1, dateTime.day);
124
+ date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
125
+ return date.getTime();
126
+ }
127
+ let ms = $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(dateTime);
128
+ let offsetBefore = $4ae0260a69729f1d$export$59c99f3515d3493f(ms - $4ae0260a69729f1d$var$DAYMILLIS, timeZone);
129
+ let offsetAfter = $4ae0260a69729f1d$export$59c99f3515d3493f(ms + $4ae0260a69729f1d$var$DAYMILLIS, timeZone);
130
+ let valid = $4ae0260a69729f1d$var$getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);
131
+ if (valid.length === 1) return valid[0];
132
+ if (valid.length > 1) switch(disambiguation){
133
+ // 'compatible' means 'earlier' for "fall back" transitions
134
+ case "compatible":
135
+ case "earlier":
136
+ return valid[0];
137
+ case "later":
138
+ return valid[valid.length - 1];
139
+ case "reject":
140
+ throw new RangeError("Multiple possible absolute times found");
141
+ }
142
+ switch(disambiguation){
143
+ case "earlier":
144
+ return Math.min(ms - offsetBefore, ms - offsetAfter);
145
+ // 'compatible' means 'later' for "spring forward" transitions
146
+ case "compatible":
147
+ case "later":
148
+ return Math.max(ms - offsetBefore, ms - offsetAfter);
149
+ case "reject":
150
+ throw new RangeError("No such absolute time found");
151
+ }
152
+ }
153
+ function $4ae0260a69729f1d$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = "compatible") {
154
+ return new Date($4ae0260a69729f1d$export$5107c82f94518f5c(dateTime, timeZone, disambiguation));
155
+ }
156
+ function $4ae0260a69729f1d$export$1b96692a1ba042ac(ms, timeZone) {
157
+ let offset = $4ae0260a69729f1d$export$59c99f3515d3493f(ms, timeZone);
158
+ let date = new Date(ms + offset);
159
+ let year = date.getUTCFullYear();
160
+ let month = date.getUTCMonth() + 1;
161
+ let day = date.getUTCDate();
162
+ let hour = date.getUTCHours();
163
+ let minute = date.getUTCMinutes();
164
+ let second = date.getUTCSeconds();
165
+ let millisecond = date.getUTCMilliseconds();
166
+ return new (0, $625ad1e1f4c43bc1$exports.ZonedDateTime)(year, month, day, timeZone, offset, hour, minute, second, millisecond);
167
+ }
168
+ function $4ae0260a69729f1d$export$e57ff100d91bd4b9(date, timeZone) {
169
+ return $4ae0260a69729f1d$export$1b96692a1ba042ac(date.getTime(), timeZone);
170
+ }
171
+ function $4ae0260a69729f1d$export$d7f92bcd3596b086(date) {
172
+ return $4ae0260a69729f1d$export$e57ff100d91bd4b9(date, (0, $1f0f7ebf1ae6c530$exports.getLocalTimeZone)());
173
+ }
174
+ function $4ae0260a69729f1d$export$93522d1a439f3617(dateTime) {
175
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);
176
+ }
177
+ function $4ae0260a69729f1d$export$6f4d78149f3f53ac(date) {
178
+ return {
179
+ era: date.era,
180
+ year: date.year,
181
+ month: date.month,
182
+ day: date.day
183
+ };
184
+ }
185
+ function $4ae0260a69729f1d$export$4d0393e732857be5(date) {
186
+ return {
187
+ hour: date.hour,
188
+ minute: date.minute,
189
+ second: date.second,
190
+ millisecond: date.millisecond
191
+ };
192
+ }
193
+ function $4ae0260a69729f1d$export$b21e0b124e224484(date, time) {
194
+ let hour = 0, minute = 0, second = 0, millisecond = 0;
195
+ if ("timeZone" in date) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = date);
196
+ else if ("hour" in date && !time) return date;
197
+ if (time) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = time);
198
+ return new (0, $625ad1e1f4c43bc1$exports.CalendarDateTime)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond);
199
+ }
200
+ function $4ae0260a69729f1d$export$d33f79e3ffc3dc83(dateTime) {
201
+ return new (0, $625ad1e1f4c43bc1$exports.Time)(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);
202
+ }
203
+ function $4ae0260a69729f1d$export$b4a036af3fc0b032(date, calendar) {
204
+ if (date.calendar.identifier === calendar.identifier) return date;
205
+ let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));
206
+ let copy = date.copy();
207
+ copy.calendar = calendar;
208
+ copy.era = calendarDate.era;
209
+ copy.year = calendarDate.year;
210
+ copy.month = calendarDate.month;
211
+ copy.day = calendarDate.day;
212
+ (0, $5c0571aa5b6fb5da$exports.constrain)(copy);
213
+ return copy;
214
+ }
215
+ function $4ae0260a69729f1d$export$84c95a83c799e074(date, timeZone, disambiguation) {
216
+ if (date instanceof (0, $625ad1e1f4c43bc1$exports.ZonedDateTime)) {
217
+ if (date.timeZone === timeZone) return date;
218
+ return $4ae0260a69729f1d$export$538b00033cc11c75(date, timeZone);
219
+ }
220
+ let ms = $4ae0260a69729f1d$export$5107c82f94518f5c(date, timeZone, disambiguation);
221
+ return $4ae0260a69729f1d$export$1b96692a1ba042ac(ms, timeZone);
222
+ }
223
+ function $4ae0260a69729f1d$export$83aac07b4c37b25(date) {
224
+ let ms = $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(date) - date.offset;
225
+ return new Date(ms);
226
+ }
227
+ function $4ae0260a69729f1d$export$538b00033cc11c75(date, timeZone) {
228
+ let ms = $4ae0260a69729f1d$export$bd4fb2bc8bb06fb(date) - date.offset;
229
+ return $4ae0260a69729f1d$export$b4a036af3fc0b032($4ae0260a69729f1d$export$1b96692a1ba042ac(ms, timeZone), date.calendar);
230
+ }
231
+ function $4ae0260a69729f1d$export$d9b67bc93c097491(date) {
232
+ return $4ae0260a69729f1d$export$538b00033cc11c75(date, (0, $1f0f7ebf1ae6c530$exports.getLocalTimeZone)());
233
+ }
234
+
235
+
236
+ //# sourceMapp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BAAgB,CAAA,GAAA,uCAAY,GAAG;QACjC,IAAI,KAAK,QAAQ,KAAK,UACpB,OAAO;QAGT,OAAO,0CAAW,MAAM;IAC1B;IAEA,IAAI,KAAK,0CAAW,MAAM,UAAU;IACpC,OAAO,0CAAa,IAAI;AAC1B;AAEO,SAAS,yCAAY,IAAmB;IAC7C,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,IAAI,KAAK;AAClB;AAGO,SAAS,0CAAW,IAAmB,EAAE,QAAgB;IAC9D,IAAI,KAAK,yCAAc,QAAQ,KAAK,MAAM;IAC1C,OAAO,0CAAW,0CAAa,IAAI,WAAW,KAAK,QAAQ;AAC7D;AAGO,SAAS,0CAAgB,IAAmB;IACjD,OAAO,0CAAW,MAAM,CAAA,GAAA,0CAAe;AACzC","sources":["packages/@internationalized/date/src/conversion.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\n// Portions of the code in this file are based on code from the TC39 Temporal proposal.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, AnyDateTime, AnyTime, Calendar, DateFields, Disambiguation, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {constrain} from './manipulation';\nimport {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar';\nimport {getLocalTimeZone} from './queries';\nimport {Mutable} from './utils';\n\nexport function epochFromDate(date: AnyDateTime) {\n date = toCalendar(date, new GregorianCalendar());\n let year = getExtendedYear(date.era, date.year);\n return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);\n}\n\nfunction epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number) {\n // Note: Date.UTC() interprets one and two-digit years as being in the\n // 20th century, so don't use it\n let date = new Date();\n date.setUTCHours(hour, minute, second, millisecond);\n date.setUTCFullYear(year, month - 1, day);\n return date.getTime();\n}\n\nexport function getTimeZoneOffset(ms: number, timeZone: string) {\n // Fast path for UTC.\n if (timeZone === 'UTC') {\n return 0;\n }\n\n // Fast path: for local timezone after 1970, use native Date.\n if (ms > 0 && timeZone === getLocalTimeZone()) {\n return new Date(ms).getTimezoneOffset() * -60 * 1000;\n }\n\n let {year, month, day, hour, minute, second} = getTimeZoneParts(ms, timeZone);\n let utc = epochFromParts(year, month, day, hour, minute, second, 0);\n return utc - Math.floor(ms / 1000) * 1000;\n}\n\nconst formattersByTimeZone = new Map<string, Intl.DateTimeFormat>();\n\nfunction getTimeZoneParts(ms: number, timeZone: string) {\n let formatter = formattersByTimeZone.get(timeZone);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone,\n hour12: false,\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n });\n\n formattersByTimeZone.set(timeZone, formatter);\n }\n\n let parts = formatter.formatToParts(new Date(ms));\n let namedParts: {[name: string]: string} = {};\n for (let part of parts) {\n if (part.type !== 'literal') {\n namedParts[part.type] = part.value;\n }\n }\n\n\n return {\n // Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253\n year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,\n month: +namedParts.month,\n day: +namedParts.day,\n hour: namedParts.hour === '24' ? 0 : +namedParts.hour, // bugs.chromium.org/p/chromium/issues/detail?id=1045791\n minute: +namedParts.minute,\n second: +namedParts.second\n };\n}\n\nconst DAYMILLIS = 86400000;\n\nexport function possibleAbsolutes(date: CalendarDateTime, timeZone: string): number[] {\n let ms = epochFromDate(date);\n let earlier = ms - getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let later = ms - getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n return getValidWallTimes(date, timeZone, earlier, later);\n}\n\nfunction getValidWallTimes(date: CalendarDateTime, timeZone: string, earlier: number, later: number): number[] {\n let found = earlier === later ? [earlier] : [earlier, later];\n return found.filter(absolute => isValidWallTime(date, timeZone, absolute));\n}\n\nfunction isValidWallTime(date: CalendarDateTime, timeZone: string, absolute: number) {\n let parts = getTimeZoneParts(absolute, timeZone);\n return date.year === parts.year\n && date.month === parts.month\n && date.day === parts.day\n && date.hour === parts.hour\n && date.minute === parts.minute\n && date.second === parts.second;\n}\n\nexport function toAbsolute(date: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): number {\n let dateTime = toCalendarDateTime(date);\n\n // Fast path: if the time zone is UTC, use native Date.\n if (timeZone === 'UTC') {\n return epochFromDate(dateTime);\n }\n\n // Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.\n if (timeZone === getLocalTimeZone() && disambiguation === 'compatible') {\n dateTime = toCalendar(dateTime, new GregorianCalendar());\n\n // Don't use Date constructor here because two-digit years are interpreted in the 20th century.\n let date = new Date();\n let year = getExtendedYear(dateTime.era, dateTime.year);\n date.setFullYear(year, dateTime.month - 1, dateTime.day);\n date.setHours(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n return date.getTime();\n }\n\n let ms = epochFromDate(dateTime);\n let offsetBefore = getTimeZoneOffset(ms - DAYMILLIS, timeZone);\n let offsetAfter = getTimeZoneOffset(ms + DAYMILLIS, timeZone);\n let valid = getValidWallTimes(dateTime, timeZone, ms - offsetBefore, ms - offsetAfter);\n\n if (valid.length === 1) {\n return valid[0];\n }\n\n if (valid.length > 1) {\n switch (disambiguation) {\n // 'compatible' means 'earlier' for \"fall back\" transitions\n case 'compatible':\n case 'earlier':\n return valid[0];\n case 'later':\n return valid[valid.length - 1];\n case 'reject':\n throw new RangeError('Multiple possible absolute times found');\n }\n }\n\n switch (disambiguation) {\n case 'earlier':\n return Math.min(ms - offsetBefore, ms - offsetAfter);\n // 'compatible' means 'later' for \"spring forward\" transitions\n case 'compatible':\n case 'later':\n return Math.max(ms - offsetBefore, ms - offsetAfter);\n case 'reject':\n throw new RangeError('No such absolute time found');\n }\n}\n\nexport function toDate(dateTime: CalendarDate | CalendarDateTime, timeZone: string, disambiguation: Disambiguation = 'compatible'): Date {\n return new Date(toAbsolute(dateTime, timeZone, disambiguation));\n}\n\n/**\n * Takes a Unix epoch (milliseconds since 1970) and converts it to the provided time zone.\n */\nexport function fromAbsolute(ms: number, timeZone: string): ZonedDateTime {\n let offset = getTimeZoneOffset(ms, timeZone);\n let date = new Date(ms + offset);\n let year = date.getUTCFullYear();\n let month = date.getUTCMonth() + 1;\n let day = date.getUTCDate();\n let hour = date.getUTCHours();\n let minute = date.getUTCMinutes();\n let second = date.getUTCSeconds();\n let millisecond = date.getUTCMilliseconds();\n\n return new ZonedDateTime(year, month, day, timeZone, offset, hour, minute, second, millisecond);\n}\n\n/**\n * Takes a `Date` object and converts it to the provided time zone.\n */\nexport function fromDate(date: Date, timeZone: string): ZonedDateTime {\n return fromAbsolute(date.getTime(), timeZone);\n}\n\nexport function fromDateToLocal(date: Date): ZonedDateTime {\n return fromDate(date, getLocalTimeZone());\n}\n\n/** Converts a value with date components such as a `CalendarDateTime` or `ZonedDateTime` into a `CalendarDate`. */\nexport function toCalendarDate(dateTime: AnyCalendarDate): CalendarDate {\n return new CalendarDate(dateTime.calendar, dateTime.era, dateTime.year, dateTime.month, dateTime.day);\n}\n\nexport function toDateFields(date: AnyCalendarDate): DateFields {\n return {\n era: date.era,\n year: date.year,\n month: date.month,\n day: date.day\n };\n}\n\nexport function toTimeFields(date: AnyTime): TimeFields {\n return {\n hour: date.hour,\n minute: date.minute,\n second: date.second,\n millisecond: date.millisecond\n };\n}\n\n/**\n * Converts a date value to a `CalendarDateTime`. An optional `Time` value can be passed to set the time\n * of the resulting value, otherwise it will default to midnight.\n */\nexport function toCalendarDateTime(date: CalendarDate | CalendarDateTime | ZonedDateTime, time?: AnyTime): CalendarDateTime {\n let hour = 0, minute = 0, second = 0, millisecond = 0;\n if ('timeZone' in date) {\n ({hour, minute, second, millisecond} = date);\n } else if ('hour' in date && !time) {\n return date;\n }\n\n if (time) {\n ({hour, minute, second, millisecond} = time);\n }\n\n return new CalendarDateTime(\n date.calendar,\n date.era,\n date.year,\n date.month,\n date.day,\n hour,\n minute,\n second,\n millisecond\n );\n}\n\n/** Extracts the time components from a value containing a date and time. */\nexport function toTime(dateTime: CalendarDateTime | ZonedDateTime): Time {\n return new Time(dateTime.hour, dateTime.minute, dateTime.second, dateTime.millisecond);\n}\n\n/** Converts a date from one calendar system to another. */\nexport function toCalendar<T extends AnyCalendarDate>(date: T, calendar: Calendar): T {\n if (date.calendar.identifier === calendar.identifier) {\n return date;\n }\n\n let calendarDate = calendar.fromJulianDay(date.calendar.toJulianDay(date));\n let copy: Mutable<T> = date.copy();\n copy.calendar = calendar;\n copy.era = calendarDate.era;\n copy.year = calendarDate.year;\n copy.month = calendarDate.month;\n copy.day = calendarDate.day;\n constrain(copy);\n return copy;\n}\n\n/**\n * Converts a date value to a `ZonedDateTime` in the provided time zone. The `disambiguation` option can be set\n * to control how values that fall on daylight saving time changes are interpreted.\n */\nexport function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime {\n if (date instanceof ZonedDateTime) {\n if (date.timeZone === timeZone) {\n return date;\n }\n\n return toTimeZone(date, timeZone);\n }\n\n let ms = toAbsolute(date, timeZone, disambiguation);\n return fromAbsolute(ms, timeZone);\n}\n\nexport function zonedToDate(date: ZonedDateTime) {\n let ms = epochFromDate(date) - date.offset;\n return new Date(ms);\n}\n\n/** Converts a `ZonedDateTime` from one time zone to another. */\nexport function toTimeZone(date: ZonedDateTime, timeZone: string): ZonedDateTime {\n let ms = epochFromDate(date) - date.offset;\n return toCalendar(fromAbsolute(ms, timeZone), date.calendar);\n}\n\n/** Converts the given `ZonedDateTime` into the user's local time zone. */\nexport function toLocalTimeZone(date: ZonedDateTime): ZonedDateTime {\n return toTimeZone(date, getLocalTimeZone());\n}\n"],"names":[],"version":3,"file":"conversion.main.js.map"}