@internationalized/date 3.5.4-nightly.4624 → 3.5.4
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.
- package/dist/BuddhistCalendar.main.js +2 -2
- package/dist/BuddhistCalendar.mjs +2 -2
- package/dist/BuddhistCalendar.module.js +2 -2
- package/dist/CalendarDate.main.js +6 -6
- package/dist/CalendarDate.mjs +6 -6
- package/dist/CalendarDate.module.js +6 -6
- package/dist/DateFormatter.main.js +30 -30
- package/dist/DateFormatter.mjs +30 -30
- package/dist/DateFormatter.module.js +30 -30
- package/dist/EthiopicCalendar.main.js +20 -20
- package/dist/EthiopicCalendar.mjs +20 -20
- package/dist/EthiopicCalendar.module.js +20 -20
- package/dist/GregorianCalendar.main.js +9 -9
- package/dist/GregorianCalendar.mjs +9 -9
- package/dist/GregorianCalendar.module.js +9 -9
- package/dist/HebrewCalendar.main.js +2 -2
- package/dist/HebrewCalendar.mjs +2 -2
- package/dist/HebrewCalendar.module.js +2 -2
- package/dist/IndianCalendar.main.js +2 -2
- package/dist/IndianCalendar.mjs +2 -2
- package/dist/IndianCalendar.module.js +2 -2
- package/dist/IslamicCalendar.main.js +5 -5
- package/dist/IslamicCalendar.mjs +5 -5
- package/dist/IslamicCalendar.module.js +5 -5
- package/dist/JapaneseCalendar.main.js +7 -7
- package/dist/JapaneseCalendar.mjs +7 -7
- package/dist/JapaneseCalendar.module.js +7 -7
- package/dist/PersianCalendar.main.js +2 -2
- package/dist/PersianCalendar.mjs +2 -2
- package/dist/PersianCalendar.module.js +2 -2
- package/dist/TaiwanCalendar.main.js +8 -8
- package/dist/TaiwanCalendar.mjs +8 -8
- package/dist/TaiwanCalendar.module.js +8 -8
- package/dist/conversion.main.js +28 -28
- package/dist/conversion.mjs +28 -28
- package/dist/conversion.module.js +28 -28
- package/dist/createCalendar.main.js +13 -13
- package/dist/createCalendar.mjs +13 -13
- package/dist/createCalendar.module.js +13 -13
- package/dist/manipulation.main.js +26 -26
- package/dist/manipulation.mjs +26 -26
- package/dist/manipulation.module.js +26 -26
- package/dist/queries.main.js +2 -2
- package/dist/queries.mjs +2 -2
- package/dist/queries.module.js +2 -2
- package/dist/string.main.js +19 -19
- package/dist/string.mjs +19 -19
- package/dist/string.module.js +19 -19
- package/dist/weekStartData.main.js +1 -1
- package/dist/weekStartData.mjs +1 -1
- package/dist/weekStartData.module.js +1 -1
- package/package.json +2 -2
|
@@ -34,7 +34,7 @@ function $11d87f3f76e88657$var$epochFromParts(year, month, day, hour, minute, se
|
|
|
34
34
|
}
|
|
35
35
|
function $11d87f3f76e88657$export$59c99f3515d3493f(ms, timeZone) {
|
|
36
36
|
// Fast path for UTC.
|
|
37
|
-
if (timeZone ===
|
|
37
|
+
if (timeZone === 'UTC') return 0;
|
|
38
38
|
// Fast path: for local timezone after 1970, use native Date.
|
|
39
39
|
if (ms > 0 && timeZone === (0, $14e0f24ef4ac5c92$export$aa8b41735afcabd2)()) return new Date(ms).getTimezoneOffset() * -60000;
|
|
40
40
|
let { year: year, month: month, day: day, hour: hour, minute: minute, second: second } = $11d87f3f76e88657$var$getTimeZoneParts(ms, timeZone);
|
|
@@ -45,28 +45,28 @@ const $11d87f3f76e88657$var$formattersByTimeZone = new Map();
|
|
|
45
45
|
function $11d87f3f76e88657$var$getTimeZoneParts(ms, timeZone) {
|
|
46
46
|
let formatter = $11d87f3f76e88657$var$formattersByTimeZone.get(timeZone);
|
|
47
47
|
if (!formatter) {
|
|
48
|
-
formatter = new Intl.DateTimeFormat(
|
|
48
|
+
formatter = new Intl.DateTimeFormat('en-US', {
|
|
49
49
|
timeZone: timeZone,
|
|
50
50
|
hour12: false,
|
|
51
|
-
era:
|
|
52
|
-
year:
|
|
53
|
-
month:
|
|
54
|
-
day:
|
|
55
|
-
hour:
|
|
56
|
-
minute:
|
|
57
|
-
second:
|
|
51
|
+
era: 'short',
|
|
52
|
+
year: 'numeric',
|
|
53
|
+
month: 'numeric',
|
|
54
|
+
day: 'numeric',
|
|
55
|
+
hour: 'numeric',
|
|
56
|
+
minute: 'numeric',
|
|
57
|
+
second: 'numeric'
|
|
58
58
|
});
|
|
59
59
|
$11d87f3f76e88657$var$formattersByTimeZone.set(timeZone, formatter);
|
|
60
60
|
}
|
|
61
61
|
let parts = formatter.formatToParts(new Date(ms));
|
|
62
62
|
let namedParts = {};
|
|
63
|
-
for (let part of parts)if (part.type !==
|
|
63
|
+
for (let part of parts)if (part.type !== 'literal') namedParts[part.type] = part.value;
|
|
64
64
|
return {
|
|
65
65
|
// Firefox returns B instead of BC... https://bugzilla.mozilla.org/show_bug.cgi?id=1752253
|
|
66
|
-
year: namedParts.era ===
|
|
66
|
+
year: namedParts.era === 'BC' || namedParts.era === 'B' ? -namedParts.year + 1 : +namedParts.year,
|
|
67
67
|
month: +namedParts.month,
|
|
68
68
|
day: +namedParts.day,
|
|
69
|
-
hour: namedParts.hour ===
|
|
69
|
+
hour: namedParts.hour === '24' ? 0 : +namedParts.hour,
|
|
70
70
|
minute: +namedParts.minute,
|
|
71
71
|
second: +namedParts.second
|
|
72
72
|
};
|
|
@@ -91,12 +91,12 @@ function $11d87f3f76e88657$var$isValidWallTime(date, timeZone, absolute) {
|
|
|
91
91
|
let parts = $11d87f3f76e88657$var$getTimeZoneParts(absolute, timeZone);
|
|
92
92
|
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;
|
|
93
93
|
}
|
|
94
|
-
function $11d87f3f76e88657$export$5107c82f94518f5c(date, timeZone, disambiguation =
|
|
94
|
+
function $11d87f3f76e88657$export$5107c82f94518f5c(date, timeZone, disambiguation = 'compatible') {
|
|
95
95
|
let dateTime = $11d87f3f76e88657$export$b21e0b124e224484(date);
|
|
96
96
|
// Fast path: if the time zone is UTC, use native Date.
|
|
97
|
-
if (timeZone ===
|
|
97
|
+
if (timeZone === 'UTC') return $11d87f3f76e88657$export$bd4fb2bc8bb06fb(dateTime);
|
|
98
98
|
// Fast path: if the time zone is the local timezone and disambiguation is compatible, use native Date.
|
|
99
|
-
if (timeZone === (0, $14e0f24ef4ac5c92$export$aa8b41735afcabd2)() && disambiguation ===
|
|
99
|
+
if (timeZone === (0, $14e0f24ef4ac5c92$export$aa8b41735afcabd2)() && disambiguation === 'compatible') {
|
|
100
100
|
dateTime = $11d87f3f76e88657$export$b4a036af3fc0b032(dateTime, new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
|
|
101
101
|
// Don't use Date constructor here because two-digit years are interpreted in the 20th century.
|
|
102
102
|
let date = new Date();
|
|
@@ -112,26 +112,26 @@ function $11d87f3f76e88657$export$5107c82f94518f5c(date, timeZone, disambiguatio
|
|
|
112
112
|
if (valid.length === 1) return valid[0];
|
|
113
113
|
if (valid.length > 1) switch(disambiguation){
|
|
114
114
|
// 'compatible' means 'earlier' for "fall back" transitions
|
|
115
|
-
case
|
|
116
|
-
case
|
|
115
|
+
case 'compatible':
|
|
116
|
+
case 'earlier':
|
|
117
117
|
return valid[0];
|
|
118
|
-
case
|
|
118
|
+
case 'later':
|
|
119
119
|
return valid[valid.length - 1];
|
|
120
|
-
case
|
|
121
|
-
throw new RangeError(
|
|
120
|
+
case 'reject':
|
|
121
|
+
throw new RangeError('Multiple possible absolute times found');
|
|
122
122
|
}
|
|
123
123
|
switch(disambiguation){
|
|
124
|
-
case
|
|
124
|
+
case 'earlier':
|
|
125
125
|
return Math.min(ms - offsetBefore, ms - offsetAfter);
|
|
126
126
|
// 'compatible' means 'later' for "spring forward" transitions
|
|
127
|
-
case
|
|
128
|
-
case
|
|
127
|
+
case 'compatible':
|
|
128
|
+
case 'later':
|
|
129
129
|
return Math.max(ms - offsetBefore, ms - offsetAfter);
|
|
130
|
-
case
|
|
131
|
-
throw new RangeError(
|
|
130
|
+
case 'reject':
|
|
131
|
+
throw new RangeError('No such absolute time found');
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
function $11d87f3f76e88657$export$e67a095c620b86fe(dateTime, timeZone, disambiguation =
|
|
134
|
+
function $11d87f3f76e88657$export$e67a095c620b86fe(dateTime, timeZone, disambiguation = 'compatible') {
|
|
135
135
|
return new Date($11d87f3f76e88657$export$5107c82f94518f5c(dateTime, timeZone, disambiguation));
|
|
136
136
|
}
|
|
137
137
|
function $11d87f3f76e88657$export$1b96692a1ba042ac(ms, timeZone) {
|
|
@@ -173,8 +173,8 @@ function $11d87f3f76e88657$export$4d0393e732857be5(date) {
|
|
|
173
173
|
}
|
|
174
174
|
function $11d87f3f76e88657$export$b21e0b124e224484(date, time) {
|
|
175
175
|
let hour = 0, minute = 0, second = 0, millisecond = 0;
|
|
176
|
-
if (
|
|
177
|
-
else if (
|
|
176
|
+
if ('timeZone' in date) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = date);
|
|
177
|
+
else if ('hour' in date && !time) return date;
|
|
178
178
|
if (time) ({ hour: hour, minute: minute, second: second, millisecond: millisecond } = time);
|
|
179
179
|
return new (0, $35ea8db9cb2ccb90$export$ca871e8dbb80966f)(date.calendar, date.era, date.year, date.month, date.day, hour, minute, second, millisecond);
|
|
180
180
|
}
|
|
@@ -35,31 +35,31 @@ $parcel$export(module.exports, "createCalendar", () => $4922c0a5a69da0ba$export$
|
|
|
35
35
|
|
|
36
36
|
function $4922c0a5a69da0ba$export$dd0bbc9b26defe37(name) {
|
|
37
37
|
switch(name){
|
|
38
|
-
case
|
|
38
|
+
case 'buddhist':
|
|
39
39
|
return new (0, $561c4ef058278b74$exports.BuddhistCalendar)();
|
|
40
|
-
case
|
|
40
|
+
case 'ethiopic':
|
|
41
41
|
return new (0, $4db04d1051af0f2f$exports.EthiopicCalendar)();
|
|
42
|
-
case
|
|
42
|
+
case 'ethioaa':
|
|
43
43
|
return new (0, $4db04d1051af0f2f$exports.EthiopicAmeteAlemCalendar)();
|
|
44
|
-
case
|
|
44
|
+
case 'coptic':
|
|
45
45
|
return new (0, $4db04d1051af0f2f$exports.CopticCalendar)();
|
|
46
|
-
case
|
|
46
|
+
case 'hebrew':
|
|
47
47
|
return new (0, $0f5324ee3bdd9396$exports.HebrewCalendar)();
|
|
48
|
-
case
|
|
48
|
+
case 'indian':
|
|
49
49
|
return new (0, $5f1dfa5c67609fe6$exports.IndianCalendar)();
|
|
50
|
-
case
|
|
50
|
+
case 'islamic-civil':
|
|
51
51
|
return new (0, $ecb2c4cc8c9aae25$exports.IslamicCivilCalendar)();
|
|
52
|
-
case
|
|
52
|
+
case 'islamic-tbla':
|
|
53
53
|
return new (0, $ecb2c4cc8c9aae25$exports.IslamicTabularCalendar)();
|
|
54
|
-
case
|
|
54
|
+
case 'islamic-umalqura':
|
|
55
55
|
return new (0, $ecb2c4cc8c9aae25$exports.IslamicUmalquraCalendar)();
|
|
56
|
-
case
|
|
56
|
+
case 'japanese':
|
|
57
57
|
return new (0, $b0ac0602ef646b2c$exports.JapaneseCalendar)();
|
|
58
|
-
case
|
|
58
|
+
case 'persian':
|
|
59
59
|
return new (0, $3c060181fc7249ae$exports.PersianCalendar)();
|
|
60
|
-
case
|
|
60
|
+
case 'roc':
|
|
61
61
|
return new (0, $9cc5d3577ec40243$exports.TaiwanCalendar)();
|
|
62
|
-
case
|
|
62
|
+
case 'gregory':
|
|
63
63
|
default:
|
|
64
64
|
return new (0, $af14c9812fdceb33$exports.GregorianCalendar)();
|
|
65
65
|
}
|
package/dist/createCalendar.mjs
CHANGED
|
@@ -29,31 +29,31 @@ import {TaiwanCalendar as $5f31bd6f0c8940b2$export$65e01080afcb0799} from "./Tai
|
|
|
29
29
|
|
|
30
30
|
function $64244302c3013299$export$dd0bbc9b26defe37(name) {
|
|
31
31
|
switch(name){
|
|
32
|
-
case
|
|
32
|
+
case 'buddhist':
|
|
33
33
|
return new (0, $8d73d47422ca7302$export$42d20a78301dee44)();
|
|
34
|
-
case
|
|
34
|
+
case 'ethiopic':
|
|
35
35
|
return new (0, $b956b2d7a6cf451f$export$26ba6eab5e20cd7d)();
|
|
36
|
-
case
|
|
36
|
+
case 'ethioaa':
|
|
37
37
|
return new (0, $b956b2d7a6cf451f$export$d72e0c37005a4914)();
|
|
38
|
-
case
|
|
38
|
+
case 'coptic':
|
|
39
39
|
return new (0, $b956b2d7a6cf451f$export$fe6243cbe1a4b7c1)();
|
|
40
|
-
case
|
|
40
|
+
case 'hebrew':
|
|
41
41
|
return new (0, $7c5f6fbf42389787$export$ca405048b8fb5af)();
|
|
42
|
-
case
|
|
42
|
+
case 'indian':
|
|
43
43
|
return new (0, $82c358003bdda0a8$export$39f31c639fa15726)();
|
|
44
|
-
case
|
|
44
|
+
case 'islamic-civil':
|
|
45
45
|
return new (0, $f2f3e0e3a817edbd$export$2066795aadd37bfc)();
|
|
46
|
-
case
|
|
46
|
+
case 'islamic-tbla':
|
|
47
47
|
return new (0, $f2f3e0e3a817edbd$export$37f0887f2f9d22f7)();
|
|
48
|
-
case
|
|
48
|
+
case 'islamic-umalqura':
|
|
49
49
|
return new (0, $f2f3e0e3a817edbd$export$5baab4758c231076)();
|
|
50
|
-
case
|
|
50
|
+
case 'japanese':
|
|
51
51
|
return new (0, $62225008020f0a13$export$b746ab2b60cdffbf)();
|
|
52
|
-
case
|
|
52
|
+
case 'persian':
|
|
53
53
|
return new (0, $f3ed2e4472ae7e25$export$37fccdbfd14c5939)();
|
|
54
|
-
case
|
|
54
|
+
case 'roc':
|
|
55
55
|
return new (0, $5f31bd6f0c8940b2$export$65e01080afcb0799)();
|
|
56
|
-
case
|
|
56
|
+
case 'gregory':
|
|
57
57
|
default:
|
|
58
58
|
return new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
59
59
|
}
|
|
@@ -29,31 +29,31 @@ import {TaiwanCalendar as $5f31bd6f0c8940b2$export$65e01080afcb0799} from "./Tai
|
|
|
29
29
|
|
|
30
30
|
function $64244302c3013299$export$dd0bbc9b26defe37(name) {
|
|
31
31
|
switch(name){
|
|
32
|
-
case
|
|
32
|
+
case 'buddhist':
|
|
33
33
|
return new (0, $8d73d47422ca7302$export$42d20a78301dee44)();
|
|
34
|
-
case
|
|
34
|
+
case 'ethiopic':
|
|
35
35
|
return new (0, $b956b2d7a6cf451f$export$26ba6eab5e20cd7d)();
|
|
36
|
-
case
|
|
36
|
+
case 'ethioaa':
|
|
37
37
|
return new (0, $b956b2d7a6cf451f$export$d72e0c37005a4914)();
|
|
38
|
-
case
|
|
38
|
+
case 'coptic':
|
|
39
39
|
return new (0, $b956b2d7a6cf451f$export$fe6243cbe1a4b7c1)();
|
|
40
|
-
case
|
|
40
|
+
case 'hebrew':
|
|
41
41
|
return new (0, $7c5f6fbf42389787$export$ca405048b8fb5af)();
|
|
42
|
-
case
|
|
42
|
+
case 'indian':
|
|
43
43
|
return new (0, $82c358003bdda0a8$export$39f31c639fa15726)();
|
|
44
|
-
case
|
|
44
|
+
case 'islamic-civil':
|
|
45
45
|
return new (0, $f2f3e0e3a817edbd$export$2066795aadd37bfc)();
|
|
46
|
-
case
|
|
46
|
+
case 'islamic-tbla':
|
|
47
47
|
return new (0, $f2f3e0e3a817edbd$export$37f0887f2f9d22f7)();
|
|
48
|
-
case
|
|
48
|
+
case 'islamic-umalqura':
|
|
49
49
|
return new (0, $f2f3e0e3a817edbd$export$5baab4758c231076)();
|
|
50
|
-
case
|
|
50
|
+
case 'japanese':
|
|
51
51
|
return new (0, $62225008020f0a13$export$b746ab2b60cdffbf)();
|
|
52
|
-
case
|
|
52
|
+
case 'persian':
|
|
53
53
|
return new (0, $f3ed2e4472ae7e25$export$37fccdbfd14c5939)();
|
|
54
|
-
case
|
|
54
|
+
case 'roc':
|
|
55
55
|
return new (0, $5f31bd6f0c8940b2$export$65e01080afcb0799)();
|
|
56
|
-
case
|
|
56
|
+
case 'gregory':
|
|
57
57
|
default:
|
|
58
58
|
return new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
59
59
|
}
|
|
@@ -35,7 +35,7 @@ $parcel$export(module.exports, "setZoned", () => $5c0571aa5b6fb5da$export$31b543
|
|
|
35
35
|
const $5c0571aa5b6fb5da$var$ONE_HOUR = 3600000;
|
|
36
36
|
function $5c0571aa5b6fb5da$export$e16d8520af44a096(date, duration) {
|
|
37
37
|
let mutableDate = date.copy();
|
|
38
|
-
let days =
|
|
38
|
+
let days = 'hour' in mutableDate ? $5c0571aa5b6fb5da$var$addTimeFields(mutableDate, duration) : 0;
|
|
39
39
|
$5c0571aa5b6fb5da$var$addYears(mutableDate, duration.years || 0);
|
|
40
40
|
if (mutableDate.calendar.balanceYearMonth) mutableDate.calendar.balanceYearMonth(mutableDate, date);
|
|
41
41
|
mutableDate.month += duration.months || 0;
|
|
@@ -114,7 +114,7 @@ function $5c0571aa5b6fb5da$export$c4e2ecac49351ef2(date) {
|
|
|
114
114
|
}
|
|
115
115
|
function $5c0571aa5b6fb5da$export$3e2544e88a25bff8(duration) {
|
|
116
116
|
let inverseDuration = {};
|
|
117
|
-
for(let key in duration)if (typeof duration[key] ===
|
|
117
|
+
for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key];
|
|
118
118
|
return inverseDuration;
|
|
119
119
|
}
|
|
120
120
|
function $5c0571aa5b6fb5da$export$4e2d2ead65e5f7e3(date, duration) {
|
|
@@ -178,18 +178,18 @@ function $5c0571aa5b6fb5da$export$fe34d3a381cd7501(time, duration) {
|
|
|
178
178
|
function $5c0571aa5b6fb5da$export$d52ced6badfb9a4c(value, field, amount, options) {
|
|
179
179
|
let mutable = value.copy();
|
|
180
180
|
switch(field){
|
|
181
|
-
case
|
|
181
|
+
case 'era':
|
|
182
182
|
{
|
|
183
183
|
let eras = value.calendar.getEras();
|
|
184
184
|
let eraIndex = eras.indexOf(value.era);
|
|
185
|
-
if (eraIndex < 0) throw new Error(
|
|
185
|
+
if (eraIndex < 0) throw new Error('Invalid era: ' + value.era);
|
|
186
186
|
eraIndex = $5c0571aa5b6fb5da$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options === null || options === void 0 ? void 0 : options.round);
|
|
187
187
|
mutable.era = eras[eraIndex];
|
|
188
188
|
// Constrain the year and other fields within the era, so the era doesn't change when we balance below.
|
|
189
189
|
$5c0571aa5b6fb5da$export$c4e2ecac49351ef2(mutable);
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
|
-
case
|
|
192
|
+
case 'year':
|
|
193
193
|
var _mutable_calendar_isInverseEra, _mutable_calendar;
|
|
194
194
|
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;
|
|
195
195
|
// The year field should not cycle within the era as that can cause weird behavior affecting other fields.
|
|
@@ -199,14 +199,14 @@ function $5c0571aa5b6fb5da$export$d52ced6badfb9a4c(value, field, amount, options
|
|
|
199
199
|
if (mutable.year === -Infinity) mutable.year = 1;
|
|
200
200
|
if (mutable.calendar.balanceYearMonth) mutable.calendar.balanceYearMonth(mutable, value);
|
|
201
201
|
break;
|
|
202
|
-
case
|
|
202
|
+
case 'month':
|
|
203
203
|
mutable.month = $5c0571aa5b6fb5da$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options === null || options === void 0 ? void 0 : options.round);
|
|
204
204
|
break;
|
|
205
|
-
case
|
|
205
|
+
case 'day':
|
|
206
206
|
mutable.day = $5c0571aa5b6fb5da$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options === null || options === void 0 ? void 0 : options.round);
|
|
207
207
|
break;
|
|
208
208
|
default:
|
|
209
|
-
throw new Error(
|
|
209
|
+
throw new Error('Unsupported field ' + field);
|
|
210
210
|
}
|
|
211
211
|
if (value.calendar.balanceDate) value.calendar.balanceDate(mutable);
|
|
212
212
|
$5c0571aa5b6fb5da$export$c4e2ecac49351ef2(mutable);
|
|
@@ -215,7 +215,7 @@ function $5c0571aa5b6fb5da$export$d52ced6badfb9a4c(value, field, amount, options
|
|
|
215
215
|
function $5c0571aa5b6fb5da$export$dd02b3e0007dfe28(value, field, amount, options) {
|
|
216
216
|
let mutable = value.copy();
|
|
217
217
|
switch(field){
|
|
218
|
-
case
|
|
218
|
+
case 'hour':
|
|
219
219
|
{
|
|
220
220
|
let hours = value.hour;
|
|
221
221
|
let min = 0;
|
|
@@ -228,17 +228,17 @@ function $5c0571aa5b6fb5da$export$dd02b3e0007dfe28(value, field, amount, options
|
|
|
228
228
|
mutable.hour = $5c0571aa5b6fb5da$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
|
|
229
229
|
break;
|
|
230
230
|
}
|
|
231
|
-
case
|
|
231
|
+
case 'minute':
|
|
232
232
|
mutable.minute = $5c0571aa5b6fb5da$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
|
|
233
233
|
break;
|
|
234
|
-
case
|
|
234
|
+
case 'second':
|
|
235
235
|
mutable.second = $5c0571aa5b6fb5da$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
|
|
236
236
|
break;
|
|
237
|
-
case
|
|
237
|
+
case 'millisecond':
|
|
238
238
|
mutable.millisecond = $5c0571aa5b6fb5da$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
|
|
239
239
|
break;
|
|
240
240
|
default:
|
|
241
|
-
throw new Error(
|
|
241
|
+
throw new Error('Unsupported field ' + field);
|
|
242
242
|
}
|
|
243
243
|
return mutable;
|
|
244
244
|
}
|
|
@@ -289,7 +289,7 @@ function $5c0571aa5b6fb5da$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
289
289
|
// 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
|
|
290
290
|
// offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.
|
|
291
291
|
switch(field){
|
|
292
|
-
case
|
|
292
|
+
case 'hour':
|
|
293
293
|
{
|
|
294
294
|
let min = 0;
|
|
295
295
|
let max = 23;
|
|
@@ -308,15 +308,15 @@ function $5c0571aa5b6fb5da$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
308
308
|
hour: min
|
|
309
309
|
}), new (0, $af14c9812fdceb33$exports.GregorianCalendar)());
|
|
310
310
|
let minAbsolute = [
|
|
311
|
-
(0, $4ae0260a69729f1d$exports.toAbsolute)(minDate, dateTime.timeZone,
|
|
312
|
-
(0, $4ae0260a69729f1d$exports.toAbsolute)(minDate, dateTime.timeZone,
|
|
311
|
+
(0, $4ae0260a69729f1d$exports.toAbsolute)(minDate, dateTime.timeZone, 'earlier'),
|
|
312
|
+
(0, $4ae0260a69729f1d$exports.toAbsolute)(minDate, dateTime.timeZone, 'later')
|
|
313
313
|
].filter((ms)=>(0, $4ae0260a69729f1d$exports.fromAbsolute)(ms, dateTime.timeZone).day === minDate.day)[0];
|
|
314
314
|
let maxDate = (0, $4ae0260a69729f1d$exports.toCalendar)($5c0571aa5b6fb5da$export$e5d5e1c1822b6e56(plainDateTime, {
|
|
315
315
|
hour: max
|
|
316
316
|
}), new (0, $af14c9812fdceb33$exports.GregorianCalendar)());
|
|
317
317
|
let maxAbsolute = [
|
|
318
|
-
(0, $4ae0260a69729f1d$exports.toAbsolute)(maxDate, dateTime.timeZone,
|
|
319
|
-
(0, $4ae0260a69729f1d$exports.toAbsolute)(maxDate, dateTime.timeZone,
|
|
318
|
+
(0, $4ae0260a69729f1d$exports.toAbsolute)(maxDate, dateTime.timeZone, 'earlier'),
|
|
319
|
+
(0, $4ae0260a69729f1d$exports.toAbsolute)(maxDate, dateTime.timeZone, 'later')
|
|
320
320
|
].filter((ms)=>(0, $4ae0260a69729f1d$exports.fromAbsolute)(ms, dateTime.timeZone).day === maxDate.day).pop();
|
|
321
321
|
// Since hours may repeat, we need to operate on the absolute time in milliseconds.
|
|
322
322
|
// This is done in hours from the Unix epoch so that cycleValue works correctly,
|
|
@@ -328,22 +328,22 @@ function $5c0571aa5b6fb5da$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
328
328
|
// Now compute the new timezone offset, and convert the absolute time back to local time.
|
|
329
329
|
return (0, $4ae0260a69729f1d$exports.toCalendar)((0, $4ae0260a69729f1d$exports.fromAbsolute)(ms, dateTime.timeZone), dateTime.calendar);
|
|
330
330
|
}
|
|
331
|
-
case
|
|
332
|
-
case
|
|
333
|
-
case
|
|
331
|
+
case 'minute':
|
|
332
|
+
case 'second':
|
|
333
|
+
case 'millisecond':
|
|
334
334
|
// @ts-ignore
|
|
335
335
|
return $5c0571aa5b6fb5da$export$dd02b3e0007dfe28(dateTime, field, amount, options);
|
|
336
|
-
case
|
|
337
|
-
case
|
|
338
|
-
case
|
|
339
|
-
case
|
|
336
|
+
case 'era':
|
|
337
|
+
case 'year':
|
|
338
|
+
case 'month':
|
|
339
|
+
case 'day':
|
|
340
340
|
{
|
|
341
341
|
let res = $5c0571aa5b6fb5da$export$d52ced6badfb9a4c((0, $4ae0260a69729f1d$exports.toCalendarDateTime)(dateTime), field, amount, options);
|
|
342
342
|
let ms = (0, $4ae0260a69729f1d$exports.toAbsolute)(res, dateTime.timeZone);
|
|
343
343
|
return (0, $4ae0260a69729f1d$exports.toCalendar)((0, $4ae0260a69729f1d$exports.fromAbsolute)(ms, dateTime.timeZone), dateTime.calendar);
|
|
344
344
|
}
|
|
345
345
|
default:
|
|
346
|
-
throw new Error(
|
|
346
|
+
throw new Error('Unsupported field ' + field);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
function $5c0571aa5b6fb5da$export$31b5430eb18be4f8(dateTime, fields, disambiguation) {
|
package/dist/manipulation.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./
|
|
|
16
16
|
const $735220c2d4774dd3$var$ONE_HOUR = 3600000;
|
|
17
17
|
function $735220c2d4774dd3$export$e16d8520af44a096(date, duration) {
|
|
18
18
|
let mutableDate = date.copy();
|
|
19
|
-
let days =
|
|
19
|
+
let days = 'hour' in mutableDate ? $735220c2d4774dd3$var$addTimeFields(mutableDate, duration) : 0;
|
|
20
20
|
$735220c2d4774dd3$var$addYears(mutableDate, duration.years || 0);
|
|
21
21
|
if (mutableDate.calendar.balanceYearMonth) mutableDate.calendar.balanceYearMonth(mutableDate, date);
|
|
22
22
|
mutableDate.month += duration.months || 0;
|
|
@@ -95,7 +95,7 @@ function $735220c2d4774dd3$export$c4e2ecac49351ef2(date) {
|
|
|
95
95
|
}
|
|
96
96
|
function $735220c2d4774dd3$export$3e2544e88a25bff8(duration) {
|
|
97
97
|
let inverseDuration = {};
|
|
98
|
-
for(let key in duration)if (typeof duration[key] ===
|
|
98
|
+
for(let key in duration)if (typeof duration[key] === 'number') inverseDuration[key] = -duration[key];
|
|
99
99
|
return inverseDuration;
|
|
100
100
|
}
|
|
101
101
|
function $735220c2d4774dd3$export$4e2d2ead65e5f7e3(date, duration) {
|
|
@@ -159,18 +159,18 @@ function $735220c2d4774dd3$export$fe34d3a381cd7501(time, duration) {
|
|
|
159
159
|
function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field, amount, options) {
|
|
160
160
|
let mutable = value.copy();
|
|
161
161
|
switch(field){
|
|
162
|
-
case
|
|
162
|
+
case 'era':
|
|
163
163
|
{
|
|
164
164
|
let eras = value.calendar.getEras();
|
|
165
165
|
let eraIndex = eras.indexOf(value.era);
|
|
166
|
-
if (eraIndex < 0) throw new Error(
|
|
166
|
+
if (eraIndex < 0) throw new Error('Invalid era: ' + value.era);
|
|
167
167
|
eraIndex = $735220c2d4774dd3$var$cycleValue(eraIndex, amount, 0, eras.length - 1, options === null || options === void 0 ? void 0 : options.round);
|
|
168
168
|
mutable.era = eras[eraIndex];
|
|
169
169
|
// Constrain the year and other fields within the era, so the era doesn't change when we balance below.
|
|
170
170
|
$735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
|
-
case
|
|
173
|
+
case 'year':
|
|
174
174
|
var _mutable_calendar_isInverseEra, _mutable_calendar;
|
|
175
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;
|
|
176
176
|
// The year field should not cycle within the era as that can cause weird behavior affecting other fields.
|
|
@@ -180,14 +180,14 @@ function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field, amount, options
|
|
|
180
180
|
if (mutable.year === -Infinity) mutable.year = 1;
|
|
181
181
|
if (mutable.calendar.balanceYearMonth) mutable.calendar.balanceYearMonth(mutable, value);
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
183
|
+
case 'month':
|
|
184
184
|
mutable.month = $735220c2d4774dd3$var$cycleValue(value.month, amount, 1, value.calendar.getMonthsInYear(value), options === null || options === void 0 ? void 0 : options.round);
|
|
185
185
|
break;
|
|
186
|
-
case
|
|
186
|
+
case 'day':
|
|
187
187
|
mutable.day = $735220c2d4774dd3$var$cycleValue(value.day, amount, 1, value.calendar.getDaysInMonth(value), options === null || options === void 0 ? void 0 : options.round);
|
|
188
188
|
break;
|
|
189
189
|
default:
|
|
190
|
-
throw new Error(
|
|
190
|
+
throw new Error('Unsupported field ' + field);
|
|
191
191
|
}
|
|
192
192
|
if (value.calendar.balanceDate) value.calendar.balanceDate(mutable);
|
|
193
193
|
$735220c2d4774dd3$export$c4e2ecac49351ef2(mutable);
|
|
@@ -196,7 +196,7 @@ function $735220c2d4774dd3$export$d52ced6badfb9a4c(value, field, amount, options
|
|
|
196
196
|
function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options) {
|
|
197
197
|
let mutable = value.copy();
|
|
198
198
|
switch(field){
|
|
199
|
-
case
|
|
199
|
+
case 'hour':
|
|
200
200
|
{
|
|
201
201
|
let hours = value.hour;
|
|
202
202
|
let min = 0;
|
|
@@ -209,17 +209,17 @@ function $735220c2d4774dd3$export$dd02b3e0007dfe28(value, field, amount, options
|
|
|
209
209
|
mutable.hour = $735220c2d4774dd3$var$cycleValue(hours, amount, min, max, options === null || options === void 0 ? void 0 : options.round);
|
|
210
210
|
break;
|
|
211
211
|
}
|
|
212
|
-
case
|
|
212
|
+
case 'minute':
|
|
213
213
|
mutable.minute = $735220c2d4774dd3$var$cycleValue(value.minute, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
215
|
+
case 'second':
|
|
216
216
|
mutable.second = $735220c2d4774dd3$var$cycleValue(value.second, amount, 0, 59, options === null || options === void 0 ? void 0 : options.round);
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
218
|
+
case 'millisecond':
|
|
219
219
|
mutable.millisecond = $735220c2d4774dd3$var$cycleValue(value.millisecond, amount, 0, 999, options === null || options === void 0 ? void 0 : options.round);
|
|
220
220
|
break;
|
|
221
221
|
default:
|
|
222
|
-
throw new Error(
|
|
222
|
+
throw new Error('Unsupported field ' + field);
|
|
223
223
|
}
|
|
224
224
|
return mutable;
|
|
225
225
|
}
|
|
@@ -270,7 +270,7 @@ function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
270
270
|
// 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
271
|
// offset changing in the case of a backward DST transition, or skipping an hour in the case of a forward DST transition.
|
|
272
272
|
switch(field){
|
|
273
|
-
case
|
|
273
|
+
case 'hour':
|
|
274
274
|
{
|
|
275
275
|
let min = 0;
|
|
276
276
|
let max = 23;
|
|
@@ -289,15 +289,15 @@ function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
289
289
|
hour: min
|
|
290
290
|
}), new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
|
|
291
291
|
let minAbsolute = [
|
|
292
|
-
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone,
|
|
293
|
-
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone,
|
|
292
|
+
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'earlier'),
|
|
293
|
+
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(minDate, dateTime.timeZone, 'later')
|
|
294
294
|
].filter((ms)=>(0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === minDate.day)[0];
|
|
295
295
|
let maxDate = (0, $11d87f3f76e88657$export$b4a036af3fc0b032)($735220c2d4774dd3$export$e5d5e1c1822b6e56(plainDateTime, {
|
|
296
296
|
hour: max
|
|
297
297
|
}), new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)());
|
|
298
298
|
let maxAbsolute = [
|
|
299
|
-
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone,
|
|
300
|
-
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone,
|
|
299
|
+
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'earlier'),
|
|
300
|
+
(0, $11d87f3f76e88657$export$5107c82f94518f5c)(maxDate, dateTime.timeZone, 'later')
|
|
301
301
|
].filter((ms)=>(0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone).day === maxDate.day).pop();
|
|
302
302
|
// Since hours may repeat, we need to operate on the absolute time in milliseconds.
|
|
303
303
|
// This is done in hours from the Unix epoch so that cycleValue works correctly,
|
|
@@ -309,22 +309,22 @@ function $735220c2d4774dd3$export$9a297d111fc86b79(dateTime, field, amount, opti
|
|
|
309
309
|
// Now compute the new timezone offset, and convert the absolute time back to local time.
|
|
310
310
|
return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)((0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
|
|
311
311
|
}
|
|
312
|
-
case
|
|
313
|
-
case
|
|
314
|
-
case
|
|
312
|
+
case 'minute':
|
|
313
|
+
case 'second':
|
|
314
|
+
case 'millisecond':
|
|
315
315
|
// @ts-ignore
|
|
316
316
|
return $735220c2d4774dd3$export$dd02b3e0007dfe28(dateTime, field, amount, options);
|
|
317
|
-
case
|
|
318
|
-
case
|
|
319
|
-
case
|
|
320
|
-
case
|
|
317
|
+
case 'era':
|
|
318
|
+
case 'year':
|
|
319
|
+
case 'month':
|
|
320
|
+
case 'day':
|
|
321
321
|
{
|
|
322
322
|
let res = $735220c2d4774dd3$export$d52ced6badfb9a4c((0, $11d87f3f76e88657$export$b21e0b124e224484)(dateTime), field, amount, options);
|
|
323
323
|
let ms = (0, $11d87f3f76e88657$export$5107c82f94518f5c)(res, dateTime.timeZone);
|
|
324
324
|
return (0, $11d87f3f76e88657$export$b4a036af3fc0b032)((0, $11d87f3f76e88657$export$1b96692a1ba042ac)(ms, dateTime.timeZone), dateTime.calendar);
|
|
325
325
|
}
|
|
326
326
|
default:
|
|
327
|
-
throw new Error(
|
|
327
|
+
throw new Error('Unsupported field ' + field);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
function $735220c2d4774dd3$export$31b5430eb18be4f8(dateTime, fields, disambiguation) {
|