@internationalized/date 3.12.0 → 3.12.2
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/index.cjs +113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/private/CalendarDate.cjs +272 -0
- package/dist/private/CalendarDate.cjs.map +1 -0
- package/dist/private/CalendarDate.js +282 -0
- package/dist/private/CalendarDate.js.map +1 -0
- package/dist/private/CalendarDate.mjs +264 -0
- package/dist/private/CalendarDate.mjs.map +1 -0
- package/dist/{DateFormatter.main.js → private/DateFormatter.cjs} +31 -28
- package/dist/private/DateFormatter.cjs.map +1 -0
- package/dist/{DateFormatter.module.js → private/DateFormatter.js} +27 -24
- package/dist/private/DateFormatter.js.map +1 -0
- package/dist/{DateFormatter.mjs → private/DateFormatter.mjs} +31 -28
- package/dist/private/DateFormatter.mjs.map +1 -0
- package/dist/{BuddhistCalendar.main.js → private/calendars/BuddhistCalendar.cjs} +13 -13
- package/dist/{BuddhistCalendar.main.js.map → private/calendars/BuddhistCalendar.cjs.map} +1 -1
- package/dist/{BuddhistCalendar.module.js → private/calendars/BuddhistCalendar.js} +13 -13
- package/dist/{BuddhistCalendar.module.js.map → private/calendars/BuddhistCalendar.js.map} +1 -1
- package/dist/{BuddhistCalendar.mjs → private/calendars/BuddhistCalendar.mjs} +13 -13
- package/dist/private/calendars/BuddhistCalendar.mjs.map +1 -0
- package/dist/{EthiopicCalendar.main.js → private/calendars/EthiopicCalendar.cjs} +37 -37
- package/dist/private/calendars/EthiopicCalendar.cjs.map +1 -0
- package/dist/{EthiopicCalendar.module.js → private/calendars/EthiopicCalendar.js} +35 -35
- package/dist/private/calendars/EthiopicCalendar.js.map +1 -0
- package/dist/{EthiopicCalendar.mjs → private/calendars/EthiopicCalendar.mjs} +35 -35
- package/dist/private/calendars/EthiopicCalendar.mjs.map +1 -0
- package/dist/{GregorianCalendar.main.js → private/calendars/GregorianCalendar.cjs} +31 -31
- package/dist/private/calendars/GregorianCalendar.cjs.map +1 -0
- package/dist/{GregorianCalendar.module.js → private/calendars/GregorianCalendar.js} +27 -27
- package/dist/private/calendars/GregorianCalendar.js.map +1 -0
- package/dist/{GregorianCalendar.mjs → private/calendars/GregorianCalendar.mjs} +27 -27
- package/dist/private/calendars/GregorianCalendar.mjs.map +1 -0
- package/dist/{HebrewCalendar.main.js → private/calendars/HebrewCalendar.cjs} +44 -44
- package/dist/private/calendars/HebrewCalendar.cjs.map +1 -0
- package/dist/{HebrewCalendar.module.js → private/calendars/HebrewCalendar.js} +44 -44
- package/dist/private/calendars/HebrewCalendar.js.map +1 -0
- package/dist/{HebrewCalendar.mjs → private/calendars/HebrewCalendar.mjs} +44 -44
- package/dist/private/calendars/HebrewCalendar.mjs.map +1 -0
- package/dist/{IndianCalendar.main.js → private/calendars/IndianCalendar.cjs} +20 -20
- package/dist/private/calendars/IndianCalendar.cjs.map +1 -0
- package/dist/{IndianCalendar.module.js → private/calendars/IndianCalendar.js} +20 -20
- package/dist/private/calendars/IndianCalendar.js.map +1 -0
- package/dist/{IndianCalendar.mjs → private/calendars/IndianCalendar.mjs} +20 -20
- package/dist/private/calendars/IndianCalendar.mjs.map +1 -0
- package/dist/private/calendars/IslamicCalendar.cjs +168 -0
- package/dist/private/calendars/IslamicCalendar.cjs.map +1 -0
- package/dist/private/calendars/IslamicCalendar.js +161 -0
- package/dist/private/calendars/IslamicCalendar.js.map +1 -0
- package/dist/private/calendars/IslamicCalendar.mjs +161 -0
- package/dist/private/calendars/IslamicCalendar.mjs.map +1 -0
- package/dist/{JapaneseCalendar.main.js → private/calendars/JapaneseCalendar.cjs} +37 -37
- package/dist/private/calendars/JapaneseCalendar.cjs.map +1 -0
- package/dist/{JapaneseCalendar.module.js → private/calendars/JapaneseCalendar.js} +37 -37
- package/dist/private/calendars/JapaneseCalendar.js.map +1 -0
- package/dist/{JapaneseCalendar.mjs → private/calendars/JapaneseCalendar.mjs} +37 -37
- package/dist/private/calendars/JapaneseCalendar.mjs.map +1 -0
- package/dist/{PersianCalendar.main.js → private/calendars/PersianCalendar.cjs} +13 -13
- package/dist/private/calendars/PersianCalendar.cjs.map +1 -0
- package/dist/{PersianCalendar.module.js → private/calendars/PersianCalendar.js} +13 -13
- package/dist/private/calendars/PersianCalendar.js.map +1 -0
- package/dist/{PersianCalendar.mjs → private/calendars/PersianCalendar.mjs} +13 -13
- package/dist/private/calendars/PersianCalendar.mjs.map +1 -0
- package/dist/{TaiwanCalendar.main.js → private/calendars/TaiwanCalendar.cjs} +20 -20
- package/dist/{TaiwanCalendar.main.js.map → private/calendars/TaiwanCalendar.cjs.map} +1 -1
- package/dist/private/calendars/TaiwanCalendar.js +75 -0
- package/dist/{TaiwanCalendar.module.js.map → private/calendars/TaiwanCalendar.js.map} +1 -1
- package/dist/{TaiwanCalendar.mjs → private/calendars/TaiwanCalendar.mjs} +20 -20
- package/dist/private/calendars/TaiwanCalendar.mjs.map +1 -0
- package/dist/{conversion.main.js → private/conversion.cjs} +85 -85
- package/dist/private/conversion.cjs.map +1 -0
- package/dist/{conversion.module.js → private/conversion.js} +71 -71
- package/dist/private/conversion.js.map +1 -0
- package/dist/{conversion.mjs → private/conversion.mjs} +71 -71
- package/dist/private/conversion.mjs.map +1 -0
- package/dist/private/createCalendar.cjs +69 -0
- package/dist/private/createCalendar.cjs.map +1 -0
- package/dist/private/createCalendar.js +64 -0
- package/dist/private/createCalendar.js.map +1 -0
- package/dist/private/createCalendar.mjs +64 -0
- package/dist/private/createCalendar.mjs.map +1 -0
- package/dist/{manipulation.main.js → private/manipulation.cjs} +106 -109
- package/dist/private/manipulation.cjs.map +1 -0
- package/dist/{manipulation.mjs → private/manipulation.js} +88 -88
- package/dist/private/manipulation.js.map +1 -0
- package/dist/{manipulation.module.js → private/manipulation.mjs} +93 -96
- package/dist/private/manipulation.mjs.map +1 -0
- package/dist/private/queries.cjs +359 -0
- package/dist/private/queries.cjs.map +1 -0
- package/dist/private/queries.js +326 -0
- package/dist/private/queries.js.map +1 -0
- package/dist/private/queries.mjs +324 -0
- package/dist/private/queries.mjs.map +1 -0
- package/dist/private/string.cjs +181 -0
- package/dist/private/string.cjs.map +1 -0
- package/dist/{string.mjs → private/string.js} +64 -64
- package/dist/private/string.js.map +1 -0
- package/dist/private/string.mjs +166 -0
- package/dist/private/string.mjs.map +1 -0
- package/dist/{utils.main.js → private/utils.cjs} +3 -3
- package/dist/{utils.main.js.map → private/utils.cjs.map} +1 -1
- package/dist/{utils.module.js → private/utils.js} +3 -3
- package/dist/{utils.module.js.map → private/utils.js.map} +1 -1
- package/dist/{utils.mjs → private/utils.mjs} +3 -3
- package/dist/private/utils.mjs.map +1 -0
- package/dist/{weekStartData.main.js → private/weekStartData.cjs} +3 -3
- package/dist/{weekStartData.main.js.map → private/weekStartData.cjs.map} +1 -1
- package/dist/{weekStartData.module.js → private/weekStartData.js} +3 -3
- package/dist/{weekStartData.module.js.map → private/weekStartData.js.map} +1 -1
- package/dist/{weekStartData.mjs → private/weekStartData.mjs} +3 -3
- package/dist/private/weekStartData.mjs.map +1 -0
- package/dist/types/src/CalendarDate.d.ts +207 -0
- package/dist/types/src/DateFormatter.d.ts +24 -0
- package/dist/types/src/calendars/BuddhistCalendar.d.ts +16 -0
- package/dist/types/src/calendars/EthiopicCalendar.d.ts +45 -0
- package/dist/types/src/calendars/GregorianCalendar.d.ts +26 -0
- package/dist/types/src/calendars/HebrewCalendar.d.ts +21 -0
- package/dist/types/src/calendars/IndianCalendar.d.ts +17 -0
- package/dist/types/src/calendars/IslamicCalendar.d.ts +51 -0
- package/dist/types/src/calendars/JapaneseCalendar.d.ts +22 -0
- package/dist/types/src/calendars/PersianCalendar.d.ts +19 -0
- package/dist/types/src/calendars/TaiwanCalendar.d.ts +19 -0
- package/dist/types/src/conversion.d.ts +45 -0
- package/dist/types/src/createCalendar.d.ts +3 -0
- package/dist/types/src/index.d.ts +17 -0
- package/dist/types/src/manipulation.d.ts +25 -0
- package/dist/types/src/queries.d.ts +93 -0
- package/dist/types/src/string.d.ts +36 -0
- package/dist/types/src/types.d.ts +136 -0
- package/dist/types/src/utils.d.ts +4 -0
- package/dist/types/src/weekStartData.d.ts +97 -0
- package/package.json +33 -18
- package/src/CalendarDate.ts +215 -35
- package/src/DateFormatter.ts +36 -16
- package/src/calendars/BuddhistCalendar.ts +1 -6
- package/src/calendars/EthiopicCalendar.ts +6 -5
- package/src/calendars/GregorianCalendar.ts +11 -4
- package/src/calendars/HebrewCalendar.ts +8 -4
- package/src/calendars/IndianCalendar.ts +8 -3
- package/src/calendars/IslamicCalendar.ts +40 -25
- package/src/calendars/JapaneseCalendar.ts +18 -10
- package/src/calendars/PersianCalendar.ts +2 -4
- package/src/calendars/TaiwanCalendar.ts +2 -9
- package/src/conversion.ts +98 -25
- package/src/createCalendar.ts +10 -2
- package/src/index.ts +11 -2
- package/src/manipulation.ts +133 -30
- package/src/queries.ts +57 -15
- package/src/string.ts +52 -25
- package/src/types.ts +73 -51
- package/src/utils.ts +1 -1
- package/dist/CalendarDate.main.js +0 -260
- package/dist/CalendarDate.main.js.map +0 -1
- package/dist/CalendarDate.mjs +0 -252
- package/dist/CalendarDate.module.js +0 -252
- package/dist/CalendarDate.module.js.map +0 -1
- package/dist/DateFormatter.main.js.map +0 -1
- package/dist/DateFormatter.module.js.map +0 -1
- package/dist/EthiopicCalendar.main.js.map +0 -1
- package/dist/EthiopicCalendar.module.js.map +0 -1
- package/dist/GregorianCalendar.main.js.map +0 -1
- package/dist/GregorianCalendar.module.js.map +0 -1
- package/dist/HebrewCalendar.main.js.map +0 -1
- package/dist/HebrewCalendar.module.js.map +0 -1
- package/dist/IndianCalendar.main.js.map +0 -1
- package/dist/IndianCalendar.module.js.map +0 -1
- package/dist/IslamicCalendar.main.js +0 -168
- package/dist/IslamicCalendar.main.js.map +0 -1
- package/dist/IslamicCalendar.mjs +0 -161
- package/dist/IslamicCalendar.module.js +0 -161
- package/dist/IslamicCalendar.module.js.map +0 -1
- package/dist/JapaneseCalendar.main.js.map +0 -1
- package/dist/JapaneseCalendar.module.js.map +0 -1
- package/dist/PersianCalendar.main.js.map +0 -1
- package/dist/PersianCalendar.module.js.map +0 -1
- package/dist/TaiwanCalendar.module.js +0 -75
- package/dist/conversion.main.js.map +0 -1
- package/dist/conversion.module.js.map +0 -1
- package/dist/createCalendar.main.js +0 -69
- package/dist/createCalendar.main.js.map +0 -1
- package/dist/createCalendar.mjs +0 -64
- package/dist/createCalendar.module.js +0 -64
- package/dist/createCalendar.module.js.map +0 -1
- package/dist/import.mjs +0 -45
- package/dist/main.js +0 -113
- package/dist/main.js.map +0 -1
- package/dist/manipulation.main.js.map +0 -1
- package/dist/manipulation.module.js.map +0 -1
- package/dist/module.js +0 -45
- package/dist/module.js.map +0 -1
- package/dist/queries.main.js +0 -361
- package/dist/queries.main.js.map +0 -1
- package/dist/queries.mjs +0 -326
- package/dist/queries.module.js +0 -326
- package/dist/queries.module.js.map +0 -1
- package/dist/string.main.js +0 -190
- package/dist/string.main.js.map +0 -1
- package/dist/string.module.js +0 -175
- package/dist/string.module.js.map +0 -1
- package/dist/types.d.ts +0 -672
- package/dist/types.d.ts.map +0 -1
package/dist/CalendarDate.mjs
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import {add as $735220c2d4774dd3$export$e16d8520af44a096, addTime as $735220c2d4774dd3$export$7ed87b6bc2506470, addZoned as $735220c2d4774dd3$export$96b1d28349274637, constrain as $735220c2d4774dd3$export$c4e2ecac49351ef2, constrainTime as $735220c2d4774dd3$export$7555de1e070510cb, cycleDate as $735220c2d4774dd3$export$d52ced6badfb9a4c, cycleTime as $735220c2d4774dd3$export$dd02b3e0007dfe28, cycleZoned as $735220c2d4774dd3$export$9a297d111fc86b79, set as $735220c2d4774dd3$export$adaa4cf7ef1b65be, setTime as $735220c2d4774dd3$export$e5d5e1c1822b6e56, setZoned as $735220c2d4774dd3$export$31b5430eb18be4f8, subtract as $735220c2d4774dd3$export$4e2d2ead65e5f7e3, subtractTime as $735220c2d4774dd3$export$fe34d3a381cd7501, subtractZoned as $735220c2d4774dd3$export$6814caac34ca03c7} from "./manipulation.mjs";
|
|
2
|
-
import {compareDate as $14e0f24ef4ac5c92$export$68781ddf31c0090f, compareTime as $14e0f24ef4ac5c92$export$c19a80a9721b80f6} from "./queries.mjs";
|
|
3
|
-
import {dateTimeToString as $fae977aafc393c5c$export$4223de14708adc63, dateToString as $fae977aafc393c5c$export$60dfd74aa96791bd, timeToString as $fae977aafc393c5c$export$f59dee82248f5ad4, zonedDateTimeToString as $fae977aafc393c5c$export$bf79f1ebf4b18792} from "./string.mjs";
|
|
4
|
-
import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.mjs";
|
|
5
|
-
import {toCalendarDateTime as $11d87f3f76e88657$export$b21e0b124e224484, toDate as $11d87f3f76e88657$export$e67a095c620b86fe, toZoned as $11d87f3f76e88657$export$84c95a83c799e074, zonedToDate as $11d87f3f76e88657$export$83aac07b4c37b25} from "./conversion.mjs";
|
|
6
|
-
import {_ as $aksy1$_} from "@swc/helpers/_/_class_private_field_init";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $35ea8db9cb2ccb90$var$shiftArgs(args) {
|
|
25
|
-
let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
26
|
-
let era;
|
|
27
|
-
if (typeof args[0] === 'string') era = args.shift();
|
|
28
|
-
else {
|
|
29
|
-
let eras = calendar.getEras();
|
|
30
|
-
era = eras[eras.length - 1];
|
|
31
|
-
}
|
|
32
|
-
let year = args.shift();
|
|
33
|
-
let month = args.shift();
|
|
34
|
-
let day = args.shift();
|
|
35
|
-
return [
|
|
36
|
-
calendar,
|
|
37
|
-
era,
|
|
38
|
-
year,
|
|
39
|
-
month,
|
|
40
|
-
day
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
44
|
-
// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
|
|
45
|
-
// If that behavior is desired, use the AnyCalendarDate interface instead.
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
$35ea8db9cb2ccb90$var$_type = /*#__PURE__*/ new WeakMap();
|
|
48
|
-
class $35ea8db9cb2ccb90$export$99faa760c7908e4f {
|
|
49
|
-
/** Returns a copy of this date. */ copy() {
|
|
50
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day);
|
|
51
|
-
else return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day);
|
|
52
|
-
}
|
|
53
|
-
/** Returns a new `CalendarDate` with the given duration added to it. */ add(duration) {
|
|
54
|
-
return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
|
|
55
|
-
}
|
|
56
|
-
/** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(duration) {
|
|
57
|
-
return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
|
|
58
|
-
}
|
|
59
|
-
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
60
|
-
return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)(this, fields);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
|
|
64
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
65
|
-
*/ cycle(field, amount, options) {
|
|
66
|
-
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
67
|
-
}
|
|
68
|
-
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */ toDate(timeZone) {
|
|
69
|
-
return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone);
|
|
70
|
-
}
|
|
71
|
-
/** Converts the date to an ISO 8601 formatted string. */ toString() {
|
|
72
|
-
return (0, $fae977aafc393c5c$export$60dfd74aa96791bd)(this);
|
|
73
|
-
}
|
|
74
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
75
|
-
return (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
|
|
76
|
-
}
|
|
77
|
-
constructor(...args){
|
|
78
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type, {
|
|
79
|
-
writable: true,
|
|
80
|
-
value: void 0
|
|
81
|
-
});
|
|
82
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
83
|
-
this.calendar = calendar;
|
|
84
|
-
this.era = era;
|
|
85
|
-
this.year = year;
|
|
86
|
-
this.month = month;
|
|
87
|
-
this.day = day;
|
|
88
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
$35ea8db9cb2ccb90$var$_type1 = /*#__PURE__*/ new WeakMap();
|
|
94
|
-
class $35ea8db9cb2ccb90$export$680ea196effce5f {
|
|
95
|
-
/** Returns a copy of this time. */ copy() {
|
|
96
|
-
return new $35ea8db9cb2ccb90$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond);
|
|
97
|
-
}
|
|
98
|
-
/** Returns a new `Time` with the given duration added to it. */ add(duration) {
|
|
99
|
-
return (0, $735220c2d4774dd3$export$7ed87b6bc2506470)(this, duration);
|
|
100
|
-
}
|
|
101
|
-
/** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) {
|
|
102
|
-
return (0, $735220c2d4774dd3$export$fe34d3a381cd7501)(this, duration);
|
|
103
|
-
}
|
|
104
|
-
/** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
105
|
-
return (0, $735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns a new `Time` with the given field adjusted by a specified amount.
|
|
109
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
110
|
-
*/ cycle(field, amount, options) {
|
|
111
|
-
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
112
|
-
}
|
|
113
|
-
/** Converts the time to an ISO 8601 formatted string. */ toString() {
|
|
114
|
-
return (0, $fae977aafc393c5c$export$f59dee82248f5ad4)(this);
|
|
115
|
-
}
|
|
116
|
-
/** Compares this time with another. A negative result indicates that this time is before the given one, and a positive time indicates that it is after. */ compare(b) {
|
|
117
|
-
return (0, $14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, b);
|
|
118
|
-
}
|
|
119
|
-
constructor(hour = 0, minute = 0, second = 0, millisecond = 0){
|
|
120
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type1, {
|
|
121
|
-
writable: true,
|
|
122
|
-
value: void 0
|
|
123
|
-
});
|
|
124
|
-
this.hour = hour;
|
|
125
|
-
this.minute = minute;
|
|
126
|
-
this.second = second;
|
|
127
|
-
this.millisecond = millisecond;
|
|
128
|
-
(0, $735220c2d4774dd3$export$7555de1e070510cb)(this);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
$35ea8db9cb2ccb90$var$_type2 = /*#__PURE__*/ new WeakMap();
|
|
134
|
-
class $35ea8db9cb2ccb90$export$ca871e8dbb80966f {
|
|
135
|
-
/** Returns a copy of this date. */ copy() {
|
|
136
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
137
|
-
else return new $35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
138
|
-
}
|
|
139
|
-
/** Returns a new `CalendarDateTime` with the given duration added to it. */ add(duration) {
|
|
140
|
-
return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
|
|
141
|
-
}
|
|
142
|
-
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(duration) {
|
|
143
|
-
return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
|
|
144
|
-
}
|
|
145
|
-
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
146
|
-
return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)((0, $735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields), fields);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
|
|
150
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
151
|
-
*/ cycle(field, amount, options) {
|
|
152
|
-
switch(field){
|
|
153
|
-
case 'era':
|
|
154
|
-
case 'year':
|
|
155
|
-
case 'month':
|
|
156
|
-
case 'day':
|
|
157
|
-
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
158
|
-
default:
|
|
159
|
-
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(timeZone, disambiguation) {
|
|
163
|
-
return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone, disambiguation);
|
|
164
|
-
}
|
|
165
|
-
/** Converts the date to an ISO 8601 formatted string. */ toString() {
|
|
166
|
-
return (0, $fae977aafc393c5c$export$4223de14708adc63)(this);
|
|
167
|
-
}
|
|
168
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
169
|
-
let res = (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
|
|
170
|
-
if (res === 0) return (0, $14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, (0, $11d87f3f76e88657$export$b21e0b124e224484)(b));
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
constructor(...args){
|
|
174
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type2, {
|
|
175
|
-
writable: true,
|
|
176
|
-
value: void 0
|
|
177
|
-
});
|
|
178
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
179
|
-
this.calendar = calendar;
|
|
180
|
-
this.era = era;
|
|
181
|
-
this.year = year;
|
|
182
|
-
this.month = month;
|
|
183
|
-
this.day = day;
|
|
184
|
-
this.hour = args.shift() || 0;
|
|
185
|
-
this.minute = args.shift() || 0;
|
|
186
|
-
this.second = args.shift() || 0;
|
|
187
|
-
this.millisecond = args.shift() || 0;
|
|
188
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
192
|
-
// @ts-ignore
|
|
193
|
-
$35ea8db9cb2ccb90$var$_type3 = /*#__PURE__*/ new WeakMap();
|
|
194
|
-
class $35ea8db9cb2ccb90$export$d3b7288e7994edea {
|
|
195
|
-
/** Returns a copy of this date. */ copy() {
|
|
196
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$d3b7288e7994edea(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
197
|
-
else return new $35ea8db9cb2ccb90$export$d3b7288e7994edea(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
198
|
-
}
|
|
199
|
-
/** Returns a new `ZonedDateTime` with the given duration added to it. */ add(duration) {
|
|
200
|
-
return (0, $735220c2d4774dd3$export$96b1d28349274637)(this, duration);
|
|
201
|
-
}
|
|
202
|
-
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(duration) {
|
|
203
|
-
return (0, $735220c2d4774dd3$export$6814caac34ca03c7)(this, duration);
|
|
204
|
-
}
|
|
205
|
-
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields, disambiguation) {
|
|
206
|
-
return (0, $735220c2d4774dd3$export$31b5430eb18be4f8)(this, fields, disambiguation);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
|
|
210
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
211
|
-
*/ cycle(field, amount, options) {
|
|
212
|
-
return (0, $735220c2d4774dd3$export$9a297d111fc86b79)(this, field, amount, options);
|
|
213
|
-
}
|
|
214
|
-
/** Converts the date to a native JavaScript Date object. */ toDate() {
|
|
215
|
-
return (0, $11d87f3f76e88657$export$83aac07b4c37b25)(this);
|
|
216
|
-
}
|
|
217
|
-
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */ toString() {
|
|
218
|
-
return (0, $fae977aafc393c5c$export$bf79f1ebf4b18792)(this);
|
|
219
|
-
}
|
|
220
|
-
/** Converts the date to an ISO 8601 formatted string in UTC. */ toAbsoluteString() {
|
|
221
|
-
return this.toDate().toISOString();
|
|
222
|
-
}
|
|
223
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
224
|
-
// TODO: Is this a bad idea??
|
|
225
|
-
return this.toDate().getTime() - (0, $11d87f3f76e88657$export$84c95a83c799e074)(b, this.timeZone).toDate().getTime();
|
|
226
|
-
}
|
|
227
|
-
constructor(...args){
|
|
228
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type3, {
|
|
229
|
-
writable: true,
|
|
230
|
-
value: void 0
|
|
231
|
-
});
|
|
232
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
233
|
-
let timeZone = args.shift();
|
|
234
|
-
let offset = args.shift();
|
|
235
|
-
this.calendar = calendar;
|
|
236
|
-
this.era = era;
|
|
237
|
-
this.year = year;
|
|
238
|
-
this.month = month;
|
|
239
|
-
this.day = day;
|
|
240
|
-
this.timeZone = timeZone;
|
|
241
|
-
this.offset = offset;
|
|
242
|
-
this.hour = args.shift() || 0;
|
|
243
|
-
this.minute = args.shift() || 0;
|
|
244
|
-
this.second = args.shift() || 0;
|
|
245
|
-
this.millisecond = args.shift() || 0;
|
|
246
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
export {$35ea8db9cb2ccb90$export$99faa760c7908e4f as CalendarDate, $35ea8db9cb2ccb90$export$680ea196effce5f as Time, $35ea8db9cb2ccb90$export$ca871e8dbb80966f as CalendarDateTime, $35ea8db9cb2ccb90$export$d3b7288e7994edea as ZonedDateTime};
|
|
252
|
-
//# sourceMappingURL=CalendarDate.module.js.map
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import {add as $735220c2d4774dd3$export$e16d8520af44a096, addTime as $735220c2d4774dd3$export$7ed87b6bc2506470, addZoned as $735220c2d4774dd3$export$96b1d28349274637, constrain as $735220c2d4774dd3$export$c4e2ecac49351ef2, constrainTime as $735220c2d4774dd3$export$7555de1e070510cb, cycleDate as $735220c2d4774dd3$export$d52ced6badfb9a4c, cycleTime as $735220c2d4774dd3$export$dd02b3e0007dfe28, cycleZoned as $735220c2d4774dd3$export$9a297d111fc86b79, set as $735220c2d4774dd3$export$adaa4cf7ef1b65be, setTime as $735220c2d4774dd3$export$e5d5e1c1822b6e56, setZoned as $735220c2d4774dd3$export$31b5430eb18be4f8, subtract as $735220c2d4774dd3$export$4e2d2ead65e5f7e3, subtractTime as $735220c2d4774dd3$export$fe34d3a381cd7501, subtractZoned as $735220c2d4774dd3$export$6814caac34ca03c7} from "./manipulation.module.js";
|
|
2
|
-
import {compareDate as $14e0f24ef4ac5c92$export$68781ddf31c0090f, compareTime as $14e0f24ef4ac5c92$export$c19a80a9721b80f6} from "./queries.module.js";
|
|
3
|
-
import {dateTimeToString as $fae977aafc393c5c$export$4223de14708adc63, dateToString as $fae977aafc393c5c$export$60dfd74aa96791bd, timeToString as $fae977aafc393c5c$export$f59dee82248f5ad4, zonedDateTimeToString as $fae977aafc393c5c$export$bf79f1ebf4b18792} from "./string.module.js";
|
|
4
|
-
import {GregorianCalendar as $3b62074eb05584b2$export$80ee6245ec4f29ec} from "./GregorianCalendar.module.js";
|
|
5
|
-
import {toCalendarDateTime as $11d87f3f76e88657$export$b21e0b124e224484, toDate as $11d87f3f76e88657$export$e67a095c620b86fe, toZoned as $11d87f3f76e88657$export$84c95a83c799e074, zonedToDate as $11d87f3f76e88657$export$83aac07b4c37b25} from "./conversion.module.js";
|
|
6
|
-
import {_ as $aksy1$_} from "@swc/helpers/_/_class_private_field_init";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $35ea8db9cb2ccb90$var$shiftArgs(args) {
|
|
25
|
-
let calendar = typeof args[0] === 'object' ? args.shift() : new (0, $3b62074eb05584b2$export$80ee6245ec4f29ec)();
|
|
26
|
-
let era;
|
|
27
|
-
if (typeof args[0] === 'string') era = args.shift();
|
|
28
|
-
else {
|
|
29
|
-
let eras = calendar.getEras();
|
|
30
|
-
era = eras[eras.length - 1];
|
|
31
|
-
}
|
|
32
|
-
let year = args.shift();
|
|
33
|
-
let month = args.shift();
|
|
34
|
-
let day = args.shift();
|
|
35
|
-
return [
|
|
36
|
-
calendar,
|
|
37
|
-
era,
|
|
38
|
-
year,
|
|
39
|
-
month,
|
|
40
|
-
day
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
44
|
-
// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
|
|
45
|
-
// If that behavior is desired, use the AnyCalendarDate interface instead.
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
$35ea8db9cb2ccb90$var$_type = /*#__PURE__*/ new WeakMap();
|
|
48
|
-
class $35ea8db9cb2ccb90$export$99faa760c7908e4f {
|
|
49
|
-
/** Returns a copy of this date. */ copy() {
|
|
50
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.era, this.year, this.month, this.day);
|
|
51
|
-
else return new $35ea8db9cb2ccb90$export$99faa760c7908e4f(this.calendar, this.year, this.month, this.day);
|
|
52
|
-
}
|
|
53
|
-
/** Returns a new `CalendarDate` with the given duration added to it. */ add(duration) {
|
|
54
|
-
return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
|
|
55
|
-
}
|
|
56
|
-
/** Returns a new `CalendarDate` with the given duration subtracted from it. */ subtract(duration) {
|
|
57
|
-
return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
|
|
58
|
-
}
|
|
59
|
-
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
60
|
-
return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)(this, fields);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
|
|
64
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
65
|
-
*/ cycle(field, amount, options) {
|
|
66
|
-
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
67
|
-
}
|
|
68
|
-
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */ toDate(timeZone) {
|
|
69
|
-
return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone);
|
|
70
|
-
}
|
|
71
|
-
/** Converts the date to an ISO 8601 formatted string. */ toString() {
|
|
72
|
-
return (0, $fae977aafc393c5c$export$60dfd74aa96791bd)(this);
|
|
73
|
-
}
|
|
74
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
75
|
-
return (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
|
|
76
|
-
}
|
|
77
|
-
constructor(...args){
|
|
78
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type, {
|
|
79
|
-
writable: true,
|
|
80
|
-
value: void 0
|
|
81
|
-
});
|
|
82
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
83
|
-
this.calendar = calendar;
|
|
84
|
-
this.era = era;
|
|
85
|
-
this.year = year;
|
|
86
|
-
this.month = month;
|
|
87
|
-
this.day = day;
|
|
88
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
$35ea8db9cb2ccb90$var$_type1 = /*#__PURE__*/ new WeakMap();
|
|
94
|
-
class $35ea8db9cb2ccb90$export$680ea196effce5f {
|
|
95
|
-
/** Returns a copy of this time. */ copy() {
|
|
96
|
-
return new $35ea8db9cb2ccb90$export$680ea196effce5f(this.hour, this.minute, this.second, this.millisecond);
|
|
97
|
-
}
|
|
98
|
-
/** Returns a new `Time` with the given duration added to it. */ add(duration) {
|
|
99
|
-
return (0, $735220c2d4774dd3$export$7ed87b6bc2506470)(this, duration);
|
|
100
|
-
}
|
|
101
|
-
/** Returns a new `Time` with the given duration subtracted from it. */ subtract(duration) {
|
|
102
|
-
return (0, $735220c2d4774dd3$export$fe34d3a381cd7501)(this, duration);
|
|
103
|
-
}
|
|
104
|
-
/** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
105
|
-
return (0, $735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns a new `Time` with the given field adjusted by a specified amount.
|
|
109
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
110
|
-
*/ cycle(field, amount, options) {
|
|
111
|
-
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
112
|
-
}
|
|
113
|
-
/** Converts the time to an ISO 8601 formatted string. */ toString() {
|
|
114
|
-
return (0, $fae977aafc393c5c$export$f59dee82248f5ad4)(this);
|
|
115
|
-
}
|
|
116
|
-
/** Compares this time with another. A negative result indicates that this time is before the given one, and a positive time indicates that it is after. */ compare(b) {
|
|
117
|
-
return (0, $14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, b);
|
|
118
|
-
}
|
|
119
|
-
constructor(hour = 0, minute = 0, second = 0, millisecond = 0){
|
|
120
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type1, {
|
|
121
|
-
writable: true,
|
|
122
|
-
value: void 0
|
|
123
|
-
});
|
|
124
|
-
this.hour = hour;
|
|
125
|
-
this.minute = minute;
|
|
126
|
-
this.second = second;
|
|
127
|
-
this.millisecond = millisecond;
|
|
128
|
-
(0, $735220c2d4774dd3$export$7555de1e070510cb)(this);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
$35ea8db9cb2ccb90$var$_type2 = /*#__PURE__*/ new WeakMap();
|
|
134
|
-
class $35ea8db9cb2ccb90$export$ca871e8dbb80966f {
|
|
135
|
-
/** Returns a copy of this date. */ copy() {
|
|
136
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
137
|
-
else return new $35ea8db9cb2ccb90$export$ca871e8dbb80966f(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
138
|
-
}
|
|
139
|
-
/** Returns a new `CalendarDateTime` with the given duration added to it. */ add(duration) {
|
|
140
|
-
return (0, $735220c2d4774dd3$export$e16d8520af44a096)(this, duration);
|
|
141
|
-
}
|
|
142
|
-
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */ subtract(duration) {
|
|
143
|
-
return (0, $735220c2d4774dd3$export$4e2d2ead65e5f7e3)(this, duration);
|
|
144
|
-
}
|
|
145
|
-
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields) {
|
|
146
|
-
return (0, $735220c2d4774dd3$export$adaa4cf7ef1b65be)((0, $735220c2d4774dd3$export$e5d5e1c1822b6e56)(this, fields), fields);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
|
|
150
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
151
|
-
*/ cycle(field, amount, options) {
|
|
152
|
-
switch(field){
|
|
153
|
-
case 'era':
|
|
154
|
-
case 'year':
|
|
155
|
-
case 'month':
|
|
156
|
-
case 'day':
|
|
157
|
-
return (0, $735220c2d4774dd3$export$d52ced6badfb9a4c)(this, field, amount, options);
|
|
158
|
-
default:
|
|
159
|
-
return (0, $735220c2d4774dd3$export$dd02b3e0007dfe28)(this, field, amount, options);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/** Converts the date to a native JavaScript Date object in the given time zone. */ toDate(timeZone, disambiguation) {
|
|
163
|
-
return (0, $11d87f3f76e88657$export$e67a095c620b86fe)(this, timeZone, disambiguation);
|
|
164
|
-
}
|
|
165
|
-
/** Converts the date to an ISO 8601 formatted string. */ toString() {
|
|
166
|
-
return (0, $fae977aafc393c5c$export$4223de14708adc63)(this);
|
|
167
|
-
}
|
|
168
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
169
|
-
let res = (0, $14e0f24ef4ac5c92$export$68781ddf31c0090f)(this, b);
|
|
170
|
-
if (res === 0) return (0, $14e0f24ef4ac5c92$export$c19a80a9721b80f6)(this, (0, $11d87f3f76e88657$export$b21e0b124e224484)(b));
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
constructor(...args){
|
|
174
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type2, {
|
|
175
|
-
writable: true,
|
|
176
|
-
value: void 0
|
|
177
|
-
});
|
|
178
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
179
|
-
this.calendar = calendar;
|
|
180
|
-
this.era = era;
|
|
181
|
-
this.year = year;
|
|
182
|
-
this.month = month;
|
|
183
|
-
this.day = day;
|
|
184
|
-
this.hour = args.shift() || 0;
|
|
185
|
-
this.minute = args.shift() || 0;
|
|
186
|
-
this.second = args.shift() || 0;
|
|
187
|
-
this.millisecond = args.shift() || 0;
|
|
188
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
var // This prevents TypeScript from allowing other types with the same fields to match.
|
|
192
|
-
// @ts-ignore
|
|
193
|
-
$35ea8db9cb2ccb90$var$_type3 = /*#__PURE__*/ new WeakMap();
|
|
194
|
-
class $35ea8db9cb2ccb90$export$d3b7288e7994edea {
|
|
195
|
-
/** Returns a copy of this date. */ copy() {
|
|
196
|
-
if (this.era) return new $35ea8db9cb2ccb90$export$d3b7288e7994edea(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
197
|
-
else return new $35ea8db9cb2ccb90$export$d3b7288e7994edea(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
198
|
-
}
|
|
199
|
-
/** Returns a new `ZonedDateTime` with the given duration added to it. */ add(duration) {
|
|
200
|
-
return (0, $735220c2d4774dd3$export$96b1d28349274637)(this, duration);
|
|
201
|
-
}
|
|
202
|
-
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */ subtract(duration) {
|
|
203
|
-
return (0, $735220c2d4774dd3$export$6814caac34ca03c7)(this, duration);
|
|
204
|
-
}
|
|
205
|
-
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */ set(fields, disambiguation) {
|
|
206
|
-
return (0, $735220c2d4774dd3$export$31b5430eb18be4f8)(this, fields, disambiguation);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
|
|
210
|
-
* When the resulting value reaches the limits of the field, it wraps around.
|
|
211
|
-
*/ cycle(field, amount, options) {
|
|
212
|
-
return (0, $735220c2d4774dd3$export$9a297d111fc86b79)(this, field, amount, options);
|
|
213
|
-
}
|
|
214
|
-
/** Converts the date to a native JavaScript Date object. */ toDate() {
|
|
215
|
-
return (0, $11d87f3f76e88657$export$83aac07b4c37b25)(this);
|
|
216
|
-
}
|
|
217
|
-
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */ toString() {
|
|
218
|
-
return (0, $fae977aafc393c5c$export$bf79f1ebf4b18792)(this);
|
|
219
|
-
}
|
|
220
|
-
/** Converts the date to an ISO 8601 formatted string in UTC. */ toAbsoluteString() {
|
|
221
|
-
return this.toDate().toISOString();
|
|
222
|
-
}
|
|
223
|
-
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */ compare(b) {
|
|
224
|
-
// TODO: Is this a bad idea??
|
|
225
|
-
return this.toDate().getTime() - (0, $11d87f3f76e88657$export$84c95a83c799e074)(b, this.timeZone).toDate().getTime();
|
|
226
|
-
}
|
|
227
|
-
constructor(...args){
|
|
228
|
-
(0, $aksy1$_)(this, $35ea8db9cb2ccb90$var$_type3, {
|
|
229
|
-
writable: true,
|
|
230
|
-
value: void 0
|
|
231
|
-
});
|
|
232
|
-
let [calendar, era, year, month, day] = $35ea8db9cb2ccb90$var$shiftArgs(args);
|
|
233
|
-
let timeZone = args.shift();
|
|
234
|
-
let offset = args.shift();
|
|
235
|
-
this.calendar = calendar;
|
|
236
|
-
this.era = era;
|
|
237
|
-
this.year = year;
|
|
238
|
-
this.month = month;
|
|
239
|
-
this.day = day;
|
|
240
|
-
this.timeZone = timeZone;
|
|
241
|
-
this.offset = offset;
|
|
242
|
-
this.hour = args.shift() || 0;
|
|
243
|
-
this.minute = args.shift() || 0;
|
|
244
|
-
this.second = args.shift() || 0;
|
|
245
|
-
this.millisecond = args.shift() || 0;
|
|
246
|
-
(0, $735220c2d4774dd3$export$c4e2ecac49351ef2)(this);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
export {$35ea8db9cb2ccb90$export$99faa760c7908e4f as CalendarDate, $35ea8db9cb2ccb90$export$680ea196effce5f as Time, $35ea8db9cb2ccb90$export$ca871e8dbb80966f as CalendarDateTime, $35ea8db9cb2ccb90$export$d3b7288e7994edea as ZonedDateTime};
|
|
252
|
-
//# sourceMappingURL=CalendarDate.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AASD,SAAS,gCAAU,IAAW;IAC5B,IAAI,WAAqB,OAAO,IAAI,CAAC,EAAE,KAAK,WACxC,KAAK,KAAK,KACV,IAAI,CAAA,GAAA,yCAAgB;IAExB,IAAI;IACJ,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,UACrB,MAAM,KAAK,KAAK;SACX;QACL,IAAI,OAAO,SAAS,OAAO;QAC3B,MAAM,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE;IAC7B;IAEA,IAAI,OAAO,KAAK,KAAK;IACrB,IAAI,QAAQ,KAAK,KAAK;IACtB,IAAI,MAAM,KAAK,KAAK;IAEpB,OAAO;QAAC;QAAU;QAAK;QAAM;QAAO;KAAI;AAC1C;IAIE,oFAAoF;AACpF,2FAA2F;AAC3F,0EAA0E;AAC1E,aAAa;AACb;AALK,MAAM;IAoCX,iCAAiC,GACjC,OAAqB;QACnB,IAAI,IAAI,CAAC,GAAG,EACV,OAAO,IAAI,0CAAa,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG;aAEhF,OAAO,IAAI,0CAAa,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,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AAK,KAAK,MAAM;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,MAAM;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,MAAM;QAC9B,IAAI,CAAC,WAAW,GAAG,KAAK,KAAK,MAAM;QAEnC,CAAA,GAAA,yCAAQ,EAAE,IAAI;IAChB;AAsDF","sources":["packages/@internationalized/date/src/CalendarDate.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\nimport {add, addTime, addZoned, constrain, constrainTime, cycleDate, cycleTime, cycleZoned, set, setTime, setZoned, subtract, subtractTime, subtractZoned} from './manipulation';\nimport {AnyCalendarDate, AnyTime, Calendar, CycleOptions, CycleTimeOptions, DateDuration, DateField, DateFields, DateTimeDuration, Disambiguation, TimeDuration, TimeField, TimeFields} from './types';\nimport {compareDate, compareTime} from './queries';\nimport {dateTimeToString, dateToString, timeToString, zonedDateTimeToString} from './string';\nimport {GregorianCalendar} from './calendars/GregorianCalendar';\nimport {toCalendarDateTime, toDate, toZoned, zonedToDate} from './conversion';\n\nfunction shiftArgs(args: any[]) {\n let calendar: Calendar = typeof args[0] === 'object'\n ? args.shift()\n : new GregorianCalendar();\n\n let era: string;\n if (typeof args[0] === 'string') {\n era = args.shift();\n } else {\n let eras = calendar.getEras();\n era = eras[eras.length - 1];\n }\n\n let year = args.shift();\n let month = args.shift();\n let day = args.shift();\n\n return [calendar, era, year, month, day];\n}\n\n/** A CalendarDate represents a date without any time components in a specific calendar system. */\nexport class CalendarDate {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.\n // If that behavior is desired, use the AnyCalendarDate interface instead.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n\n constructor(year: number, month: number, day: number);\n constructor(era: string, year: number, month: number, day: number);\n constructor(calendar: Calendar, year: number, month: number, day: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDate {\n if (this.era) {\n return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);\n } else {\n return new CalendarDate(this.calendar, this.year, this.month, this.day);\n }\n }\n\n /** Returns a new `CalendarDate` with the given duration added to it. */\n add(duration: DateDuration): CalendarDate {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDate` with the given duration subtracted from it. */\n subtract(duration: DateDuration): CalendarDate {\n return subtract(this, duration);\n }\n\n /** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */\n set(fields: DateFields): CalendarDate {\n return set(this, fields);\n }\n\n /**\n * Returns a new `CalendarDate` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField, amount: number, options?: CycleOptions): CalendarDate {\n return cycleDate(this, field, amount, options);\n }\n\n /** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */\n toDate(timeZone: string): Date {\n return toDate(this, timeZone);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateToString(this);\n }\n\n /** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */\n compare(b: AnyCalendarDate): number {\n return compareDate(this, b);\n }\n}\n\n/** A Time represents a clock time without any date components. */\nexport class Time {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The hour, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(\n hour: number = 0,\n minute: number = 0,\n second: number = 0,\n millisecond: number = 0\n ) {\n this.hour = hour;\n this.minute = minute;\n this.second = second;\n this.millisecond = millisecond;\n constrainTime(this);\n }\n\n /** Returns a copy of this time. */\n copy(): Time {\n return new Time(this.hour, this.minute, this.second, this.millisecond);\n }\n\n /** Returns a new `Time` with the given duration added to it. */\n add(duration: TimeDuration): Time {\n return addTime(this, duration);\n }\n\n /** Returns a new `Time` with the given duration subtracted from it. */\n subtract(duration: TimeDuration): Time {\n return subtractTime(this, duration);\n }\n\n /** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */\n set(fields: TimeFields): Time {\n return setTime(this, fields);\n }\n\n /**\n * Returns a new `Time` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: TimeField, amount: number, options?: CycleTimeOptions): Time {\n return cycleTime(this, field, amount, options);\n }\n\n /** Converts the time to an ISO 8601 formatted string. */\n toString(): string {\n return timeToString(this);\n }\n\n /** Compares this time with another. A negative result indicates that this time is before the given one, and a positive time indicates that it is after. */\n compare(b: AnyTime): number {\n return compareTime(this, b);\n }\n}\n\n/** A CalendarDateTime represents a date and time without a time zone, in a specific calendar system. */\nexport class CalendarDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n\n constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(calendar: Calendar, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): CalendarDateTime {\n if (this.era) {\n return new CalendarDateTime(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);\n } else {\n return new CalendarDateTime(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);\n }\n }\n\n /** Returns a new `CalendarDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): CalendarDateTime {\n return add(this, duration);\n }\n\n /** Returns a new `CalendarDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): CalendarDateTime {\n return subtract(this, duration);\n }\n\n /** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */\n set(fields: DateFields & TimeFields): CalendarDateTime {\n return set(setTime(this, fields), fields);\n }\n\n /**\n * Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): CalendarDateTime {\n switch (field) {\n case 'era':\n case 'year':\n case 'month':\n case 'day':\n return cycleDate(this, field, amount, options);\n default:\n return cycleTime(this, field, amount, options);\n }\n }\n\n /** Converts the date to a native JavaScript Date object in the given time zone. */\n toDate(timeZone: string, disambiguation?: Disambiguation): Date {\n return toDate(this, timeZone, disambiguation);\n }\n\n /** Converts the date to an ISO 8601 formatted string. */\n toString(): string {\n return dateTimeToString(this);\n }\n\n /** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n let res = compareDate(this, b);\n if (res === 0) {\n return compareTime(this, toCalendarDateTime(b));\n }\n\n return res;\n }\n}\n\n/** A ZonedDateTime represents a date and time in a specific time zone and calendar system. */\nexport class ZonedDateTime {\n // This prevents TypeScript from allowing other types with the same fields to match.\n // @ts-ignore\n #type;\n /** The calendar system associated with this date, e.g. Gregorian. */\n public readonly calendar: Calendar;\n /** The calendar era for this date, e.g. \"BC\" or \"AD\". */\n public readonly era: string;\n /** The year of this date within the era. */\n public readonly year: number;\n /**\n * The month number within the year. Note that some calendar systems such as Hebrew\n * may have a variable number of months per year. Therefore, month numbers may not\n * always correspond to the same month names in different years.\n */\n public readonly month: number;\n /** The day number within the month. */\n public readonly day: number;\n /** The hour in the day, numbered from 0 to 23. */\n public readonly hour: number;\n /** The minute in the hour. */\n public readonly minute: number;\n /** The second in the minute. */\n public readonly second: number;\n /** The millisecond in the second. */\n public readonly millisecond: number;\n /** The IANA time zone identifier that this date and time is represented in. */\n public readonly timeZone: string;\n /** The UTC offset for this time, in milliseconds. */\n public readonly offset: number;\n\n constructor(year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(calendar: Calendar, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(calendar: Calendar, era: string, year: number, month: number, day: number, timeZone: string, offset: number, hour?: number, minute?: number, second?: number, millisecond?: number);\n constructor(...args: any[]) {\n let [calendar, era, year, month, day] = shiftArgs(args);\n let timeZone = args.shift();\n let offset = args.shift();\n this.calendar = calendar;\n this.era = era;\n this.year = year;\n this.month = month;\n this.day = day;\n this.timeZone = timeZone;\n this.offset = offset;\n this.hour = args.shift() || 0;\n this.minute = args.shift() || 0;\n this.second = args.shift() || 0;\n this.millisecond = args.shift() || 0;\n\n constrain(this);\n }\n\n /** Returns a copy of this date. */\n copy(): ZonedDateTime {\n if (this.era) {\n return new ZonedDateTime(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);\n } else {\n return new ZonedDateTime(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);\n }\n }\n\n /** Returns a new `ZonedDateTime` with the given duration added to it. */\n add(duration: DateTimeDuration): ZonedDateTime {\n return addZoned(this, duration);\n }\n\n /** Returns a new `ZonedDateTime` with the given duration subtracted from it. */\n subtract(duration: DateTimeDuration): ZonedDateTime {\n return subtractZoned(this, duration);\n }\n\n /** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */\n set(fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {\n return setZoned(this, fields, disambiguation);\n }\n\n /**\n * Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.\n * When the resulting value reaches the limits of the field, it wraps around.\n */\n cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {\n return cycleZoned(this, field, amount, options);\n }\n\n /** Converts the date to a native JavaScript Date object. */\n toDate(): Date {\n return zonedToDate(this);\n }\n\n /** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */\n toString(): string {\n return zonedDateTimeToString(this);\n }\n\n /** Converts the date to an ISO 8601 formatted string in UTC. */\n toAbsoluteString(): string {\n return this.toDate().toISOString();\n }\n\n /** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */\n compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {\n // TODO: Is this a bad idea??\n return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();\n }\n}\n"],"names":[],"version":3,"file":"CalendarDate.module.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAOlB,MAAM;IAUX,qGAAqG,GACrG,OAAO,KAAW,EAAU;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B;IAEA,4FAA4F,GAC5F,cAAc,KAAW,EAA6B;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;IACtC;IAEA,sCAAsC,GACtC,YAAY,KAAW,EAAE,GAAS,EAAU;QAC1C,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,YACxC,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO;QAG3C,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;QAGvB,wCAAwC;QACxC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,UAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM;IAC1E;IAEA,+CAA+C,GAC/C,mBAAmB,KAAW,EAAE,GAAS,EAAyB;QAChE,aAAa;QACb,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,KAAK,YAC/C,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO;QAGlD,IAAI,MAAM,OACR,MAAM,IAAI,WAAW;Q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SAAS,OAAO,OAAO,CAAC,0BAA0B;IAClD,UAAU,AAAC,CAAA,OAAO,QAAQ,CAAC,SAAS,KAAK,IAAG,IAAK;IACjD,IAAI,YAAY,6CAAuB,QAAQ;QAC7C,GAAG,OAAO;QACV,UAAU,UAAU,qBAAqB;IAC3C;IAEA,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IACzG,IAAI,MAAM,SAAS,UAAU,aAAa,CAAC,IAAI,KAAK,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IAE1G,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.DateTimeFormat>();\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /** Formats a date as a string according to the locale and format options passed to the constructor. */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as DateRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as DateRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions();\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(locale: string, options: Intl.DateTimeFormatOptions = {}): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions().hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value, 10);\n let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value, 10);\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.main.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,G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AAC,CAAA,IAAK,EAAE,IAAI,KAAK,QAAS,KAAK,EAAE;IAE1G,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,IAAI,QAAQ,KAAK,QAAQ,IACvB,OAAO;IAGT,IAAI,QAAQ,MAAM,QAAQ,IACxB,OAAO;IAGT,MAAM,IAAI,MAAM;AAClB","sources":["packages/@internationalized/date/src/DateFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.DateTimeFormat>();\n\ninterface DateRangeFormatPart extends Intl.DateTimeFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\n}\n\n/** A wrapper around Intl.DateTimeFormat that fixes various browser bugs, and polyfills new features. */\nexport class DateFormatter implements Intl.DateTimeFormat {\n private formatter: Intl.DateTimeFormat;\n private options: Intl.DateTimeFormatOptions;\n private resolvedHourCycle: Intl.DateTimeFormatOptions['hourCycle'];\n\n constructor(locale: string, options: Intl.DateTimeFormatOptions = {}) {\n this.formatter = getCachedDateFormatter(locale, options);\n this.options = options;\n }\n\n /** Formats a date as a string according to the locale and format options passed to the constructor. */\n format(value: Date): string {\n return this.formatter.format(value);\n }\n\n /** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */\n formatToParts(value: Date): Intl.DateTimeFormatPart[] {\n return this.formatter.formatToParts(value);\n }\n\n /** Formats a date range as a string. */\n formatRange(start: Date, end: Date): string {\n // @ts-ignore\n if (typeof this.formatter.formatRange === 'function') {\n // @ts-ignore\n return this.formatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.formatter.format(start)} – ${this.formatter.format(end)}`;\n }\n\n /** Formats a date range as an array of parts. */\n formatRangeToParts(start: Date, end: Date): DateRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.formatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.formatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.formatter.formatToParts(start);\n let endParts = this.formatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as DateRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as DateRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\n resolvedOptions(): Intl.ResolvedDateTimeFormatOptions {\n let resolvedOptions = this.formatter.resolvedOptions();\n if (hasBuggyResolvedHourCycle()) {\n if (!this.resolvedHourCycle) {\n this.resolvedHourCycle = getResolvedHourCycle(resolvedOptions.locale, this.options);\n }\n resolvedOptions.hourCycle = this.resolvedHourCycle;\n resolvedOptions.hour12 = this.resolvedHourCycle === 'h11' || this.resolvedHourCycle === 'h12';\n }\n\n // Safari uses a different name for the Ethiopic (Amete Alem) calendar.\n // https://bugs.webkit.org/show_bug.cgi?id=241564\n if (resolvedOptions.calendar === 'ethiopic-amete-alem') {\n resolvedOptions.calendar = 'ethioaa';\n }\n\n return resolvedOptions;\n }\n}\n\n// There are multiple bugs involving the hour12 and hourCycle options in various browser engines.\n// - Chrome [1] (and the ECMA 402 spec [2]) resolve hour12: false in English and other locales to h24 (24:00 - 23:59)\n// rather than h23 (00:00 - 23:59). Same can happen with hour12: true in French, which Chrome resolves to h11 (00:00 - 11:59)\n// rather than h12 (12:00 - 11:59).\n// - WebKit returns an incorrect hourCycle resolved option in the French locale due to incorrect parsing of 'h' literal\n// in the resolved pattern. It also formats incorrectly when specifying the hourCycle option for the same reason. [3]\n// [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1045791\n// [2] https://github.com/tc39/ecma402/issues/402\n// [3] https://bugs.webkit.org/show_bug.cgi?id=229313\n\n// https://github.com/unicode-org/cldr/blob/018b55eff7ceb389c7e3fc44e2f657eae3b10b38/common/supplemental/supplementalData.xml#L4774-L4802\nconst hour12Preferences = {\n true: {\n // Only Japanese uses the h11 style for 12 hour time. All others use h12.\n ja: 'h11'\n },\n false: {\n // All locales use h23 for 24 hour time. None use h24.\n }\n};\n\nfunction getCachedDateFormatter(locale: string, options: Intl.DateTimeFormatOptions = {}): Intl.DateTimeFormat {\n // Work around buggy hour12 behavior in Chrome / ECMA 402 spec by using hourCycle instead.\n // Only apply the workaround if the issue is detected, because the hourCycle option is buggy in Safari.\n if (typeof options.hour12 === 'boolean' && hasBuggyHour12Behavior()) {\n options = {...options};\n let pref = hour12Preferences[String(options.hour12)][locale.split('-')[0]];\n let defaultHourCycle = options.hour12 ? 'h12' : 'h23';\n options.hourCycle = pref ?? defaultHourCycle;\n delete options.hour12;\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey)!;\n }\n\n let numberFormatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\nlet _hasBuggyHour12Behavior: boolean | null = null;\nfunction hasBuggyHour12Behavior() {\n if (_hasBuggyHour12Behavior == null) {\n _hasBuggyHour12Behavior = new Intl.DateTimeFormat('en-US', {\n hour: 'numeric',\n hour12: false\n }).format(new Date(2020, 2, 3, 0)) === '24';\n }\n\n return _hasBuggyHour12Behavior;\n}\n\nlet _hasBuggyResolvedHourCycle: boolean | null = null;\nfunction hasBuggyResolvedHourCycle() {\n if (_hasBuggyResolvedHourCycle == null) {\n _hasBuggyResolvedHourCycle = new Intl.DateTimeFormat('fr', {\n hour: 'numeric',\n hour12: false\n }).resolvedOptions().hourCycle === 'h12';\n }\n\n return _hasBuggyResolvedHourCycle;\n}\n\nfunction getResolvedHourCycle(locale: string, options: Intl.DateTimeFormatOptions) {\n if (!options.timeStyle && !options.hour) {\n return undefined;\n }\n\n // Work around buggy results in resolved hourCycle and hour12 options in WebKit.\n // Format the minimum possible hour and maximum possible hour in a day and parse the results.\n locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, '');\n locale += (locale.includes('-u-') ? '' : '-u') + '-nu-latn';\n let formatter = getCachedDateFormatter(locale, {\n ...options,\n timeZone: undefined // use local timezone\n });\n\n let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find(p => p.type === 'hour')!.value, 10);\n let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find(p => p.type === 'hour')!.value, 10);\n\n if (min === 0 && max === 23) {\n return 'h23';\n }\n\n if (min === 24 && max === 23) {\n return 'h24';\n }\n\n if (min === 0 && max === 11) {\n return 'h11';\n }\n\n if (min === 12 && max === 11) {\n return 'h12';\n }\n\n throw new Error('Unexpected hour cycle result');\n}\n"],"names":[],"version":3,"file":"DateFormatter.module.js.map"}
|