@internationalized/date 3.12.1 → 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.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/private/CalendarDate.cjs +40 -10
- package/dist/private/CalendarDate.cjs.map +1 -1
- package/dist/private/CalendarDate.js +40 -10
- package/dist/private/CalendarDate.js.map +1 -1
- package/dist/private/CalendarDate.mjs +40 -10
- package/dist/private/CalendarDate.mjs.map +1 -1
- package/dist/private/DateFormatter.cjs +4 -1
- package/dist/private/DateFormatter.cjs.map +1 -1
- package/dist/private/DateFormatter.js +4 -1
- package/dist/private/DateFormatter.js.map +1 -1
- package/dist/private/DateFormatter.mjs +4 -1
- package/dist/private/DateFormatter.mjs.map +1 -1
- package/dist/private/calendars/BuddhistCalendar.cjs.map +1 -1
- package/dist/private/calendars/BuddhistCalendar.js.map +1 -1
- package/dist/private/calendars/BuddhistCalendar.mjs.map +1 -1
- package/dist/private/calendars/EthiopicCalendar.cjs +5 -5
- package/dist/private/calendars/EthiopicCalendar.cjs.map +1 -1
- package/dist/private/calendars/EthiopicCalendar.js +5 -5
- package/dist/private/calendars/EthiopicCalendar.js.map +1 -1
- package/dist/private/calendars/EthiopicCalendar.mjs +5 -5
- package/dist/private/calendars/EthiopicCalendar.mjs.map +1 -1
- package/dist/private/calendars/GregorianCalendar.cjs.map +1 -1
- package/dist/private/calendars/GregorianCalendar.js.map +1 -1
- package/dist/private/calendars/GregorianCalendar.mjs.map +1 -1
- package/dist/private/calendars/HebrewCalendar.cjs.map +1 -1
- package/dist/private/calendars/HebrewCalendar.js.map +1 -1
- package/dist/private/calendars/HebrewCalendar.mjs.map +1 -1
- package/dist/private/calendars/IndianCalendar.cjs.map +1 -1
- package/dist/private/calendars/IndianCalendar.js.map +1 -1
- package/dist/private/calendars/IndianCalendar.mjs.map +1 -1
- package/dist/private/calendars/IslamicCalendar.cjs.map +1 -1
- package/dist/private/calendars/IslamicCalendar.js.map +1 -1
- package/dist/private/calendars/IslamicCalendar.mjs.map +1 -1
- package/dist/private/calendars/JapaneseCalendar.cjs.map +1 -1
- package/dist/private/calendars/JapaneseCalendar.js.map +1 -1
- package/dist/private/calendars/JapaneseCalendar.mjs.map +1 -1
- package/dist/private/calendars/PersianCalendar.cjs.map +1 -1
- package/dist/private/calendars/PersianCalendar.js.map +1 -1
- package/dist/private/calendars/PersianCalendar.mjs.map +1 -1
- package/dist/private/calendars/TaiwanCalendar.cjs.map +1 -1
- package/dist/private/calendars/TaiwanCalendar.js.map +1 -1
- package/dist/private/calendars/TaiwanCalendar.mjs.map +1 -1
- package/dist/private/conversion.cjs.map +1 -1
- package/dist/private/conversion.js.map +1 -1
- package/dist/private/conversion.mjs.map +1 -1
- package/dist/private/createCalendar.cjs.map +1 -1
- package/dist/private/createCalendar.js.map +1 -1
- package/dist/private/createCalendar.mjs.map +1 -1
- package/dist/private/manipulation.cjs.map +1 -1
- package/dist/private/manipulation.js.map +1 -1
- package/dist/private/manipulation.mjs.map +1 -1
- package/dist/private/queries.cjs.map +1 -1
- package/dist/private/queries.js.map +1 -1
- package/dist/private/queries.mjs.map +1 -1
- package/dist/private/string.cjs.map +1 -1
- package/dist/private/string.js.map +1 -1
- package/dist/private/string.mjs.map +1 -1
- package/dist/private/utils.cjs.map +1 -1
- package/dist/private/utils.js.map +1 -1
- package/dist/private/utils.mjs.map +1 -1
- package/dist/types/src/CalendarDate.d.ts +40 -10
- package/dist/types/src/DateFormatter.d.ts +4 -1
- package/dist/types/src/calendars/GregorianCalendar.d.ts +3 -2
- package/dist/types/src/calendars/IslamicCalendar.d.ts +18 -15
- package/dist/types/src/calendars/JapaneseCalendar.d.ts +4 -3
- package/dist/types/src/conversion.d.ts +8 -5
- package/dist/types/src/queries.d.ts +8 -2
- package/dist/types/src/string.d.ts +5 -4
- package/dist/types/src/types.d.ts +7 -3
- package/package.json +16 -16
- package/src/CalendarDate.ts +213 -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 +10 -2
- package/src/manipulation.ts +133 -30
- package/src/queries.ts +56 -12
- package/src/string.ts +52 -25
- package/src/types.ts +73 -51
- package/src/utils.ts +1 -1
package/src/types.ts
CHANGED
|
@@ -14,27 +14,45 @@ import {CalendarDate} from './CalendarDate';
|
|
|
14
14
|
|
|
15
15
|
/** An interface that is compatible with any object with date fields. */
|
|
16
16
|
export interface AnyCalendarDate {
|
|
17
|
-
readonly calendar: Calendar
|
|
18
|
-
readonly era: string
|
|
19
|
-
readonly year: number
|
|
20
|
-
readonly month: number
|
|
21
|
-
readonly day: number
|
|
22
|
-
copy(): this
|
|
17
|
+
readonly calendar: Calendar;
|
|
18
|
+
readonly era: string;
|
|
19
|
+
readonly year: number;
|
|
20
|
+
readonly month: number;
|
|
21
|
+
readonly day: number;
|
|
22
|
+
copy(): this;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** An interface that is compatible with any object with time fields. */
|
|
26
26
|
export interface AnyTime {
|
|
27
|
-
readonly hour: number
|
|
28
|
-
readonly minute: number
|
|
29
|
-
readonly second: number
|
|
30
|
-
readonly millisecond: number
|
|
31
|
-
copy(): this
|
|
27
|
+
readonly hour: number;
|
|
28
|
+
readonly minute: number;
|
|
29
|
+
readonly second: number;
|
|
30
|
+
readonly millisecond: number;
|
|
31
|
+
copy(): this;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** An interface that is compatible with any object with both date and time fields. */
|
|
35
35
|
export interface AnyDateTime extends AnyCalendarDate, AnyTime {}
|
|
36
36
|
|
|
37
|
-
export type CalendarIdentifier =
|
|
37
|
+
export type CalendarIdentifier =
|
|
38
|
+
| 'gregory'
|
|
39
|
+
| 'buddhist'
|
|
40
|
+
| 'chinese'
|
|
41
|
+
| 'coptic'
|
|
42
|
+
| 'dangi'
|
|
43
|
+
| 'ethioaa'
|
|
44
|
+
| 'ethiopic'
|
|
45
|
+
| 'hebrew'
|
|
46
|
+
| 'indian'
|
|
47
|
+
| 'islamic'
|
|
48
|
+
| 'islamic-umalqura'
|
|
49
|
+
| 'islamic-tbla'
|
|
50
|
+
| 'islamic-civil'
|
|
51
|
+
| 'islamic-rgsa'
|
|
52
|
+
| 'iso8601'
|
|
53
|
+
| 'japanese'
|
|
54
|
+
| 'persian'
|
|
55
|
+
| 'roc';
|
|
38
56
|
|
|
39
57
|
/**
|
|
40
58
|
* The Calendar interface represents a calendar system, including information
|
|
@@ -43,101 +61,104 @@ export type CalendarIdentifier = 'gregory' | 'buddhist' | 'chinese' | 'coptic' |
|
|
|
43
61
|
*/
|
|
44
62
|
export interface Calendar {
|
|
45
63
|
/**
|
|
46
|
-
* A string identifier for the calendar, as defined by Unicode CLDR.
|
|
47
|
-
*
|
|
64
|
+
* A string identifier for the calendar, as defined by Unicode CLDR. See
|
|
65
|
+
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf#supported_calendar_types).
|
|
48
66
|
*/
|
|
49
|
-
identifier: CalendarIdentifier
|
|
67
|
+
identifier: CalendarIdentifier;
|
|
50
68
|
|
|
51
69
|
/** Creates a CalendarDate in this calendar from the given Julian day number. */
|
|
52
|
-
fromJulianDay(jd: number): CalendarDate
|
|
70
|
+
fromJulianDay(jd: number): CalendarDate;
|
|
53
71
|
/** Converts a date in this calendar to a Julian day number. */
|
|
54
|
-
toJulianDay(date: AnyCalendarDate): number
|
|
72
|
+
toJulianDay(date: AnyCalendarDate): number;
|
|
55
73
|
|
|
56
74
|
/** Returns the number of days in the month of the given date. */
|
|
57
|
-
getDaysInMonth(date: AnyCalendarDate): number
|
|
75
|
+
getDaysInMonth(date: AnyCalendarDate): number;
|
|
58
76
|
/** Returns the number of months in the year of the given date. */
|
|
59
|
-
getMonthsInYear(date: AnyCalendarDate): number
|
|
77
|
+
getMonthsInYear(date: AnyCalendarDate): number;
|
|
60
78
|
/** Returns the number of years in the era of the given date. */
|
|
61
|
-
getYearsInEra(date: AnyCalendarDate): number
|
|
79
|
+
getYearsInEra(date: AnyCalendarDate): number;
|
|
62
80
|
/** Returns a list of era identifiers for the calendar. */
|
|
63
|
-
getEras(): string[]
|
|
81
|
+
getEras(): string[];
|
|
64
82
|
|
|
65
83
|
/**
|
|
66
84
|
* Returns the minimum month number of the given date's year.
|
|
67
85
|
* Normally, this is 1, but in some calendars such as the Japanese,
|
|
68
86
|
* eras may begin in the middle of a year.
|
|
69
87
|
*/
|
|
70
|
-
getMinimumMonthInYear?(date: AnyCalendarDate): number
|
|
88
|
+
getMinimumMonthInYear?(date: AnyCalendarDate): number;
|
|
71
89
|
/**
|
|
72
90
|
* Returns the minimum day number of the given date's month.
|
|
73
91
|
* Normally, this is 1, but in some calendars such as the Japanese,
|
|
74
92
|
* eras may begin in the middle of a month.
|
|
75
93
|
*/
|
|
76
|
-
getMinimumDayInMonth?(date: AnyCalendarDate): number
|
|
94
|
+
getMinimumDayInMonth?(date: AnyCalendarDate): number;
|
|
77
95
|
/** Returns the maximum months across all years. */
|
|
78
|
-
getMaximumMonthsInYear(): number
|
|
96
|
+
getMaximumMonthsInYear(): number;
|
|
79
97
|
/** Returns the maximum days across all months. */
|
|
80
|
-
getMaximumDaysInMonth(): number
|
|
98
|
+
getMaximumDaysInMonth(): number;
|
|
81
99
|
/**
|
|
82
100
|
* Returns a date that is the first day of the month for the given date.
|
|
83
101
|
* This is used to determine the month that the given date falls in, if
|
|
84
|
-
* the calendar has months that do not align with the standard calendar months
|
|
102
|
+
* the calendar has months that do not align with the standard calendar months
|
|
85
103
|
* (e.g. fiscal calendars).
|
|
86
104
|
*/
|
|
87
|
-
getFormattableMonth?(date: AnyCalendarDate): CalendarDate
|
|
105
|
+
getFormattableMonth?(date: AnyCalendarDate): CalendarDate;
|
|
88
106
|
|
|
89
107
|
/** Returns whether the given calendar is the same as this calendar. */
|
|
90
|
-
isEqual?(calendar: Calendar): boolean
|
|
108
|
+
isEqual?(calendar: Calendar): boolean;
|
|
91
109
|
|
|
92
110
|
/** @private */
|
|
93
|
-
balanceDate?(date: AnyCalendarDate): void
|
|
111
|
+
balanceDate?(date: AnyCalendarDate): void;
|
|
94
112
|
/** @private */
|
|
95
|
-
balanceYearMonth?(date: AnyCalendarDate, previousDate: AnyCalendarDate): void
|
|
113
|
+
balanceYearMonth?(date: AnyCalendarDate, previousDate: AnyCalendarDate): void;
|
|
96
114
|
/** @private */
|
|
97
|
-
constrainDate?(date: AnyCalendarDate): void
|
|
115
|
+
constrainDate?(date: AnyCalendarDate): void;
|
|
98
116
|
/** @private */
|
|
99
|
-
isInverseEra?(date: AnyCalendarDate): boolean
|
|
117
|
+
isInverseEra?(date: AnyCalendarDate): boolean;
|
|
100
118
|
}
|
|
101
119
|
|
|
102
120
|
/** Represents an amount of time in calendar-specific units, for use when performing arithmetic. */
|
|
103
121
|
export interface DateDuration {
|
|
104
122
|
/** The number of years to add or subtract. */
|
|
105
|
-
years?: number
|
|
123
|
+
years?: number;
|
|
106
124
|
/** The number of months to add or subtract. */
|
|
107
|
-
months?: number
|
|
125
|
+
months?: number;
|
|
108
126
|
/** The number of weeks to add or subtract. */
|
|
109
|
-
weeks?: number
|
|
127
|
+
weeks?: number;
|
|
110
128
|
/** The number of days to add or subtract. */
|
|
111
|
-
days?: number
|
|
129
|
+
days?: number;
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
/** Represents an amount of time, for use whe performing arithmetic. */
|
|
115
133
|
export interface TimeDuration {
|
|
116
134
|
/** The number of hours to add or subtract. */
|
|
117
|
-
hours?: number
|
|
135
|
+
hours?: number;
|
|
118
136
|
/** The number of minutes to add or subtract. */
|
|
119
|
-
minutes?: number
|
|
137
|
+
minutes?: number;
|
|
120
138
|
/** The number of seconds to add or subtract. */
|
|
121
|
-
seconds?: number
|
|
139
|
+
seconds?: number;
|
|
122
140
|
/** The number of milliseconds to add or subtract. */
|
|
123
|
-
milliseconds?: number
|
|
141
|
+
milliseconds?: number;
|
|
124
142
|
}
|
|
125
143
|
|
|
126
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Represents an amount of time with both date and time components, for use when performing
|
|
146
|
+
* arithmetic.
|
|
147
|
+
*/
|
|
127
148
|
export interface DateTimeDuration extends DateDuration, TimeDuration {}
|
|
128
149
|
|
|
129
150
|
export interface DateFields {
|
|
130
|
-
era?: string
|
|
131
|
-
year?: number
|
|
132
|
-
month?: number
|
|
133
|
-
day?: number
|
|
151
|
+
era?: string;
|
|
152
|
+
year?: number;
|
|
153
|
+
month?: number;
|
|
154
|
+
day?: number;
|
|
134
155
|
}
|
|
135
156
|
|
|
136
157
|
export interface TimeFields {
|
|
137
|
-
hour?: number
|
|
138
|
-
minute?: number
|
|
139
|
-
second?: number
|
|
140
|
-
millisecond?: number
|
|
158
|
+
hour?: number;
|
|
159
|
+
minute?: number;
|
|
160
|
+
second?: number;
|
|
161
|
+
millisecond?: number;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
export type DateField = keyof DateFields;
|
|
@@ -147,7 +168,7 @@ export type Disambiguation = 'compatible' | 'earlier' | 'later' | 'reject';
|
|
|
147
168
|
|
|
148
169
|
export interface CycleOptions {
|
|
149
170
|
/** Whether to round the field value to the nearest interval of the amount. */
|
|
150
|
-
round?: boolean
|
|
171
|
+
round?: boolean;
|
|
151
172
|
}
|
|
152
173
|
|
|
153
174
|
export interface CycleTimeOptions extends CycleOptions {
|
|
@@ -155,7 +176,8 @@ export interface CycleTimeOptions extends CycleOptions {
|
|
|
155
176
|
* Whether to use 12 or 24 hour time. If 12 hour time is chosen, the resulting value
|
|
156
177
|
* will remain in the same day period as the original value (e.g. if the value is AM,
|
|
157
178
|
* the resulting value also be AM).
|
|
179
|
+
*
|
|
158
180
|
* @default 24
|
|
159
181
|
*/
|
|
160
|
-
hourCycle?: 12 | 24
|
|
182
|
+
hourCycle?: 12 | 24;
|
|
161
183
|
}
|