@internationalized/date 3.12.0 → 3.12.1

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 (165) hide show
  1. package/dist/index.cjs +113 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.js +45 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +45 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/{CalendarDate.main.js → private/CalendarDate.cjs} +102 -120
  8. package/dist/private/CalendarDate.cjs.map +1 -0
  9. package/dist/{CalendarDate.mjs → private/CalendarDate.js} +65 -65
  10. package/dist/private/CalendarDate.js.map +1 -0
  11. package/dist/{CalendarDate.module.js → private/CalendarDate.mjs} +99 -117
  12. package/dist/private/CalendarDate.mjs.map +1 -0
  13. package/dist/{DateFormatter.main.js → private/DateFormatter.cjs} +27 -27
  14. package/dist/private/DateFormatter.cjs.map +1 -0
  15. package/dist/{DateFormatter.module.js → private/DateFormatter.js} +23 -23
  16. package/dist/{DateFormatter.module.js.map → private/DateFormatter.js.map} +1 -1
  17. package/dist/{DateFormatter.mjs → private/DateFormatter.mjs} +27 -27
  18. package/dist/private/DateFormatter.mjs.map +1 -0
  19. package/dist/{BuddhistCalendar.main.js → private/calendars/BuddhistCalendar.cjs} +13 -13
  20. package/dist/{BuddhistCalendar.main.js.map → private/calendars/BuddhistCalendar.cjs.map} +1 -1
  21. package/dist/{BuddhistCalendar.module.js → private/calendars/BuddhistCalendar.js} +13 -13
  22. package/dist/{BuddhistCalendar.module.js.map → private/calendars/BuddhistCalendar.js.map} +1 -1
  23. package/dist/{BuddhistCalendar.mjs → private/calendars/BuddhistCalendar.mjs} +13 -13
  24. package/dist/private/calendars/BuddhistCalendar.mjs.map +1 -0
  25. package/dist/{EthiopicCalendar.main.js → private/calendars/EthiopicCalendar.cjs} +32 -32
  26. package/dist/{EthiopicCalendar.main.js.map → private/calendars/EthiopicCalendar.cjs.map} +1 -1
  27. package/dist/{EthiopicCalendar.module.js → private/calendars/EthiopicCalendar.js} +30 -30
  28. package/dist/{EthiopicCalendar.module.js.map → private/calendars/EthiopicCalendar.js.map} +1 -1
  29. package/dist/{EthiopicCalendar.mjs → private/calendars/EthiopicCalendar.mjs} +30 -30
  30. package/dist/private/calendars/EthiopicCalendar.mjs.map +1 -0
  31. package/dist/{GregorianCalendar.main.js → private/calendars/GregorianCalendar.cjs} +31 -31
  32. package/dist/{GregorianCalendar.main.js.map → private/calendars/GregorianCalendar.cjs.map} +1 -1
  33. package/dist/{GregorianCalendar.module.js → private/calendars/GregorianCalendar.js} +27 -27
  34. package/dist/{GregorianCalendar.module.js.map → private/calendars/GregorianCalendar.js.map} +1 -1
  35. package/dist/{GregorianCalendar.mjs → private/calendars/GregorianCalendar.mjs} +27 -27
  36. package/dist/private/calendars/GregorianCalendar.mjs.map +1 -0
  37. package/dist/{HebrewCalendar.main.js → private/calendars/HebrewCalendar.cjs} +44 -44
  38. package/dist/{HebrewCalendar.main.js.map → private/calendars/HebrewCalendar.cjs.map} +1 -1
  39. package/dist/{HebrewCalendar.module.js → private/calendars/HebrewCalendar.js} +44 -44
  40. package/dist/{HebrewCalendar.module.js.map → private/calendars/HebrewCalendar.js.map} +1 -1
  41. package/dist/{HebrewCalendar.mjs → private/calendars/HebrewCalendar.mjs} +44 -44
  42. package/dist/private/calendars/HebrewCalendar.mjs.map +1 -0
  43. package/dist/{IndianCalendar.main.js → private/calendars/IndianCalendar.cjs} +20 -20
  44. package/dist/{IndianCalendar.main.js.map → private/calendars/IndianCalendar.cjs.map} +1 -1
  45. package/dist/{IndianCalendar.module.js → private/calendars/IndianCalendar.js} +20 -20
  46. package/dist/{IndianCalendar.module.js.map → private/calendars/IndianCalendar.js.map} +1 -1
  47. package/dist/{IndianCalendar.mjs → private/calendars/IndianCalendar.mjs} +20 -20
  48. package/dist/private/calendars/IndianCalendar.mjs.map +1 -0
  49. package/dist/private/calendars/IslamicCalendar.cjs +168 -0
  50. package/dist/private/calendars/IslamicCalendar.cjs.map +1 -0
  51. package/dist/private/calendars/IslamicCalendar.js +161 -0
  52. package/dist/{IslamicCalendar.module.js.map → private/calendars/IslamicCalendar.js.map} +1 -1
  53. package/dist/private/calendars/IslamicCalendar.mjs +161 -0
  54. package/dist/private/calendars/IslamicCalendar.mjs.map +1 -0
  55. package/dist/{JapaneseCalendar.main.js → private/calendars/JapaneseCalendar.cjs} +37 -37
  56. package/dist/{JapaneseCalendar.main.js.map → private/calendars/JapaneseCalendar.cjs.map} +1 -1
  57. package/dist/{JapaneseCalendar.module.js → private/calendars/JapaneseCalendar.js} +37 -37
  58. package/dist/{JapaneseCalendar.module.js.map → private/calendars/JapaneseCalendar.js.map} +1 -1
  59. package/dist/{JapaneseCalendar.mjs → private/calendars/JapaneseCalendar.mjs} +37 -37
  60. package/dist/private/calendars/JapaneseCalendar.mjs.map +1 -0
  61. package/dist/{PersianCalendar.main.js → private/calendars/PersianCalendar.cjs} +13 -13
  62. package/dist/{PersianCalendar.main.js.map → private/calendars/PersianCalendar.cjs.map} +1 -1
  63. package/dist/{PersianCalendar.module.js → private/calendars/PersianCalendar.js} +13 -13
  64. package/dist/{PersianCalendar.module.js.map → private/calendars/PersianCalendar.js.map} +1 -1
  65. package/dist/{PersianCalendar.mjs → private/calendars/PersianCalendar.mjs} +13 -13
  66. package/dist/private/calendars/PersianCalendar.mjs.map +1 -0
  67. package/dist/{TaiwanCalendar.main.js → private/calendars/TaiwanCalendar.cjs} +20 -20
  68. package/dist/{TaiwanCalendar.main.js.map → private/calendars/TaiwanCalendar.cjs.map} +1 -1
  69. package/dist/private/calendars/TaiwanCalendar.js +75 -0
  70. package/dist/{TaiwanCalendar.module.js.map → private/calendars/TaiwanCalendar.js.map} +1 -1
  71. package/dist/{TaiwanCalendar.mjs → private/calendars/TaiwanCalendar.mjs} +20 -20
  72. package/dist/private/calendars/TaiwanCalendar.mjs.map +1 -0
  73. package/dist/{conversion.main.js → private/conversion.cjs} +85 -85
  74. package/dist/{conversion.main.js.map → private/conversion.cjs.map} +1 -1
  75. package/dist/{conversion.module.js → private/conversion.js} +71 -71
  76. package/dist/{conversion.module.js.map → private/conversion.js.map} +1 -1
  77. package/dist/{conversion.mjs → private/conversion.mjs} +71 -71
  78. package/dist/private/conversion.mjs.map +1 -0
  79. package/dist/private/createCalendar.cjs +69 -0
  80. package/dist/{createCalendar.main.js.map → private/createCalendar.cjs.map} +1 -1
  81. package/dist/private/createCalendar.js +64 -0
  82. package/dist/{createCalendar.module.js.map → private/createCalendar.js.map} +1 -1
  83. package/dist/private/createCalendar.mjs +64 -0
  84. package/dist/private/createCalendar.mjs.map +1 -0
  85. package/dist/{manipulation.main.js → private/manipulation.cjs} +106 -109
  86. package/dist/private/manipulation.cjs.map +1 -0
  87. package/dist/{manipulation.mjs → private/manipulation.js} +88 -88
  88. package/dist/{manipulation.module.js.map → private/manipulation.js.map} +1 -1
  89. package/dist/{manipulation.module.js → private/manipulation.mjs} +93 -96
  90. package/dist/private/manipulation.mjs.map +1 -0
  91. package/dist/private/queries.cjs +359 -0
  92. package/dist/private/queries.cjs.map +1 -0
  93. package/dist/private/queries.js +326 -0
  94. package/dist/private/queries.js.map +1 -0
  95. package/dist/private/queries.mjs +324 -0
  96. package/dist/private/queries.mjs.map +1 -0
  97. package/dist/private/string.cjs +181 -0
  98. package/dist/private/string.cjs.map +1 -0
  99. package/dist/{string.mjs → private/string.js} +64 -64
  100. package/dist/{string.module.js.map → private/string.js.map} +1 -1
  101. package/dist/private/string.mjs +166 -0
  102. package/dist/private/string.mjs.map +1 -0
  103. package/dist/{utils.main.js → private/utils.cjs} +3 -3
  104. package/dist/{utils.main.js.map → private/utils.cjs.map} +1 -1
  105. package/dist/{utils.module.js → private/utils.js} +3 -3
  106. package/dist/{utils.module.js.map → private/utils.js.map} +1 -1
  107. package/dist/{utils.mjs → private/utils.mjs} +3 -3
  108. package/dist/private/utils.mjs.map +1 -0
  109. package/dist/{weekStartData.main.js → private/weekStartData.cjs} +3 -3
  110. package/dist/{weekStartData.main.js.map → private/weekStartData.cjs.map} +1 -1
  111. package/dist/{weekStartData.module.js → private/weekStartData.js} +3 -3
  112. package/dist/{weekStartData.module.js.map → private/weekStartData.js.map} +1 -1
  113. package/dist/{weekStartData.mjs → private/weekStartData.mjs} +3 -3
  114. package/dist/private/weekStartData.mjs.map +1 -0
  115. package/dist/types/src/CalendarDate.d.ts +177 -0
  116. package/dist/types/src/DateFormatter.d.ts +21 -0
  117. package/dist/types/src/calendars/BuddhistCalendar.d.ts +16 -0
  118. package/dist/types/src/calendars/EthiopicCalendar.d.ts +45 -0
  119. package/dist/types/src/calendars/GregorianCalendar.d.ts +25 -0
  120. package/dist/types/src/calendars/HebrewCalendar.d.ts +21 -0
  121. package/dist/types/src/calendars/IndianCalendar.d.ts +17 -0
  122. package/dist/types/src/calendars/IslamicCalendar.d.ts +48 -0
  123. package/dist/types/src/calendars/JapaneseCalendar.d.ts +21 -0
  124. package/dist/types/src/calendars/PersianCalendar.d.ts +19 -0
  125. package/dist/types/src/calendars/TaiwanCalendar.d.ts +19 -0
  126. package/dist/types/src/conversion.d.ts +42 -0
  127. package/dist/types/src/createCalendar.d.ts +3 -0
  128. package/dist/types/src/index.d.ts +17 -0
  129. package/dist/types/src/manipulation.d.ts +25 -0
  130. package/dist/types/src/queries.d.ts +87 -0
  131. package/dist/types/src/string.d.ts +35 -0
  132. package/dist/types/src/types.d.ts +132 -0
  133. package/dist/types/src/utils.d.ts +4 -0
  134. package/dist/types/src/weekStartData.d.ts +97 -0
  135. package/package.json +26 -11
  136. package/src/CalendarDate.ts +2 -0
  137. package/src/index.ts +1 -0
  138. package/src/queries.ts +1 -3
  139. package/dist/CalendarDate.main.js.map +0 -1
  140. package/dist/CalendarDate.module.js.map +0 -1
  141. package/dist/DateFormatter.main.js.map +0 -1
  142. package/dist/IslamicCalendar.main.js +0 -168
  143. package/dist/IslamicCalendar.main.js.map +0 -1
  144. package/dist/IslamicCalendar.mjs +0 -161
  145. package/dist/IslamicCalendar.module.js +0 -161
  146. package/dist/TaiwanCalendar.module.js +0 -75
  147. package/dist/createCalendar.main.js +0 -69
  148. package/dist/createCalendar.mjs +0 -64
  149. package/dist/createCalendar.module.js +0 -64
  150. package/dist/import.mjs +0 -45
  151. package/dist/main.js +0 -113
  152. package/dist/main.js.map +0 -1
  153. package/dist/manipulation.main.js.map +0 -1
  154. package/dist/module.js +0 -45
  155. package/dist/module.js.map +0 -1
  156. package/dist/queries.main.js +0 -361
  157. package/dist/queries.main.js.map +0 -1
  158. package/dist/queries.mjs +0 -326
  159. package/dist/queries.module.js +0 -326
  160. package/dist/queries.module.js.map +0 -1
  161. package/dist/string.main.js +0 -190
  162. package/dist/string.main.js.map +0 -1
  163. package/dist/string.module.js +0 -175
  164. package/dist/types.d.ts +0 -672
  165. package/dist/types.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
- import {epochFromDate as $11d87f3f76e88657$export$bd4fb2bc8bb06fb, fromAbsolute as $11d87f3f76e88657$export$1b96692a1ba042ac, toAbsolute as $11d87f3f76e88657$export$5107c82f94518f5c, toCalendar as $11d87f3f76e88657$export$b4a036af3fc0b032, toCalendarDateTime as $11d87f3f76e88657$export$b21e0b124e224484} from "./conversion.module.js";
2
- import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.module.js";
1
+ import {epochFromDate as $d07e34cce18680fd$export$bd4fb2bc8bb06fb, fromAbsolute as $d07e34cce18680fd$export$1b96692a1ba042ac, toAbsolute as $d07e34cce18680fd$export$5107c82f94518f5c, toCalendar as $d07e34cce18680fd$export$b4a036af3fc0b032, toCalendarDateTime as $d07e34cce18680fd$export$b21e0b124e224484} from "./conversion.mjs";
2
+ import {GregorianCalendar as $93635573935797de$export$80ee6245ec4f29ec} from "./calendars/GregorianCalendar.mjs";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,19 +13,19 @@ import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- const $735220c2d4774dd3$var$ONE_HOUR = 3600000;
17
- function $735220c2d4774dd3$export$e16d8520af44a096(date, duration) {
16
+ const $435a2ceaa8778ed8$var$ONE_HOUR = 3600000;
17
+ function $435a2ceaa8778ed8$export$e16d8520af44a096(date, duration) {
18
18
  let mutableDate = date.copy();
19
- let days = 'hour' in mutableDate ? $735220c2d4774dd3$var$addTimeFields(mutableDate, duration) : 0;
20
- $735220c2d4774dd3$var$addYears(mutableDate, duration.years || 0);
19
+ let days = 'hour' in mutableDate ? $435a2ceaa8778ed8$var$addTimeFields(mutableDate, duration) : 0;
20
+ $435a2ceaa8778ed8$var$addYears(mutableDate, duration.years || 0);
21
21
  if (mutableDate.calendar.balanceYearMonth) mutableDate.calendar.balanceYearMonth(mutableDate, date);
22
22
  mutableDate.month += duration.months || 0;
23
- $735220c2d4774dd3$var$balanceYearMonth(mutableDate);
24
- $735220c2d4774dd3$var$constrainMonthDay(mutableDate);
23
+ $435a2ceaa8778ed8$var$balanceYearMonth(mutableDate);
24
+ $435a2ceaa8778ed8$var$constrainMonthDay(mutableDate);
25
25
  mutableDate.day += (duration.weeks || 0) * 7;
26
26
  mutableDate.day += duration.days || 0;
27
27
  mutableDate.day += days;
28
- $735220c2d4774dd3$var$balanceDay(mutableDate);
28
+ $435a2ceaa8778ed8$var$balanceDay(mutableDate);
29
29
  if (mutableDate.calendar.balanceDate) mutableDate.calendar.balanceDate(mutableDate);
30
30
  // Constrain in case adding ended up with a date outside the valid range for the calendar system.
31
31
  // The behavior here is slightly different than when constraining in the `set` function in that
@@ -38,8 +38,7 @@ function $735220c2d4774dd3$export$e16d8520af44a096(date, duration) {
38
38
  }
39
39
  let maxYear = mutableDate.calendar.getYearsInEra(mutableDate);
40
40
  if (mutableDate.year > maxYear) {
41
- var _mutableDate_calendar_isInverseEra, _mutableDate_calendar;
42
- let isInverseEra = (_mutableDate_calendar_isInverseEra = (_mutableDate_calendar = mutableDate.calendar).isInverseEra) === null || _mutableDate_calendar_isInverseEra === void 0 ? void 0 : _mutableDate_calendar_isInverseEra.call(_mutableDate_calendar, mutableDate);
41
+ let isInverseEra = mutableDate.calendar.isInverseEra?.(mutableDate);
43
42
  mutableDate.year = maxYear;
44
43
  mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate);
45
44
  mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate);
@@ -56,107 +55,106 @@ function $735220c2d4774dd3$export$e16d8520af44a096(date, duration) {
56
55
  mutableDate.day = Math.max(1, Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day));
57
56
  return mutableDate;
58
57
  }
59
- function $735220c2d4774dd3$var$addYears(date, years) {
60
- var _date_calendar_isInverseEra, _date_calendar;
61
- if ((_date_calendar_isInverseEra = (_date_calendar = date.calendar).isInverseEra) === null || _date_calendar_isInverseEra === void 0 ? void 0 : _date_calendar_isInverseEra.call(_date_calendar, date)) years = -years;
58
+ function $435a2ceaa8778ed8$var$addYears(date, years) {
59
+ if (date.calendar.isInverseEra?.(date)) years = -years;
62
60
  date.year += years;
63
61
  }
64
- function $735220c2d4774dd3$var$balanceYearMonth(date) {
62
+ function $435a2ceaa8778ed8$var$balanceYearMonth(date) {
65
63
  while(date.month < 1){
66
- $735220c2d4774dd3$var$addYears(date, -1);
64
+ $435a2ceaa8778ed8$var$addYears(date, -1);
67
65
  date.month += date.calendar.getMonthsInYear(date);
68
66
  }
69
67
  let monthsInYear = 0;
70
68
  while(date.month > (monthsInYear = date.calendar.getMonthsInYear(date))){
71
69
  date.month -= monthsInYear;
72
- $735220c2d4774dd3$var$addYears(date, 1);
70
+ $435a2ceaa8778ed8$var$addYears(date, 1);
73
71
  }
74
72
  }
75
- function $735220c2d4774dd3$var$balanceDay(date) {
73
+ function $435a2ceaa8778ed8$var$balanceDay(date) {
76
74
  while(date.day < 1){
77
75
  date.month--;
78
- $735220c2d4774dd3$var$balanceYearMonth(date);
76
+ $435a2ceaa8778ed8$var$balanceYearMonth(date);
79
77
  date.day += date.calendar.getDaysInMonth(date);
80
78
  }
81
79
  while(date.day > date.calendar.getDaysInMonth(date)){
82
80
  date.day -= date.calendar.getDaysInMonth(date);
83
81
  date.month++;
84
- $735220c2d4774dd3$var$balanceYearMonth(date);
82
+ $435a2ceaa8778ed8$var$balanceYearMonth(date);
85
83
  }
86
84
  }
87
- function $735220c2d4774dd3$var$constrainMonthDay(date) {
85
+ function $435a2ceaa8778ed8$var$constrainMonthDay(date) {
88
86
  date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
89
87
  date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
90
88
  }
91
- function $735220c2d4774dd3$export$c4e2ecac49351ef2(date) {
89
+ function $435a2ceaa8778ed8$export$c4e2ecac49351ef2(date) {
92
90
  if (date.calendar.constrainDate) date.calendar.constrainDate(date);
93
91
  date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));
94
- $735220c2d4774dd3$var$constrainMonthDay(date);
92
+ $435a2ceaa8778ed8$var$constrainMonthDay(date);
95
93
  }
96
- function $735220c2d4774dd3$export$3e2544e88a25bff8(duration) {
94
+ function $435a2ceaa8778ed8$export$3e2544e88a25bff8(duration) {
97
95
  let inverseDuration = {};
98
96
  for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key];
99
97
  return inverseDuration;
100
98
  }
101
- function $735220c2d4774dd3$export$4e2d2ead65e5f7e3(date, duration) {
102
- return $735220c2d4774dd3$export$e16d8520af44a096(date, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
99
+ function $435a2ceaa8778ed8$export$4e2d2ead65e5f7e3(date, duration) {
100
+ return $435a2ceaa8778ed8$export$e16d8520af44a096(date, $435a2ceaa8778ed8$export$3e2544e88a25bff8(duration));
103
101
  }
104
- function $735220c2d4774dd3$export$adaa4cf7ef1b65be(date, fields) {
102
+ function $435a2ceaa8778ed8$export$adaa4cf7ef1b65be(date, fields) {
105
103
  let mutableDate = date.copy();
106
104
  if (fields.era != null) mutableDate.era = fields.era;
107
105
  if (fields.year != null) mutableDate.year = fields.year;
108
106
  if (fields.month != null) mutableDate.month = fields.month;
109
107
  if (fields.day != null) mutableDate.day = fields.day;
110
- $735220c2d4774dd3$export$c4e2ecac49351ef2(mutableDate);
108
+ $435a2ceaa8778ed8$export$c4e2ecac49351ef2(mutableDate);
111
109
  return mutableDate;
112
110
  }
113
- function $735220c2d4774dd3$export$e5d5e1c1822b6e56(value, fields) {
111
+ function $435a2ceaa8778ed8$export$e5d5e1c1822b6e56(value, fields) {
114
112
  let mutableValue = value.copy();
115
113
  if (fields.hour != null) mutableValue.hour = fields.hour;
116
114
  if (fields.minute != null) mutableValue.minute = fields.minute;
117
115
  if (fields.second != null) mutableValue.second = fields.second;
118
116
  if (fields.millisecond != null) mutableValue.millisecond = fields.millisecond;
119
- $735220c2d4774dd3$export$7555de1e070510cb(mutableValue);
117
+ $435a2ceaa8778ed8$export$7555de1e070510cb(mutableValue);
120
118
  return mutableValue;
121
119
  }
122
- function $735220c2d4774dd3$var$balanceTime(time) {
120
+ function $435a2ceaa8778ed8$var$balanceTime(time) {
123
121
  time.second += Math.floor(time.millisecond / 1000);
124
- time.millisecond = $735220c2d4774dd3$var$nonNegativeMod(time.millisecond, 1000);
122
+ time.millisecond = $435a2ceaa8778ed8$var$nonNegativeMod(time.millisecond, 1000);
125
123
  time.minute += Math.floor(time.second / 60);
126
- time.second = $735220c2d4774dd3$var$nonNegativeMod(time.second, 60);
124
+ time.second = $435a2ceaa8778ed8$var$nonNegativeMod(time.second, 60);
127
125
  time.hour += Math.floor(time.minute / 60);
128
- time.minute = $735220c2d4774dd3$var$nonNegativeMod(time.minute, 60);
126
+ time.minute = $435a2ceaa8778ed8$var$nonNegativeMod(time.minute, 60);
129
127
  let days = Math.floor(time.hour / 24);
130
- time.hour = $735220c2d4774dd3$var$nonNegativeMod(time.hour, 24);
128
+ time.hour = $435a2ceaa8778ed8$var$nonNegativeMod(time.hour, 24);
131
129
  return days;
132
130
  }
133
- function $735220c2d4774dd3$export$7555de1e070510cb(time) {
131
+ function $435a2ceaa8778ed8$export$7555de1e070510cb(time) {
134
132
  time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));
135
133
  time.second = Math.max(0, Math.min(time.second, 59));
136
134
  time.minute = Math.max(0, Math.min(time.minute, 59));
137
135
  time.hour = Math.max(0, Math.min(time.hour, 23));
138
136
  }
139
- function $735220c2d4774dd3$var$nonNegativeMod(a, b) {
137
+ function $435a2ceaa8778ed8$var$nonNegativeMod(a, b) {
140
138
  let result = a % b;
141
139
  if (result < 0) result += b;
142
140
  return result;
143
141
  }
144
- function $735220c2d4774dd3$var$addTimeFields(time, duration) {
142
+ function $435a2ceaa8778ed8$var$addTimeFields(time, duration) {
145
143
  time.hour += duration.hours || 0;
146
144
  time.minute += duration.minutes || 0;
147
145
  time.second += duration.seconds || 0;
148
146
  time.millisecond += duration.milliseconds || 0;
149
- return $735220c2d4774dd3$var$balanceTime(time);
147
+ return $435a2ceaa8778ed8$var$balanceTime(time);
150
148
  }
151
- function $735220c2d4774dd3$export$7ed87b6bc2506470(time, duration) {
149
+ function $435a2ceaa8778ed8$export$7ed87b6bc2506470(time, duration) {
152
150
  let res = time.copy();
153
- $735220c2d4774dd3$var$addTimeFields(res, duration);
151
+ $435a2ceaa8778ed8$var$addTimeFields(res, duration);
154
152
  return res;
155
153
  }
156
- function $735220c2d4774dd3$export$fe34d3a381cd7501(time, duration) {
157
- return $735220c2d4774dd3$export$7ed87b6bc2506470(time, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
154
+ function $435a2ceaa8778ed8$export$fe34d3a381cd7501(time, duration) {
155
+ return $435a2ceaa8778ed8$export$7ed87b6bc2506470(time, $435a2ceaa8778ed8$export$3e2544e88a25bff8(duration));
158
156
  }
159
- function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field, amount, options) {
157
+ function $435a2ceaa8778ed8$export$d52ced6badfb9a4c(value, field, amount, options) {
160
158
  let mutable = value.copy();
161
159
  switch(field){
162
160
  case 'era':
@@ -164,36 +162,35 @@ function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field, amount, options
164
162
  let eras = value.calendar.getEras();
165
163
  let eraIndex = eras.indexOf(value.era);
166
164
  if (eraIndex < 0) throw new Error('Invalid era: ' + value.era);
167
- eraIndex = $735220c2d4774dd3$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options === null || options === void 0 ? void 0 : options.round);
165
+ eraIndex = $435a2ceaa8778ed8$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options?.round);
168
166
  mutable.era = eras[eraIndex];
169
167
  // Constrain the year and other fields within the era, so the era doesn't change when we balance below.
170
- $735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
168
+ $435a2ceaa8778ed8$export$c4e2ecac49351ef2(mutable);
171
169
  break;
172
170
  }
173
171
  case 'year':
174
- var _mutable_calendar_isInverseEra, _mutable_calendar;
175
- if ((_mutable_calendar_isInverseEra = (_mutable_calendar = mutable.calendar).isInverseEra) === null || _mutable_calendar_isInverseEra === void 0 ? void 0 : _mutable_calendar_isInverseEra.call(_mutable_calendar, mutable)) amount = -amount;
172
+ if (mutable.calendar.isInverseEra?.(mutable)) amount = -amount;
176
173
  // The year field should not cycle within the era as that can cause weird behavior affecting other fields.
177
174
  // We need to also allow values < 1 so that decrementing goes to the previous era. If we get -Infinity back
178
175
  // we know we wrapped around after reaching 9999 (the maximum), so set the year back to 1.
179
- mutable.year = $735220c2d4774dd3$var$cycleValue(value.year, amount, -Infinity, 9999, options === null || options === void 0 ? void 0 : options.round);
176
+ mutable.year = $435a2ceaa8778ed8$var$cycleValue(value.year, amount, -Infinity, 9999, options?.round);
180
177
  if (mutable.year === -Infinity) mutable.year = 1;
181
178
  if (mutable.calendar.balanceYearMonth) mutable.calendar.balanceYearMonth(mutable, value);
182
179
  break;
183
180
  case 'month':
184
- mutable.month = $735220c2d4774dd3$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options === null || options === void 0 ? void 0 : options.round);
181
+ mutable.month = $435a2ceaa8778ed8$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options?.round);
185
182
  break;
186
183
  case 'day':
187
- mutable.day = $735220c2d4774dd3$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options === null || options === void 0 ? void 0 : options.round);
184
+ mutable.day = $435a2ceaa8778ed8$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options?.round);
188
185
  break;
189
186
  default:
190
187
  throw new Error('Unsupported field ' + field);
191
188
  }
192
189
  if (value.calendar.balanceDate) value.calendar.balanceDate(mutable);
193
- $735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
190
+ $435a2ceaa8778ed8$export$c4e2ecac49351ef2(mutable);
194
191
  return mutable;
195
192
  }
196
- function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options) {
193
+ function $435a2ceaa8778ed8$export$dd02b3e0007dfe28(value, field, amount, options) {
197
194
  let mutable = value.copy();
198
195
  switch(field){
199
196
  case 'hour':
@@ -201,29 +198,29 @@ function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options
201
198
  let hours = value.hour;
202
199
  let min = 0;
203
200
  let max = 23;
204
- if ((options === null || options === void 0 ? void 0 : options.hourCycle) === 12) {
201
+ if (options?.hourCycle === 12) {
205
202
  let isPM = hours >= 12;
206
203
  min = isPM ? 12 : 0;
207
204
  max = isPM ? 23 : 11;
208
205
  }
209
- mutable.hour = $735220c2d4774dd3$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
206
+ mutable.hour = $435a2ceaa8778ed8$var$cycleValue(hours, amount, min, max, options?.round);
210
207
  break;
211
208
  }
212
209
  case 'minute':
213
- mutable.minute = $735220c2d4774dd3$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
210
+ mutable.minute = $435a2ceaa8778ed8$var$cycleValue(value.minute, amount, 0, 59, options?.round);
214
211
  break;
215
212
  case 'second':
216
- mutable.second = $735220c2d4774dd3$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
213
+ mutable.second = $435a2ceaa8778ed8$var$cycleValue(value.second, amount, 0, 59, options?.round);
217
214
  break;
218
215
  case 'millisecond':
219
- mutable.millisecond = $735220c2d4774dd3$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
216
+ mutable.millisecond = $435a2ceaa8778ed8$var$cycleValue(value.millisecond, amount, 0, 999, options?.round);
220
217
  break;
221
218
  default:
222
219
  throw new Error('Unsupported field ' + field);
223
220
  }
224
221
  return mutable;
225
222
  }
226
- function $735220c2d4774dd3$var$cycleValue(value, amount, min, max, round = false) {
223
+ function $435a2ceaa8778ed8$var$cycleValue(value, amount, min, max, round = false) {
227
224
  if (round) {
228
225
  value += Math.sign(amount);
229
226
  if (value < min) value = max;
@@ -238,10 +235,10 @@ function $735220c2d4774dd3$var$cycleValue(value, amount, min, max, round = false
238
235
  }
239
236
  return value;
240
237
  }
241
- function $735220c2d4774dd3$export$96b1d28349274637(dateTime, duration) {
238
+ function $435a2ceaa8778ed8$export$96b1d28349274637(dateTime, duration) {
242
239
  let ms;
243
240
  if (duration.years != null && duration.years !== 0 || duration.months != null && duration.months !== 0 || duration.weeks != null && duration.weeks !== 0 || duration.days != null && duration.days !== 0) {
244
- let res = $735220c2d4774dd3$export$e16d8520af44a096((0, $11d87f3f76e88657$export$b21e0b124e224484)(dateTime), {
241
+ let res = $435a2ceaa8778ed8$export$e16d8520af44a096((0, $d07e34cce18680fd$export$b21e0b124e224484)(dateTime), {
245
242
  years: duration.years,
246
243
  months: duration.months,
247
244
  weeks: duration.weeks,
@@ -249,9 +246,9 @@ function $735220c2d4774dd3$export$96b1d28349274637(dateTime, duration) {
249
246
  });
250
247
  // Changing the date may change the timezone offset, so we need to recompute
251
248
  // using the 'compatible' disambiguation.
252
- ms = (0, $11d87f3f76e88657$export$5107c82f94518f5c)(res, dateTime.timeZone);
249
+ ms = (0, $d07e34cce18680fd$export$5107c82f94518f5c)(res, dateTime.timeZone);
253
250
  } else // Otherwise, preserve the offset of the original date.
254
- ms = (0, $11d87f3f76e88657$export$bd4fb2bc8bb06fb)(dateTime) - dateTime.offset;
251
+ ms = (0, $d07e34cce18680fd$export$bd4fb2bc8bb06fb)(dateTime) - dateTime.offset;
255
252
  // Perform time manipulation in milliseconds rather than on the original time fields to account for DST.
256
253
  // For example, adding one hour during a DST transition may result in the hour field staying the same or
257
254
  // skipping an hour. This results in the offset field changing value instead of the specified field.
@@ -259,13 +256,13 @@ function $735220c2d4774dd3$export$96b1d28349274637(dateTime, duration) {
259
256
  ms += (duration.seconds || 0) * 1000;
260
257
  ms += (duration.minutes || 0) * 60000;
261
258
  ms += (duration.hours || 0) * 3600000;
262
- let res = (0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone);
263
- return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)(res, dateTime.calendar);
259
+ let res = (0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone);
260
+ return (0, $d07e34cce18680fd$export$b4a036af3fc0b032)(res, dateTime.calendar);
264
261
  }
265
- function $735220c2d4774dd3$export$6814caac34ca03c7(dateTime, duration) {
266
- return $735220c2d4774dd3$export$96b1d28349274637(dateTime, $735220c2d4774dd3$export$3e2544e88a25bff8(duration));
262
+ function $435a2ceaa8778ed8$export$6814caac34ca03c7(dateTime, duration) {
263
+ return $435a2ceaa8778ed8$export$96b1d28349274637(dateTime, $435a2ceaa8778ed8$export$3e2544e88a25bff8(duration));
267
264
  }
268
- function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, options) {
265
+ function $435a2ceaa8778ed8$export$9a297d111fc86b79(dateTime, field, amount, options) {
269
266
  // For date fields, we want the time to remain consistent and the UTC offset to potentially change to account for DST changes.
270
267
  // For time fields, we want the time to change by the amount given. This may result in the hour field staying the same, but the UTC
271
268
  // offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.
@@ -274,7 +271,7 @@ function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, opti
274
271
  {
275
272
  let min = 0;
276
273
  let max = 23;
277
- if ((options === null || options === void 0 ? void 0 : options.hourCycle) === 12) {
274
+ if (options?.hourCycle === 12) {
278
275
  let isPM = dateTime.hour >= 12;
279
276
  min = isPM ? 12 : 0;
280
277
  max = isPM ? 23 : 11;
@@ -284,61 +281,61 @@ function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, opti
284
281
  // Or it might end at midnight and repeat the 11pm hour. To handle this, we get
285
282
  // the possible absolute times for the min and max, and find the maximum range
286
283
  // that is within the current day.
287
- let plainDateTime = (0, $11d87f3f76e88657$export$b21e0b124e224484)(dateTime);
288
- let minDate = (0, $11d87f3f76e88657$export$b4a036af3fc0b032)($735220c2d4774dd3$export$e5d5e1c1822b6e56(plainDateTime, {
284
+ let plainDateTime = (0, $d07e34cce18680fd$export$b21e0b124e224484)(dateTime);
285
+ let minDate = (0, $d07e34cce18680fd$export$b4a036af3fc0b032)($435a2ceaa8778ed8$export$e5d5e1c1822b6e56(plainDateTime, {
289
286
  hour: min
290
- }), new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
287
+ }), new (0, $93635573935797de$export$80ee6245ec4f29ec)());
291
288
  let minAbsolute = [
292
- (0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'earlier'),
293
- (0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'later')
294
- ].filter((ms)=>(0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === minDate.day)[0];
295
- let maxDate = (0, $11d87f3f76e88657$export$b4a036af3fc0b032)($735220c2d4774dd3$export$e5d5e1c1822b6e56(plainDateTime, {
289
+ (0, $d07e34cce18680fd$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'earlier'),
290
+ (0, $d07e34cce18680fd$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'later')
291
+ ].filter((ms)=>(0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === minDate.day)[0];
292
+ let maxDate = (0, $d07e34cce18680fd$export$b4a036af3fc0b032)($435a2ceaa8778ed8$export$e5d5e1c1822b6e56(plainDateTime, {
296
293
  hour: max
297
- }), new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
294
+ }), new (0, $93635573935797de$export$80ee6245ec4f29ec)());
298
295
  let maxAbsolute = [
299
- (0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'earlier'),
300
- (0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'later')
301
- ].filter((ms)=>(0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === maxDate.day).pop();
296
+ (0, $d07e34cce18680fd$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'earlier'),
297
+ (0, $d07e34cce18680fd$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'later')
298
+ ].filter((ms)=>(0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === maxDate.day).pop();
302
299
  // Since hours may repeat, we need to operate on the absolute time in milliseconds.
303
300
  // This is done in hours from the Unix epoch so that cycleValue works correctly,
304
301
  // and then converted back to milliseconds.
305
- let ms = (0, $11d87f3f76e88657$export$bd4fb2bc8bb06fb)(dateTime) - dateTime.offset;
306
- let hours = Math.floor(ms / $735220c2d4774dd3$var$ONE_HOUR);
307
- let remainder = ms % $735220c2d4774dd3$var$ONE_HOUR;
308
- ms = $735220c2d4774dd3$var$cycleValue(hours, amount, Math.floor(minAbsolute / $735220c2d4774dd3$var$ONE_HOUR), Math.floor(maxAbsolute / $735220c2d4774dd3$var$ONE_HOUR), options === null || options === void 0 ? void 0 : options.round) * $735220c2d4774dd3$var$ONE_HOUR + remainder;
302
+ let ms = (0, $d07e34cce18680fd$export$bd4fb2bc8bb06fb)(dateTime) - dateTime.offset;
303
+ let hours = Math.floor(ms / $435a2ceaa8778ed8$var$ONE_HOUR);
304
+ let remainder = ms % $435a2ceaa8778ed8$var$ONE_HOUR;
305
+ ms = $435a2ceaa8778ed8$var$cycleValue(hours, amount, Math.floor(minAbsolute / $435a2ceaa8778ed8$var$ONE_HOUR), Math.floor(maxAbsolute / $435a2ceaa8778ed8$var$ONE_HOUR), options?.round) * $435a2ceaa8778ed8$var$ONE_HOUR + remainder;
309
306
  // Now compute the new timezone offset, and convert the absolute time back to local time.
310
- return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)((0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
307
+ return (0, $d07e34cce18680fd$export$b4a036af3fc0b032)((0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
311
308
  }
312
309
  case 'minute':
313
310
  case 'second':
314
311
  case 'millisecond':
315
312
  // @ts-ignore
316
- return $735220c2d4774dd3$export$dd02b3e0007dfe28(dateTime, field, amount, options);
313
+ return $435a2ceaa8778ed8$export$dd02b3e0007dfe28(dateTime, field, amount, options);
317
314
  case 'era':
318
315
  case 'year':
319
316
  case 'month':
320
317
  case 'day':
321
318
  {
322
- let res = $735220c2d4774dd3$export$d52ced6badfb9a4c((0, $11d87f3f76e88657$export$b21e0b124e224484)(dateTime), field, amount, options);
323
- let ms = (0, $11d87f3f76e88657$export$5107c82f94518f5c)(res, dateTime.timeZone);
324
- return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)((0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
319
+ let res = $435a2ceaa8778ed8$export$d52ced6badfb9a4c((0, $d07e34cce18680fd$export$b21e0b124e224484)(dateTime), field, amount, options);
320
+ let ms = (0, $d07e34cce18680fd$export$5107c82f94518f5c)(res, dateTime.timeZone);
321
+ return (0, $d07e34cce18680fd$export$b4a036af3fc0b032)((0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
325
322
  }
326
323
  default:
327
324
  throw new Error('Unsupported field ' + field);
328
325
  }
329
326
  }
330
- function $735220c2d4774dd3$export$31b5430eb18be4f8(dateTime, fields, disambiguation) {
327
+ function $435a2ceaa8778ed8$export$31b5430eb18be4f8(dateTime, fields, disambiguation) {
331
328
  // Set the date/time fields, and recompute the UTC offset to account for DST changes.
332
329
  // We also need to validate by converting back to a local time in case hours are skipped during forward DST transitions.
333
- let plainDateTime = (0, $11d87f3f76e88657$export$b21e0b124e224484)(dateTime);
334
- let res = $735220c2d4774dd3$export$e5d5e1c1822b6e56($735220c2d4774dd3$export$adaa4cf7ef1b65be(plainDateTime, fields), fields);
330
+ let plainDateTime = (0, $d07e34cce18680fd$export$b21e0b124e224484)(dateTime);
331
+ let res = $435a2ceaa8778ed8$export$e5d5e1c1822b6e56($435a2ceaa8778ed8$export$adaa4cf7ef1b65be(plainDateTime, fields), fields);
335
332
  // If the resulting plain date time values are equal, return the original time.
336
333
  // We don't want to change the offset when setting the time to the same value.
337
334
  if (res.compare(plainDateTime) === 0) return dateTime;
338
- let ms = (0, $11d87f3f76e88657$export$5107c82f94518f5c)(res, dateTime.timeZone, disambiguation);
339
- return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)((0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
335
+ let ms = (0, $d07e34cce18680fd$export$5107c82f94518f5c)(res, dateTime.timeZone, disambiguation);
336
+ return (0, $d07e34cce18680fd$export$b4a036af3fc0b032)((0, $d07e34cce18680fd$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
340
337
  }
341
338
 
342
339
 
343
- export {$735220c2d4774dd3$export$e16d8520af44a096 as add, $735220c2d4774dd3$export$c4e2ecac49351ef2 as constrain, $735220c2d4774dd3$export$3e2544e88a25bff8 as invertDuration, $735220c2d4774dd3$export$4e2d2ead65e5f7e3 as subtract, $735220c2d4774dd3$export$adaa4cf7ef1b65be as set, $735220c2d4774dd3$export$e5d5e1c1822b6e56 as setTime, $735220c2d4774dd3$export$7555de1e070510cb as constrainTime, $735220c2d4774dd3$export$7ed87b6bc2506470 as addTime, $735220c2d4774dd3$export$fe34d3a381cd7501 as subtractTime, $735220c2d4774dd3$export$d52ced6badfb9a4c as cycleDate, $735220c2d4774dd3$export$dd02b3e0007dfe28 as cycleTime, $735220c2d4774dd3$export$96b1d28349274637 as addZoned, $735220c2d4774dd3$export$6814caac34ca03c7 as subtractZoned, $735220c2d4774dd3$export$9a297d111fc86b79 as cycleZoned, $735220c2d4774dd3$export$31b5430eb18be4f8 as setZoned};
344
- //# sourceMappingURL=manipulation.module.js.map
340
+ export {$435a2ceaa8778ed8$export$e16d8520af44a096 as add, $435a2ceaa8778ed8$export$c4e2ecac49351ef2 as constrain, $435a2ceaa8778ed8$export$3e2544e88a25bff8 as invertDuration, $435a2ceaa8778ed8$export$4e2d2ead65e5f7e3 as subtract, $435a2ceaa8778ed8$export$adaa4cf7ef1b65be as set, $435a2ceaa8778ed8$export$e5d5e1c1822b6e56 as setTime, $435a2ceaa8778ed8$export$7555de1e070510cb as constrainTime, $435a2ceaa8778ed8$export$7ed87b6bc2506470 as addTime, $435a2ceaa8778ed8$export$fe34d3a381cd7501 as subtractTime, $435a2ceaa8778ed8$export$d52ced6badfb9a4c as cycleDate, $435a2ceaa8778ed8$export$dd02b3e0007dfe28 as cycleTime, $435a2ceaa8778ed8$export$96b1d28349274637 as addZoned, $435a2ceaa8778ed8$export$6814caac34ca03c7 as subtractZoned, $435a2ceaa8778ed8$export$9a297d111fc86b79 as cycleZoned, $435a2ceaa8778ed8$export$31b5430eb18be4f8 as setZoned};
341
+ //# sourceMappingURL=manipulation.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAA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*\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\nimport {AnyCalendarDate, AnyDateTime, AnyTime, CycleOptions, CycleTimeOptions, DateDuration, DateField, DateFields, DateTimeDuration, Disambiguation, TimeDuration, TimeField, TimeFields} from './types';\nimport {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from './CalendarDate';\nimport {epochFromDate, fromAbsolute, toAbsolute, toCalendar, toCalendarDateTime} from './conversion';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {Mutable} from './utils';\n\nconst ONE_HOUR = 3600000;\n\nexport function add(date: CalendarDateTime, duration: DateTimeDuration): CalendarDateTime;\nexport function add(date: CalendarDate, duration: DateDuration): CalendarDate;\nexport function add(date: CalendarDate | CalendarDateTime, duration: DateTimeDuration): CalendarDate | CalendarDateTime;\nexport function add(date: CalendarDate | CalendarDateTime, duration: DateTimeDuration): Mutable<AnyCalendarDate | AnyDateTime> {\n let mutableDate: Mutable<AnyCalendarDate | AnyDateTime> = date.copy();\n let days = 'hour' in mutableDate ? addTimeFields(mutableDate, duration) : 0;\n\n addYears(mutableDate, duration.years || 0);\n if (mutableDate.calendar.balanceYearMonth) {\n mutableDate.calendar.balanceYearMonth(mutableDate, date);\n }\n\n mutableDate.month += duration.months || 0;\n\n balanceYearMonth(mutableDate);\n constrainMonthDay(mutableDate);\n\n mutableDate.day += (duration.weeks || 0) * 7;\n mutableDate.day += duration.days || 0;\n mutableDate.day += days;\n\n balanceDay(mutableDate);\n\n if (mutableDate.calendar.balanceDate) {\n mutableDate.calendar.balanceDate(mutableDate);\n }\n\n // Constrain in case adding ended up with a date outside the valid range for the calendar system.\n // The behavior here is slightly different than when constraining in the `set` function in that\n // we adjust smaller fields to their minimum/maximum values rather than constraining each field\n // individually. This matches the general behavior of `add` vs `set` regarding how fields are balanced.\n if (mutableDate.year < 1) {\n mutableDate.year = 1;\n mutableDate.month = 1;\n mutableDate.day = 1;\n }\n\n let maxYear = mutableDate.calendar.getYearsInEra(mutableDate);\n if (mutableDate.year > maxYear) {\n let isInverseEra = mutableDate.calendar.isInverseEra?.(mutableDate);\n mutableDate.year = maxYear;\n mutableDate.month = isInverseEra ? 1 : mutableDate.calendar.getMonthsInYear(mutableDate);\n mutableDate.day = isInverseEra ? 1 : mutableDate.calendar.getDaysInMonth(mutableDate);\n }\n\n if (mutableDate.month < 1) {\n mutableDate.month = 1;\n mutableDate.day = 1;\n }\n\n let maxMonth = mutableDate.calendar.getMonthsInYear(mutableDate);\n if (mutableDate.month > maxMonth) {\n mutableDate.month = maxMonth;\n mutableDate.day = mutableDate.calendar.getDaysInMonth(mutableDate);\n }\n\n mutableDate.day = Math.max(1, Math.min(mutableDate.calendar.getDaysInMonth(mutableDate), mutableDate.day));\n return mutableDate;\n}\n\nfunction addYears(date: Mutable<AnyCalendarDate>, years: number) {\n if (date.calendar.isInverseEra?.(date)) {\n years = -years;\n }\n\n date.year += years;\n}\n\nfunction balanceYearMonth(date: Mutable<AnyCalendarDate>) {\n while (date.month < 1) {\n addYears(date, -1);\n date.month += date.calendar.getMonthsInYear(date);\n }\n\n let monthsInYear = 0;\n while (date.month > (monthsInYear = date.calendar.getMonthsInYear(date))) {\n date.month -= monthsInYear;\n addYears(date, 1);\n }\n}\n\nfunction balanceDay(date: Mutable<AnyCalendarDate>) {\n while (date.day < 1) {\n date.month--;\n balanceYearMonth(date);\n date.day += date.calendar.getDaysInMonth(date);\n }\n\n while (date.day > date.calendar.getDaysInMonth(date)) {\n date.day -= date.calendar.getDaysInMonth(date);\n date.month++;\n balanceYearMonth(date);\n }\n}\n\nfunction constrainMonthDay(date: Mutable<AnyCalendarDate>) {\n date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));\n date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));\n}\n\nexport function constrain(date: Mutable<AnyCalendarDate>): void {\n if (date.calendar.constrainDate) {\n date.calendar.constrainDate(date);\n }\n\n date.year = Math.max(1, Math.min(date.calendar.getYearsInEra(date), date.year));\n constrainMonthDay(date);\n}\n\nexport function invertDuration(duration: DateTimeDuration): DateTimeDuration {\n let inverseDuration = {};\n for (let key in duration) {\n if (typeof duration[key] === 'number') {\n inverseDuration[key] = -duration[key];\n }\n }\n\n return inverseDuration;\n}\n\nexport function subtract(date: CalendarDateTime, duration: DateTimeDuration): CalendarDateTime;\nexport function subtract(date: CalendarDate, duration: DateDuration): CalendarDate;\nexport function subtract(date: CalendarDate | CalendarDateTime, duration: DateTimeDuration): CalendarDate | CalendarDateTime {\n return add(date, invertDuration(duration));\n}\n\nexport function set(date: CalendarDateTime, fields: DateFields): CalendarDateTime;\nexport function set(date: CalendarDate, fields: DateFields): CalendarDate;\nexport function set(date: CalendarDate | CalendarDateTime, fields: DateFields): Mutable<AnyCalendarDate> {\n let mutableDate: Mutable<AnyCalendarDate> = date.copy();\n\n if (fields.era != null) {\n mutableDate.era = fields.era;\n }\n\n if (fields.year != null) {\n mutableDate.year = fields.year;\n }\n\n if (fields.month != null) {\n mutableDate.month = fields.month;\n }\n\n if (fields.day != null) {\n mutableDate.day = fields.day;\n }\n\n constrain(mutableDate);\n return mutableDate;\n}\n\nexport function setTime(value: CalendarDateTime, fields: TimeFields): CalendarDateTime;\nexport function setTime(value: Time, fields: TimeFields): Time;\nexport function setTime(value: Time | CalendarDateTime, fields: TimeFields): Mutable<Time | CalendarDateTime> {\n let mutableValue: Mutable<Time | CalendarDateTime> = value.copy();\n\n if (fields.hour != null) {\n mutableValue.hour = fields.hour;\n }\n\n if (fields.minute != null) {\n mutableValue.minute = fields.minute;\n }\n\n if (fields.second != null) {\n mutableValue.second = fields.second;\n }\n\n if (fields.millisecond != null) {\n mutableValue.millisecond = fields.millisecond;\n }\n\n constrainTime(mutableValue);\n return mutableValue;\n}\n\nfunction balanceTime(time: Mutable<AnyTime>): number {\n time.second += Math.floor(time.millisecond / 1000);\n time.millisecond = nonNegativeMod(time.millisecond, 1000);\n\n time.minute += Math.floor(time.second / 60);\n time.second = nonNegativeMod(time.second, 60);\n\n time.hour += Math.floor(time.minute / 60);\n time.minute = nonNegativeMod(time.minute, 60);\n\n let days = Math.floor(time.hour / 24);\n time.hour = nonNegativeMod(time.hour, 24);\n\n return days;\n}\n\nexport function constrainTime(time: Mutable<AnyTime>): void {\n time.millisecond = Math.max(0, Math.min(time.millisecond, 1000));\n time.second = Math.max(0, Math.min(time.second, 59));\n time.minute = Math.max(0, Math.min(time.minute, 59));\n time.hour = Math.max(0, Math.min(time.hour, 23));\n}\n\nfunction nonNegativeMod(a: number, b: number) {\n let result = a % b;\n if (result < 0) {\n result += b;\n }\n return result;\n}\n\nfunction addTimeFields(time: Mutable<AnyTime>, duration: TimeDuration): number {\n time.hour += duration.hours || 0;\n time.minute += duration.minutes || 0;\n time.second += duration.seconds || 0;\n time.millisecond += duration.milliseconds || 0;\n return balanceTime(time);\n}\n\nexport function addTime(time: Time, duration: TimeDuration): Time {\n let res = time.copy();\n addTimeFields(res, duration);\n return res;\n}\n\nexport function subtractTime(time: Time, duration: TimeDuration): Time {\n return addTime(time, invertDuration(duration));\n}\n\nexport function cycleDate(value: CalendarDateTime, field: DateField, amount: number, options?: CycleOptions): CalendarDateTime;\nexport function cycleDate(value: CalendarDate, field: DateField, amount: number, options?: CycleOptions): CalendarDate;\nexport function cycleDate(value: CalendarDate | CalendarDateTime, field: DateField, amount: number, options?: CycleOptions): Mutable<CalendarDate | CalendarDateTime> {\n let mutable: Mutable<CalendarDate | CalendarDateTime> = value.copy();\n\n switch (field) {\n case 'era': {\n let eras = value.calendar.getEras();\n let eraIndex = eras.indexOf(value.era);\n if (eraIndex < 0) {\n throw new Error('Invalid era: ' + value.era);\n }\n eraIndex = cycleValue(eraIndex, amount, 0, eras.length - 1, options?.round);\n mutable.era = eras[eraIndex];\n\n // Constrain the year and other fields within the era, so the era doesn't change when we balance below.\n constrain(mutable);\n break;\n }\n case 'year': {\n if (mutable.calendar.isInverseEra?.(mutable)) {\n amount = -amount;\n }\n\n // The year field should not cycle within the era as that can cause weird behavior affecting other fields.\n // We need to also allow values < 1 so that decrementing goes to the previous era. If we get -Infinity back\n // we know we wrapped around after reaching 9999 (the maximum), so set the year back to 1.\n mutable.year = cycleValue(value.year, amount, -Infinity, 9999, options?.round);\n if (mutable.year === -Infinity) {\n mutable.year = 1;\n }\n\n if (mutable.calendar.balanceYearMonth) {\n mutable.calendar.balanceYearMonth(mutable, value);\n }\n break;\n }\n case 'month':\n mutable.month = cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options?.round);\n break;\n case 'day':\n mutable.day = cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options?.round);\n break;\n default:\n throw new Error('Unsupported field ' + field);\n }\n\n if (value.calendar.balanceDate) {\n value.calendar.balanceDate(mutable);\n }\n\n constrain(mutable);\n return mutable;\n}\n\nexport function cycleTime(value: CalendarDateTime, field: TimeField, amount: number, options?: CycleTimeOptions): CalendarDateTime;\nexport function cycleTime(value: Time, field: TimeField, amount: number, options?: CycleTimeOptions): Time;\nexport function cycleTime(value: Time | CalendarDateTime, field: TimeField, amount: number, options?: CycleTimeOptions): Mutable<Time | CalendarDateTime> {\n let mutable: Mutable<Time | CalendarDateTime> = value.copy();\n\n switch (field) {\n case 'hour': {\n let hours = value.hour;\n let min = 0;\n let max = 23;\n if (options?.hourCycle === 12) {\n let isPM = hours >= 12;\n min = isPM ? 12 : 0;\n max = isPM ? 23 : 11;\n }\n mutable.hour = cycleValue(hours, amount, min, max, options?.round);\n break;\n }\n case 'minute':\n mutable.minute = cycleValue(value.minute, amount, 0, 59, options?.round);\n break;\n case 'second':\n mutable.second = cycleValue(value.second, amount, 0, 59, options?.round);\n break;\n case 'millisecond':\n mutable.millisecond = cycleValue(value.millisecond, amount, 0, 999, options?.round);\n break;\n default:\n throw new Error('Unsupported field ' + field);\n }\n\n return mutable;\n}\n\nfunction cycleValue(value: number, amount: number, min: number, max: number, round = false) {\n if (round) {\n value += Math.sign(amount);\n\n if (value < min) {\n value = max;\n }\n\n let div = Math.abs(amount);\n if (amount > 0) {\n value = Math.ceil(value / div) * div;\n } else {\n value = Math.floor(value / div) * div;\n }\n\n if (value > max) {\n value = min;\n }\n } else {\n value += amount;\n if (value < min) {\n value = max - (min - value - 1);\n } else if (value > max) {\n value = min + (value - max - 1);\n }\n }\n\n return value;\n}\n\nexport function addZoned(dateTime: ZonedDateTime, duration: DateTimeDuration): ZonedDateTime {\n let ms: number;\n if ((duration.years != null && duration.years !== 0) || (duration.months != null && duration.months !== 0) || (duration.weeks != null && duration.weeks !== 0) || (duration.days != null && duration.days !== 0)) {\n let res = add(toCalendarDateTime(dateTime), {\n years: duration.years,\n months: duration.months,\n weeks: duration.weeks,\n days: duration.days\n });\n\n // Changing the date may change the timezone offset, so we need to recompute\n // using the 'compatible' disambiguation.\n ms = toAbsolute(res, dateTime.timeZone);\n } else {\n // Otherwise, preserve the offset of the original date.\n ms = epochFromDate(dateTime) - dateTime.offset;\n }\n\n // Perform time manipulation in milliseconds rather than on the original time fields to account for DST.\n // For example, adding one hour during a DST transition may result in the hour field staying the same or\n // skipping an hour. This results in the offset field changing value instead of the specified field.\n ms += duration.milliseconds || 0;\n ms += (duration.seconds || 0) * 1000;\n ms += (duration.minutes || 0) * 60 * 1000;\n ms += (duration.hours || 0) * 60 * 60 * 1000;\n\n let res = fromAbsolute(ms, dateTime.timeZone);\n return toCalendar(res, dateTime.calendar);\n}\n\nexport function subtractZoned(dateTime: ZonedDateTime, duration: DateTimeDuration): ZonedDateTime {\n return addZoned(dateTime, invertDuration(duration));\n}\n\nexport function cycleZoned(dateTime: ZonedDateTime, field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {\n // For date fields, we want the time to remain consistent and the UTC offset to potentially change to account for DST changes.\n // For time fields, we want the time to change by the amount given. This may result in the hour field staying the same, but the UTC\n // offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.\n switch (field) {\n case 'hour': {\n let min = 0;\n let max = 23;\n if (options?.hourCycle === 12) {\n let isPM = dateTime.hour >= 12;\n min = isPM ? 12 : 0;\n max = isPM ? 23 : 11;\n }\n\n // The minimum and maximum hour may be affected by daylight saving time.\n // For example, it might jump forward at midnight, and skip 1am.\n // Or it might end at midnight and repeat the 11pm hour. To handle this, we get\n // the possible absolute times for the min and max, and find the maximum range\n // that is within the current day.\n let plainDateTime = toCalendarDateTime(dateTime);\n let minDate = toCalendar(setTime(plainDateTime, {hour: min}), new GregorianCalendar());\n let minAbsolute = [toAbsolute(minDate, dateTime.timeZone, 'earlier'), toAbsolute(minDate, dateTime.timeZone, 'later')]\n .filter(ms => fromAbsolute(ms, dateTime.timeZone).day === minDate.day)[0];\n\n let maxDate = toCalendar(setTime(plainDateTime, {hour: max}), new GregorianCalendar());\n let maxAbsolute = [toAbsolute(maxDate, dateTime.timeZone, 'earlier'), toAbsolute(maxDate, dateTime.timeZone, 'later')]\n .filter(ms => fromAbsolute(ms, dateTime.timeZone).day === maxDate.day).pop()!;\n\n // Since hours may repeat, we need to operate on the absolute time in milliseconds.\n // This is done in hours from the Unix epoch so that cycleValue works correctly,\n // and then converted back to milliseconds.\n let ms = epochFromDate(dateTime) - dateTime.offset;\n let hours = Math.floor(ms / ONE_HOUR);\n let remainder = ms % ONE_HOUR;\n ms = cycleValue(\n hours,\n amount,\n Math.floor(minAbsolute / ONE_HOUR),\n Math.floor(maxAbsolute / ONE_HOUR),\n options?.round\n ) * ONE_HOUR + remainder;\n\n // Now compute the new timezone offset, and convert the absolute time back to local time.\n return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);\n }\n case 'minute':\n case 'second':\n case 'millisecond':\n // @ts-ignore\n return cycleTime(dateTime, field, amount, options);\n case 'era':\n case 'year':\n case 'month':\n case 'day': {\n let res = cycleDate(toCalendarDateTime(dateTime), field, amount, options);\n let ms = toAbsolute(res, dateTime.timeZone);\n return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);\n }\n default:\n throw new Error('Unsupported field ' + field);\n }\n}\n\nexport function setZoned(dateTime: ZonedDateTime, fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {\n // Set the date/time fields, and recompute the UTC offset to account for DST changes.\n // We also need to validate by converting back to a local time in case hours are skipped during forward DST transitions.\n let plainDateTime = toCalendarDateTime(dateTime);\n let res = setTime(set(plainDateTime, fields), fields);\n\n // If the resulting plain date time values are equal, return the original time.\n // We don't want to change the offset when setting the time to the same value.\n if (res.compare(plainDateTime) === 0) {\n return dateTime;\n }\n\n let ms = toAbsolute(res, dateTime.timeZone, disambiguation);\n return toCalendar(fromAbsolute(ms, dateTime.timeZone), dateTime.calendar);\n}\n"],"names":[],"version":3,"file":"manipulation.mjs.map"}