@subrotosaha/datekit 1.0.0 → 1.2.0
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/README.md +484 -249
- package/dist/index.d.mts +125 -17
- package/dist/index.d.ts +125 -17
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,26 +19,33 @@ interface SetDateValues {
|
|
|
19
19
|
}
|
|
20
20
|
interface LocaleConfig {
|
|
21
21
|
name: string;
|
|
22
|
+
/** Text direction. Use this to apply CSS `direction` automatically for RTL languages (ar, ur). */
|
|
23
|
+
dir?: "ltr" | "rtl";
|
|
22
24
|
weekdays: string[];
|
|
23
25
|
weekdaysShort: string[];
|
|
24
26
|
weekdaysMin: string[];
|
|
25
27
|
months: string[];
|
|
26
28
|
monthsShort: string[];
|
|
27
29
|
ordinal: (n: number) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Relative-time strings. Multi-unit keys (mm, hh, dd, MM, yy) may be either
|
|
32
|
+
* a `string` with a `%d` placeholder OR a `(n: number) => string` function
|
|
33
|
+
* for languages with complex plural rules (e.g. Russian).
|
|
34
|
+
*/
|
|
28
35
|
relativeTime: {
|
|
29
36
|
future: string;
|
|
30
37
|
past: string;
|
|
31
38
|
s: string;
|
|
32
39
|
m: string;
|
|
33
|
-
mm: string;
|
|
40
|
+
mm: string | ((n: number) => string);
|
|
34
41
|
h: string;
|
|
35
|
-
hh: string;
|
|
42
|
+
hh: string | ((n: number) => string);
|
|
36
43
|
d: string;
|
|
37
|
-
dd: string;
|
|
44
|
+
dd: string | ((n: number) => string);
|
|
38
45
|
M: string;
|
|
39
|
-
MM: string;
|
|
46
|
+
MM: string | ((n: number) => string);
|
|
40
47
|
y: string;
|
|
41
|
-
yy: string;
|
|
48
|
+
yy: string | ((n: number) => string);
|
|
42
49
|
};
|
|
43
50
|
calendar: {
|
|
44
51
|
sameDay: string;
|
|
@@ -77,7 +84,13 @@ declare class Duration {
|
|
|
77
84
|
asWeeks(): number;
|
|
78
85
|
asMonths(): number;
|
|
79
86
|
asYears(): number;
|
|
80
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Returns a human-readable representation of this duration in the given locale.
|
|
89
|
+
* Delegates to the same locale-aware formatRelativeTime() used by fromNow()/toNow(),
|
|
90
|
+
* so all registered locales work automatically.
|
|
91
|
+
* Pass withoutSuffix=true to get "5 minutes" instead of "in 5 minutes" / "5 minutes ago".
|
|
92
|
+
*/
|
|
93
|
+
humanize(locale?: string, withoutSuffix?: boolean): string;
|
|
81
94
|
toObject(): DurationObject;
|
|
82
95
|
add(duration: Duration): Duration;
|
|
83
96
|
subtract(duration: Duration): Duration;
|
|
@@ -106,24 +119,27 @@ declare class DateKit {
|
|
|
106
119
|
toString(): string;
|
|
107
120
|
format(formatStr: string): string;
|
|
108
121
|
/**
|
|
109
|
-
* Parses a timezone-aware date
|
|
122
|
+
* Parses a timezone-aware date and formats it in the original timezone
|
|
110
123
|
* without applying timezone conversion. This ensures the local date components
|
|
111
124
|
* remain unchanged regardless of the timezone offset.
|
|
112
125
|
*
|
|
113
|
-
* @param
|
|
126
|
+
* @param dateInput - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
114
127
|
* @param formatStr - The format string for the output (e.g., "DD-MM-YYYY")
|
|
115
128
|
* @returns The formatted date string preserving the original timezone's date
|
|
116
129
|
*
|
|
117
130
|
* @example
|
|
118
131
|
* DateKit.formatFromTimezoneString("Sun Aug 31 2025 00:00:00 GMT+0600 (Bangladesh Standard Time)", "DD-MM-YYYY")
|
|
119
132
|
* // Returns: "31-08-2025"
|
|
133
|
+
* @example
|
|
134
|
+
* DateKit.formatFromTimezoneString(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
135
|
+
* // Returns: "31-08-2025"
|
|
120
136
|
*/
|
|
121
|
-
static formatFromTimezoneString(
|
|
137
|
+
static formatFromTimezoneString(dateInput: DateInput, formatStr: string): string;
|
|
122
138
|
/**
|
|
123
|
-
* Static method: Formats a timezone-aware date
|
|
139
|
+
* Static method: Formats a timezone-aware date with explicit GMT offset.
|
|
124
140
|
* Preserves the local date components from the specified timezone.
|
|
125
141
|
*
|
|
126
|
-
* @param input - The timezone-aware date
|
|
142
|
+
* @param input - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
127
143
|
* @param outputFormat - The format string for the output (default: "DD-MM-YYYY")
|
|
128
144
|
* @param locale - The locale for formatting (default: "en")
|
|
129
145
|
* @returns The formatted date string preserving the original timezone's date
|
|
@@ -131,13 +147,16 @@ declare class DateKit {
|
|
|
131
147
|
* @example
|
|
132
148
|
* DateKit.formatZonedDate("Sun Aug 31 2025 00:00:00 GMT+0600 (Bangladesh Standard Time)", "DD-MM-YYYY")
|
|
133
149
|
* // Returns: "31-08-2025"
|
|
150
|
+
* @example
|
|
151
|
+
* DateKit.formatZonedDate(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
152
|
+
* // Returns: "31-08-2025"
|
|
134
153
|
*/
|
|
135
|
-
static formatZonedDate(input:
|
|
154
|
+
static formatZonedDate(input: DateInput, outputFormat?: string, locale?: string): string;
|
|
136
155
|
/**
|
|
137
|
-
* Instance method: Formats a timezone-aware date
|
|
156
|
+
* Instance method: Formats a timezone-aware date using the instance's locale.
|
|
138
157
|
* Convenience wrapper around the static formatZonedDate method.
|
|
139
158
|
*
|
|
140
|
-
* @param input - The timezone-aware date string
|
|
159
|
+
* @param input - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
141
160
|
* @param outputFormat - The format string for the output (default: "DD-MM-YYYY")
|
|
142
161
|
* @returns The formatted date string preserving the original timezone's date
|
|
143
162
|
*
|
|
@@ -145,8 +164,12 @@ declare class DateKit {
|
|
|
145
164
|
* const dk = new DateKit('2025-01-15', { locale: 'es' });
|
|
146
165
|
* dk.formatZonedDate("Sun Aug 31 2025 00:00:00 GMT+0600", "DD-MM-YYYY")
|
|
147
166
|
* // Returns: "31-08-2025" (uses 'es' locale from instance)
|
|
167
|
+
* @example
|
|
168
|
+
* const dk = new DateKit('2025-01-15', { locale: 'es' });
|
|
169
|
+
* dk.formatZonedDate(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
170
|
+
* // Returns: "31-08-2025"
|
|
148
171
|
*/
|
|
149
|
-
formatZonedDate(input:
|
|
172
|
+
formatZonedDate(input: DateInput, outputFormat?: string): string;
|
|
150
173
|
/**
|
|
151
174
|
* Converts a date from one IANA timezone to another and formats it.
|
|
152
175
|
*
|
|
@@ -266,7 +289,10 @@ declare class DateKit {
|
|
|
266
289
|
addBusinessDays(days: number, holidays?: Date[]): DateKit;
|
|
267
290
|
subtractBusinessDays(days: number, holidays?: Date[]): DateKit;
|
|
268
291
|
businessDaysUntil(date: DateInput, holidays?: Date[]): number;
|
|
269
|
-
locale
|
|
292
|
+
/** Returns the active locale name when called with no argument. */
|
|
293
|
+
locale(): string;
|
|
294
|
+
/** Returns a new DateKit instance configured to use the given locale. */
|
|
295
|
+
locale(name: string): DateKit;
|
|
270
296
|
static eachDayOfInterval(interval: DateInterval): DateKit[];
|
|
271
297
|
static eachWeekOfInterval(interval: DateInterval): DateKit[];
|
|
272
298
|
static eachMonthOfInterval(interval: DateInterval): DateKit[];
|
|
@@ -278,13 +304,95 @@ declare class DateKit {
|
|
|
278
304
|
static min(...dates: DateInput[]): DateKit;
|
|
279
305
|
static isDuration(obj: any): obj is Duration;
|
|
280
306
|
static duration(value: number | DurationObject, unit?: string): Duration;
|
|
307
|
+
/**
|
|
308
|
+
* Parses a date string using an explicit format string.
|
|
309
|
+
*
|
|
310
|
+
* @param dateStr - The date string to parse, e.g. "15/08/2025"
|
|
311
|
+
* @param formatStr - The format, e.g. "DD/MM/YYYY"
|
|
312
|
+
* @param config - Optional DateKitConfig to attach to the result
|
|
313
|
+
* @returns A new DateKit instance
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* DateKit.parse("15-08-2025", "DD-MM-YYYY") // Aug 15 2025
|
|
317
|
+
* DateKit.parse("08/31/2025 02:30 PM", "MM/DD/YYYY hh:mm A") // Aug 31 14:30
|
|
318
|
+
* DateKit.parse("2025 W33", ...) // not supported — use ISO strings
|
|
319
|
+
*/
|
|
320
|
+
static parse(dateStr: string, formatStr: string, config?: DateKitConfig): DateKit;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Represents an inclusive date range [start, end].
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* const range = new DateRange("2025-01-01", "2025-12-31");
|
|
328
|
+
* range.contains("2025-06-15"); // true
|
|
329
|
+
* range.duration().asDays(); // 364
|
|
330
|
+
*/
|
|
331
|
+
declare class DateRange {
|
|
332
|
+
readonly start: DateKit;
|
|
333
|
+
readonly end: DateKit;
|
|
334
|
+
constructor(start: DateInput, end: DateInput);
|
|
335
|
+
/** Returns true if the given date falls within [start, end] (inclusive). */
|
|
336
|
+
contains(date: DateInput): boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Returns true if this range overlaps with another.
|
|
339
|
+
* Two ranges overlap unless one ends before the other starts.
|
|
340
|
+
*/
|
|
341
|
+
overlaps(other: DateRange): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Returns the overlapping range, or null if there is none.
|
|
344
|
+
*/
|
|
345
|
+
intersection(other: DateRange): DateRange | null;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the smallest range that covers both this range and other.
|
|
348
|
+
*/
|
|
349
|
+
union(other: DateRange): DateRange;
|
|
350
|
+
/** Duration of the range. */
|
|
351
|
+
duration(): Duration;
|
|
352
|
+
/**
|
|
353
|
+
* Returns every DateKit in the range at the given step size.
|
|
354
|
+
* Defaults to 1 day.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* range.toArray("month") // first day of each month in range
|
|
358
|
+
*/
|
|
359
|
+
toArray(unit?: TimeUnit): DateKit[];
|
|
360
|
+
/** Number of whole days in the range. */
|
|
361
|
+
days(): number;
|
|
362
|
+
toString(): string;
|
|
363
|
+
toJSON(): {
|
|
364
|
+
start: string;
|
|
365
|
+
end: string;
|
|
366
|
+
};
|
|
281
367
|
}
|
|
282
368
|
|
|
283
369
|
declare const en: LocaleConfig;
|
|
284
370
|
|
|
285
371
|
declare const es: LocaleConfig;
|
|
286
372
|
|
|
373
|
+
declare const fr: LocaleConfig;
|
|
374
|
+
|
|
375
|
+
declare const de: LocaleConfig;
|
|
376
|
+
|
|
377
|
+
declare const ar: LocaleConfig;
|
|
378
|
+
|
|
379
|
+
declare const zh: LocaleConfig;
|
|
380
|
+
|
|
381
|
+
declare const hi: LocaleConfig;
|
|
382
|
+
|
|
383
|
+
declare const bn: LocaleConfig;
|
|
384
|
+
|
|
385
|
+
declare const ur: LocaleConfig;
|
|
386
|
+
|
|
387
|
+
declare const pt: LocaleConfig;
|
|
388
|
+
|
|
389
|
+
declare const ja: LocaleConfig;
|
|
390
|
+
|
|
391
|
+
declare const ko: LocaleConfig;
|
|
392
|
+
|
|
393
|
+
declare const ru: LocaleConfig;
|
|
394
|
+
|
|
287
395
|
declare function getLocale(name: string): LocaleConfig;
|
|
288
396
|
declare function registerLocale(locale: LocaleConfig): void;
|
|
289
397
|
|
|
290
|
-
export { type DateInput, type DateInterval, DateKit, type DateKitConfig, Duration, type DurationObject, type LocaleConfig, type QuarterNumber, type SetDateValues, type TimeUnit, en, es, getLocale, registerLocale };
|
|
398
|
+
export { type DateInput, type DateInterval, DateKit, type DateKitConfig, DateRange, Duration, type DurationObject, type LocaleConfig, type QuarterNumber, type SetDateValues, type TimeUnit, ar, bn, de, en, es, fr, getLocale, hi, ja, ko, pt, registerLocale, ru, ur, zh };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,26 +19,33 @@ interface SetDateValues {
|
|
|
19
19
|
}
|
|
20
20
|
interface LocaleConfig {
|
|
21
21
|
name: string;
|
|
22
|
+
/** Text direction. Use this to apply CSS `direction` automatically for RTL languages (ar, ur). */
|
|
23
|
+
dir?: "ltr" | "rtl";
|
|
22
24
|
weekdays: string[];
|
|
23
25
|
weekdaysShort: string[];
|
|
24
26
|
weekdaysMin: string[];
|
|
25
27
|
months: string[];
|
|
26
28
|
monthsShort: string[];
|
|
27
29
|
ordinal: (n: number) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Relative-time strings. Multi-unit keys (mm, hh, dd, MM, yy) may be either
|
|
32
|
+
* a `string` with a `%d` placeholder OR a `(n: number) => string` function
|
|
33
|
+
* for languages with complex plural rules (e.g. Russian).
|
|
34
|
+
*/
|
|
28
35
|
relativeTime: {
|
|
29
36
|
future: string;
|
|
30
37
|
past: string;
|
|
31
38
|
s: string;
|
|
32
39
|
m: string;
|
|
33
|
-
mm: string;
|
|
40
|
+
mm: string | ((n: number) => string);
|
|
34
41
|
h: string;
|
|
35
|
-
hh: string;
|
|
42
|
+
hh: string | ((n: number) => string);
|
|
36
43
|
d: string;
|
|
37
|
-
dd: string;
|
|
44
|
+
dd: string | ((n: number) => string);
|
|
38
45
|
M: string;
|
|
39
|
-
MM: string;
|
|
46
|
+
MM: string | ((n: number) => string);
|
|
40
47
|
y: string;
|
|
41
|
-
yy: string;
|
|
48
|
+
yy: string | ((n: number) => string);
|
|
42
49
|
};
|
|
43
50
|
calendar: {
|
|
44
51
|
sameDay: string;
|
|
@@ -77,7 +84,13 @@ declare class Duration {
|
|
|
77
84
|
asWeeks(): number;
|
|
78
85
|
asMonths(): number;
|
|
79
86
|
asYears(): number;
|
|
80
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Returns a human-readable representation of this duration in the given locale.
|
|
89
|
+
* Delegates to the same locale-aware formatRelativeTime() used by fromNow()/toNow(),
|
|
90
|
+
* so all registered locales work automatically.
|
|
91
|
+
* Pass withoutSuffix=true to get "5 minutes" instead of "in 5 minutes" / "5 minutes ago".
|
|
92
|
+
*/
|
|
93
|
+
humanize(locale?: string, withoutSuffix?: boolean): string;
|
|
81
94
|
toObject(): DurationObject;
|
|
82
95
|
add(duration: Duration): Duration;
|
|
83
96
|
subtract(duration: Duration): Duration;
|
|
@@ -106,24 +119,27 @@ declare class DateKit {
|
|
|
106
119
|
toString(): string;
|
|
107
120
|
format(formatStr: string): string;
|
|
108
121
|
/**
|
|
109
|
-
* Parses a timezone-aware date
|
|
122
|
+
* Parses a timezone-aware date and formats it in the original timezone
|
|
110
123
|
* without applying timezone conversion. This ensures the local date components
|
|
111
124
|
* remain unchanged regardless of the timezone offset.
|
|
112
125
|
*
|
|
113
|
-
* @param
|
|
126
|
+
* @param dateInput - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
114
127
|
* @param formatStr - The format string for the output (e.g., "DD-MM-YYYY")
|
|
115
128
|
* @returns The formatted date string preserving the original timezone's date
|
|
116
129
|
*
|
|
117
130
|
* @example
|
|
118
131
|
* DateKit.formatFromTimezoneString("Sun Aug 31 2025 00:00:00 GMT+0600 (Bangladesh Standard Time)", "DD-MM-YYYY")
|
|
119
132
|
* // Returns: "31-08-2025"
|
|
133
|
+
* @example
|
|
134
|
+
* DateKit.formatFromTimezoneString(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
135
|
+
* // Returns: "31-08-2025"
|
|
120
136
|
*/
|
|
121
|
-
static formatFromTimezoneString(
|
|
137
|
+
static formatFromTimezoneString(dateInput: DateInput, formatStr: string): string;
|
|
122
138
|
/**
|
|
123
|
-
* Static method: Formats a timezone-aware date
|
|
139
|
+
* Static method: Formats a timezone-aware date with explicit GMT offset.
|
|
124
140
|
* Preserves the local date components from the specified timezone.
|
|
125
141
|
*
|
|
126
|
-
* @param input - The timezone-aware date
|
|
142
|
+
* @param input - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
127
143
|
* @param outputFormat - The format string for the output (default: "DD-MM-YYYY")
|
|
128
144
|
* @param locale - The locale for formatting (default: "en")
|
|
129
145
|
* @returns The formatted date string preserving the original timezone's date
|
|
@@ -131,13 +147,16 @@ declare class DateKit {
|
|
|
131
147
|
* @example
|
|
132
148
|
* DateKit.formatZonedDate("Sun Aug 31 2025 00:00:00 GMT+0600 (Bangladesh Standard Time)", "DD-MM-YYYY")
|
|
133
149
|
* // Returns: "31-08-2025"
|
|
150
|
+
* @example
|
|
151
|
+
* DateKit.formatZonedDate(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
152
|
+
* // Returns: "31-08-2025"
|
|
134
153
|
*/
|
|
135
|
-
static formatZonedDate(input:
|
|
154
|
+
static formatZonedDate(input: DateInput, outputFormat?: string, locale?: string): string;
|
|
136
155
|
/**
|
|
137
|
-
* Instance method: Formats a timezone-aware date
|
|
156
|
+
* Instance method: Formats a timezone-aware date using the instance's locale.
|
|
138
157
|
* Convenience wrapper around the static formatZonedDate method.
|
|
139
158
|
*
|
|
140
|
-
* @param input - The timezone-aware date string
|
|
159
|
+
* @param input - The timezone-aware date (can be Date, string, or number/timestamp)
|
|
141
160
|
* @param outputFormat - The format string for the output (default: "DD-MM-YYYY")
|
|
142
161
|
* @returns The formatted date string preserving the original timezone's date
|
|
143
162
|
*
|
|
@@ -145,8 +164,12 @@ declare class DateKit {
|
|
|
145
164
|
* const dk = new DateKit('2025-01-15', { locale: 'es' });
|
|
146
165
|
* dk.formatZonedDate("Sun Aug 31 2025 00:00:00 GMT+0600", "DD-MM-YYYY")
|
|
147
166
|
* // Returns: "31-08-2025" (uses 'es' locale from instance)
|
|
167
|
+
* @example
|
|
168
|
+
* const dk = new DateKit('2025-01-15', { locale: 'es' });
|
|
169
|
+
* dk.formatZonedDate(new Date("2025-08-31T00:00:00+06:00"), "DD-MM-YYYY")
|
|
170
|
+
* // Returns: "31-08-2025"
|
|
148
171
|
*/
|
|
149
|
-
formatZonedDate(input:
|
|
172
|
+
formatZonedDate(input: DateInput, outputFormat?: string): string;
|
|
150
173
|
/**
|
|
151
174
|
* Converts a date from one IANA timezone to another and formats it.
|
|
152
175
|
*
|
|
@@ -266,7 +289,10 @@ declare class DateKit {
|
|
|
266
289
|
addBusinessDays(days: number, holidays?: Date[]): DateKit;
|
|
267
290
|
subtractBusinessDays(days: number, holidays?: Date[]): DateKit;
|
|
268
291
|
businessDaysUntil(date: DateInput, holidays?: Date[]): number;
|
|
269
|
-
locale
|
|
292
|
+
/** Returns the active locale name when called with no argument. */
|
|
293
|
+
locale(): string;
|
|
294
|
+
/** Returns a new DateKit instance configured to use the given locale. */
|
|
295
|
+
locale(name: string): DateKit;
|
|
270
296
|
static eachDayOfInterval(interval: DateInterval): DateKit[];
|
|
271
297
|
static eachWeekOfInterval(interval: DateInterval): DateKit[];
|
|
272
298
|
static eachMonthOfInterval(interval: DateInterval): DateKit[];
|
|
@@ -278,13 +304,95 @@ declare class DateKit {
|
|
|
278
304
|
static min(...dates: DateInput[]): DateKit;
|
|
279
305
|
static isDuration(obj: any): obj is Duration;
|
|
280
306
|
static duration(value: number | DurationObject, unit?: string): Duration;
|
|
307
|
+
/**
|
|
308
|
+
* Parses a date string using an explicit format string.
|
|
309
|
+
*
|
|
310
|
+
* @param dateStr - The date string to parse, e.g. "15/08/2025"
|
|
311
|
+
* @param formatStr - The format, e.g. "DD/MM/YYYY"
|
|
312
|
+
* @param config - Optional DateKitConfig to attach to the result
|
|
313
|
+
* @returns A new DateKit instance
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* DateKit.parse("15-08-2025", "DD-MM-YYYY") // Aug 15 2025
|
|
317
|
+
* DateKit.parse("08/31/2025 02:30 PM", "MM/DD/YYYY hh:mm A") // Aug 31 14:30
|
|
318
|
+
* DateKit.parse("2025 W33", ...) // not supported — use ISO strings
|
|
319
|
+
*/
|
|
320
|
+
static parse(dateStr: string, formatStr: string, config?: DateKitConfig): DateKit;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Represents an inclusive date range [start, end].
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* const range = new DateRange("2025-01-01", "2025-12-31");
|
|
328
|
+
* range.contains("2025-06-15"); // true
|
|
329
|
+
* range.duration().asDays(); // 364
|
|
330
|
+
*/
|
|
331
|
+
declare class DateRange {
|
|
332
|
+
readonly start: DateKit;
|
|
333
|
+
readonly end: DateKit;
|
|
334
|
+
constructor(start: DateInput, end: DateInput);
|
|
335
|
+
/** Returns true if the given date falls within [start, end] (inclusive). */
|
|
336
|
+
contains(date: DateInput): boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Returns true if this range overlaps with another.
|
|
339
|
+
* Two ranges overlap unless one ends before the other starts.
|
|
340
|
+
*/
|
|
341
|
+
overlaps(other: DateRange): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Returns the overlapping range, or null if there is none.
|
|
344
|
+
*/
|
|
345
|
+
intersection(other: DateRange): DateRange | null;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the smallest range that covers both this range and other.
|
|
348
|
+
*/
|
|
349
|
+
union(other: DateRange): DateRange;
|
|
350
|
+
/** Duration of the range. */
|
|
351
|
+
duration(): Duration;
|
|
352
|
+
/**
|
|
353
|
+
* Returns every DateKit in the range at the given step size.
|
|
354
|
+
* Defaults to 1 day.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* range.toArray("month") // first day of each month in range
|
|
358
|
+
*/
|
|
359
|
+
toArray(unit?: TimeUnit): DateKit[];
|
|
360
|
+
/** Number of whole days in the range. */
|
|
361
|
+
days(): number;
|
|
362
|
+
toString(): string;
|
|
363
|
+
toJSON(): {
|
|
364
|
+
start: string;
|
|
365
|
+
end: string;
|
|
366
|
+
};
|
|
281
367
|
}
|
|
282
368
|
|
|
283
369
|
declare const en: LocaleConfig;
|
|
284
370
|
|
|
285
371
|
declare const es: LocaleConfig;
|
|
286
372
|
|
|
373
|
+
declare const fr: LocaleConfig;
|
|
374
|
+
|
|
375
|
+
declare const de: LocaleConfig;
|
|
376
|
+
|
|
377
|
+
declare const ar: LocaleConfig;
|
|
378
|
+
|
|
379
|
+
declare const zh: LocaleConfig;
|
|
380
|
+
|
|
381
|
+
declare const hi: LocaleConfig;
|
|
382
|
+
|
|
383
|
+
declare const bn: LocaleConfig;
|
|
384
|
+
|
|
385
|
+
declare const ur: LocaleConfig;
|
|
386
|
+
|
|
387
|
+
declare const pt: LocaleConfig;
|
|
388
|
+
|
|
389
|
+
declare const ja: LocaleConfig;
|
|
390
|
+
|
|
391
|
+
declare const ko: LocaleConfig;
|
|
392
|
+
|
|
393
|
+
declare const ru: LocaleConfig;
|
|
394
|
+
|
|
287
395
|
declare function getLocale(name: string): LocaleConfig;
|
|
288
396
|
declare function registerLocale(locale: LocaleConfig): void;
|
|
289
397
|
|
|
290
|
-
export { type DateInput, type DateInterval, DateKit, type DateKitConfig, Duration, type DurationObject, type LocaleConfig, type QuarterNumber, type SetDateValues, type TimeUnit, en, es, getLocale, registerLocale };
|
|
398
|
+
export { type DateInput, type DateInterval, DateKit, type DateKitConfig, DateRange, Duration, type DurationObject, type LocaleConfig, type QuarterNumber, type SetDateValues, type TimeUnit, ar, bn, de, en, es, fr, getLocale, hi, ja, ko, pt, registerLocale, ru, ur, zh };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var J=(r,t)=>{for(var e in t)Y(r,e,{get:t[e],enumerable:!0})},R=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of B(t))!Q.call(r,a)&&a!==e&&Y(r,a,{get:()=>t[a],enumerable:!(n=Z(t,a))||n.enumerable});return r};var V=r=>R(Y({},"__esModule",{value:!0}),r);var P={};J(P,{DateKit:()=>p,Duration:()=>f,en:()=>L,es:()=>x,getLocale:()=>M,registerLocale:()=>W});module.exports=V(P);var L={name:"en",weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekdaysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinal:r=>{let t=["th","st","nd","rd"],e=r%100;return r+(t[(e-20)%10]||t[e]||t[0])},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"}};var x={name:"es",weekdays:["Domingo","Lunes","Martes","Mi\xE9rcoles","Jueves","Viernes","S\xE1bado"],weekdaysShort:["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"],weekdaysMin:["Do","Lu","Ma","Mi","Ju","Vi","S\xE1"],months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthsShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],ordinal:r=>`${r}\xBA`,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un d\xEDa",dd:"%d d\xEDas",M:"un mes",MM:"%d meses",y:"un a\xF1o",yy:"%d a\xF1os"},calendar:{sameDay:"[Hoy a las] LT",nextDay:"[Ma\xF1ana a las] LT",nextWeek:"dddd [a las] LT",lastDay:"[Ayer a las] LT",lastWeek:"[El] dddd [pasado a las] LT",sameElse:"L"}};var K={en:L,es:x};function M(r){return K[r]||K.en}function W(r){K[r.name]=r}function E(r,t,e="en"){let n=M(e),a=r.getUTCFullYear(),s=r.getUTCMonth(),o=r.getUTCDate(),i=r.getUTCHours(),c=r.getUTCMinutes(),d=r.getUTCSeconds(),h=r.getUTCMilliseconds(),m=r.getUTCDay(),u=new Date(Date.UTC(a,0,1)),D=Math.floor((r.getTime()-u.getTime())/864e5)+1,g=Math.floor(s/3)+1,T=q(r),k=new Map,w=new Map,y={YYYY:a.toString(),YY:a.toString().slice(-2),Qo:n.ordinal(g),Q:g.toString(),MMMM:n.months[s],MMM:n.monthsShort[s],Mo:n.ordinal(s+1),MM:(s+1).toString().padStart(2,"0"),M:(s+1).toString(),Wo:n.ordinal(T),WW:T.toString().padStart(2,"0"),W:T.toString(),DDDo:n.ordinal(D),DDDD:D.toString().padStart(3,"0"),DDD:D.toString(),Do:n.ordinal(o),DD:o.toString().padStart(2,"0"),D:o.toString(),dddd:n.weekdays[m],ddd:n.weekdaysShort[m],do:n.ordinal(m),dd:n.weekdaysMin[m],d:m.toString(),HH:i.toString().padStart(2,"0"),H:i.toString(),hh:(i%12||12).toString().padStart(2,"0"),h:(i%12||12).toString(),mm:c.toString().padStart(2,"0"),m:c.toString(),ss:d.toString().padStart(2,"0"),s:d.toString(),SSS:h.toString().padStart(3,"0"),SS:h.toString().padStart(2,"0").slice(0,2),S:Math.floor(h/100).toString(),A:i>=12?"PM":"AM",a:i>=12?"pm":"am",Z:v(r.getTimezoneOffset()),ZZ:v(r.getTimezoneOffset()).replace(":",""),X:Math.floor(r.getTime()/1e3).toString(),x:r.getTime().toString()},S=t;return Object.keys(y).sort((b,U)=>U.length-b.length).forEach((b,U)=>{let N=`\0${U}\0`,$=new RegExp(b,"g");S=S.replace($,N),w.set(N,y[b])}),w.forEach((b,U)=>{S=S.replace(new RegExp(U,"g"),b)}),S}function q(r){let t=new Date(r.getTime());t.setUTCHours(0,0,0,0),t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));let e=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-e.getTime())/864e5+1)/7)}function v(r){let t=r<=0?"+":"-",e=Math.abs(r),n=Math.floor(e/60),a=e%60;return`${t}${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function l(r){if(r instanceof Date)return new Date(r);if(typeof r=="number")return new Date(r);if(typeof r=="string")return new Date(r);throw new Error("Invalid date input")}function C(r){return r instanceof Date&&!isNaN(r.getTime())}function I(r,t="en",e=!1){let n=M(t),a=r<0,o=Math.abs(r)/1e3,i=o/60,c=i/60,d=c/24,h=d/30.44,m=d/365.25,u;return o<45?u=n.relativeTime.s:o<90?u=n.relativeTime.m:i<45?u=n.relativeTime.mm.replace("%d",Math.round(i).toString()):i<90?u=n.relativeTime.h:c<22?u=n.relativeTime.hh.replace("%d",Math.round(c).toString()):c<36?u=n.relativeTime.d:d<25?u=n.relativeTime.dd.replace("%d",Math.round(d).toString()):d<45?u=n.relativeTime.M:d<345?u=n.relativeTime.MM.replace("%d",Math.round(h).toString()):m<1.5?u=n.relativeTime.y:u=n.relativeTime.yy.replace("%d",Math.round(m).toString()),e?u:(a?n.relativeTime.future:n.relativeTime.past).replace("%s",u)}function H(r,t=new Date,e="en"){let n=M(e),a=new p(r),s=new p(t),o=a.startOf("day").diff(s.startOf("day").toDate(),"day"),i;return o===0?i=n.calendar.sameDay:o===1?i=n.calendar.nextDay:o===-1?i=n.calendar.lastDay:o>1&&o<=7?i=n.calendar.nextWeek:o<-1&&o>=-7?i=n.calendar.lastWeek:i=n.calendar.sameElse,i=i.replace("[","").replace("]","").replace("LT",a.format("HH:mm")).replace("L",a.format("MM/DD/YYYY")).replace("dddd",n.weekdays[r.getUTCDay()]),i}var A=[1,2,3,4,5];function O(r,t=[]){let e=r.getUTCDay();if(!A.includes(e))return!1;let n=r.toISOString().split("T")[0];return!t.some(a=>a.toISOString().split("T")[0]===n)}function F(r,t,e=[]){let n=new Date(r),a=Math.abs(t),s=t>0?1:-1;for(;a>0;)n.setUTCDate(n.getUTCDate()+s),O(n,e)&&a--;return n}function z(r,t,e=[]){let n=0,a=new Date(r),s=new Date(t);for(;a<=s;)O(a,e)&&n++,a.setUTCDate(a.getUTCDate()+1);return n}var f=class r{constructor(t,e="milliseconds"){typeof t=="number"?this._milliseconds=this.convertToMilliseconds(t,e):this._milliseconds=this.objectToMilliseconds(t)}convertToMilliseconds(t,e){return t*({milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5,weeks:6048e5}[e]||1)}objectToMilliseconds(t){let e=0;return t.years&&(e+=t.years*365.25*864e5),t.months&&(e+=t.months*30.44*864e5),t.weeks&&(e+=t.weeks*6048e5),t.days&&(e+=t.days*864e5),t.hours&&(e+=t.hours*36e5),t.minutes&&(e+=t.minutes*6e4),t.seconds&&(e+=t.seconds*1e3),t.milliseconds&&(e+=t.milliseconds),e}asMilliseconds(){return this._milliseconds}asSeconds(){return this._milliseconds/1e3}asMinutes(){return this._milliseconds/6e4}asHours(){return this._milliseconds/36e5}asDays(){return this._milliseconds/864e5}asWeeks(){return this._milliseconds/6048e5}asMonths(){return this._milliseconds/(30.44*864e5)}asYears(){return this._milliseconds/(365.25*864e5)}humanize(t="en"){let e=Math.abs(this.asSeconds()),n=Math.abs(this.asMinutes()),a=Math.abs(this.asHours()),s=Math.abs(this.asDays()),o=Math.abs(this.asMonths()),i=Math.abs(this.asYears());return e<45?"a few seconds":e<90?"a minute":n<45?`${Math.round(n)} minutes`:n<90?"an hour":a<22?`${Math.round(a)} hours`:a<36?"a day":s<25?`${Math.round(s)} days`:s<45?"a month":s<345?`${Math.round(o)} months`:i<1.5?"a year":`${Math.round(i)} years`}toObject(){let t=Math.abs(this._milliseconds),e=Math.floor(t/(365.25*864e5));t-=e*365.25*864e5;let n=Math.floor(t/(30.44*864e5));t-=n*30.44*864e5;let a=Math.floor(t/864e5);t-=a*864e5;let s=Math.floor(t/36e5);t-=s*36e5;let o=Math.floor(t/6e4);t-=o*6e4;let i=Math.floor(t/1e3);t-=i*1e3;let c=Math.floor(t);return{years:e,months:n,days:a,hours:s,minutes:o,seconds:i,milliseconds:c}}add(t){return new r(this._milliseconds+t.asMilliseconds())}subtract(t){return new r(this._milliseconds-t.asMilliseconds())}static between(t,e){return new r(Math.abs(e.getTime()-t.getTime()))}};var p=class r{constructor(t,e){if(this.config={locale:"en",weekStartsOn:0,strictParsing:!1,...e},this.date=t?l(t):new Date,!C(this.date))throw new Error("Invalid date provided")}toDate(){return new Date(this.date)}toISOString(){return this.date.toISOString()}toUnix(){return Math.floor(this.date.getTime()/1e3)}valueOf(){return this.date.getTime()}toArray(){return[this.date.getUTCFullYear(),this.date.getUTCMonth(),this.date.getUTCDate(),this.date.getUTCHours(),this.date.getUTCMinutes(),this.date.getUTCSeconds(),this.date.getUTCMilliseconds()]}toObject(){return{year:this.date.getUTCFullYear(),month:this.date.getUTCMonth(),date:this.date.getUTCDate(),hour:this.date.getUTCHours(),minute:this.date.getUTCMinutes(),second:this.date.getUTCSeconds(),millisecond:this.date.getUTCMilliseconds()}}toJSON(){return this.toISOString()}toString(){return this.date.toString()}format(t){return E(this.date,t,this.config.locale)}static formatFromTimezoneString(t,e){let n=new Date(t);if(isNaN(n.getTime()))throw new Error("Invalid date string provided");let a=t.match(/GMT([+-]\d{2}):?(\d{2})|UTC([+-]\d{2}):?(\d{2})/i),s=0;if(a){let w=(a[1]||a[3])[0],y=parseInt((a[1]||a[3]).substring(1)),S=parseInt(a[2]||a[4]||"0");s=(y*60+S)*(w==="+"?1:-1)}else s=-n.getTimezoneOffset();let i=n.getTime()+s*60*1e3,c=new Date(i),d=c.getUTCFullYear(),h=c.getUTCMonth(),m=c.getUTCDate(),u=c.getUTCHours(),D=c.getUTCMinutes(),g=c.getUTCSeconds(),T=c.getUTCMilliseconds();return new r(Date.UTC(d,h,m,u,D,g,T)).format(e)}static formatZonedDate(t,e="DD-MM-YYYY",n="en"){if(typeof t!="string")throw new Error("formatZonedDate expects input as a string with explicit GMT offset");let a=t.match(/GMT([+-])(\d{2}):?(\d{2})/i),s=new Date(t);if(isNaN(s.getTime()))throw new Error("Invalid date input for formatZonedDate");let o=s;if(a){let i=a[1]==="-"?-1:1,c=parseInt(a[2],10),d=parseInt(a[3],10),h=i*(c*60+d),m=s.getTime()+h*6e4;o=new Date(m)}return E(o,e,n)}formatZonedDate(t,e="DD-MM-YYYY"){let n=this.config?.locale??"en";return r.formatZonedDate(t,e,n)}static convertTimezone(t,e,n,a){let s=l(t);if(!C(s))throw new Error("Invalid date provided");let o,i,c,d,h,m;if(typeof t=="string"&&!t.includes("Z")&&!t.includes("+")&&!t.includes("GMT")){let u=t.match(/(\d{4})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2}):(\d{2})/);u?(o=parseInt(u[1]),i=parseInt(u[2]),c=parseInt(u[3]),d=parseInt(u[4]),h=parseInt(u[5]),m=parseInt(u[6])):(o=s.getUTCFullYear(),i=s.getUTCMonth()+1,c=s.getUTCDate(),d=s.getUTCHours(),h=s.getUTCMinutes(),m=s.getUTCSeconds());let D=`${o}-${i.toString().padStart(2,"0")}-${c.toString().padStart(2,"0")}T${d.toString().padStart(2,"0")}:${h.toString().padStart(2,"0")}:${m.toString().padStart(2,"0")}`,g=new Date(Date.UTC(o,i-1,c,d,h,m)),T=new Date(g.toLocaleString("en-US",{timeZone:e})),k=new Date(g.toLocaleString("en-US",{timeZone:"UTC"})),w=T.getTime()-k.getTime(),y=g.getTime()-w,S=new Date(y);return r.formatInTimezone(S,n,a)}else return r.formatInTimezone(s,n,a)}static formatInTimezone(t,e,n){let a=l(t);if(!C(a))throw new Error("Invalid date provided");let o=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(a),i={};return o.forEach(d=>{d.type!=="literal"&&(i[d.type]=d.value)}),new r(Date.UTC(parseInt(i.year),parseInt(i.month)-1,parseInt(i.day),parseInt(i.hour),parseInt(i.minute),parseInt(i.second))).format(n)}static fromTimezone(t,e,n,a=0,s=0,o=0,i="UTC"){let c=`${t}-${e.toString().padStart(2,"0")}-${n.toString().padStart(2,"0")}T${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`,d=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),h=new Date(c),m=new Date(Date.UTC(t,e-1,n,a,s,o)),u=new Date(m.toLocaleString("en-US",{timeZone:i})),D=new Date(m.toLocaleString("en-US",{timeZone:"UTC"})),g=u.getTime()-D.getTime(),T=m.getTime()-g;return new r(T)}static getTimezoneOffset(t,e=new Date){let n=new Date(e.toLocaleString("en-US",{timeZone:"UTC"}));return(new Date(e.toLocaleString("en-US",{timeZone:t})).getTime()-n.getTime())/6e4}year(){return this.date.getUTCFullYear()}month(){return this.date.getUTCMonth()}getDate(){return this.date.getUTCDate()}day(){return this.date.getUTCDay()}hour(){return this.date.getUTCHours()}minute(){return this.date.getUTCMinutes()}second(){return this.date.getUTCSeconds()}millisecond(){return this.date.getUTCMilliseconds()}quarter(){return Math.floor(this.date.getUTCMonth()/3)+1}week(){return this.isoWeek()}isoWeek(){let t=new Date(this.date.getTime());t.setUTCHours(0,0,0,0),t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));let e=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-e.getTime())/864e5+1)/7)}weekday(){return(this.date.getUTCDay()+7-this.config.weekStartsOn)%7}isoWeekday(){return this.date.getUTCDay()||7}dayOfYear(){let t=new Date(Date.UTC(this.date.getUTCFullYear(),0,1));return Math.floor((this.date.getTime()-t.getTime())/864e5)+1}weekYear(){let t=new Date(this.date.getTime());return t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7)),t.getUTCFullYear()}set(t){let e=new Date(this.date);return t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month),t.date!==void 0&&e.setUTCDate(t.date),t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond),new r(e,this.config)}setYear(t){return this.set({year:t})}setMonth(t){return this.set({month:t})}setDate(t){return this.set({date:t})}setHour(t){return this.set({hour:t})}setMinute(t){return this.set({minute:t})}setSecond(t){return this.set({second:t})}setMillisecond(t){return this.set({millisecond:t})}setQuarter(t){let e=(t-1)*3;return this.set({month:e})}add(t,e){let n=new Date(this.date);switch(e){case"millisecond":n.setUTCMilliseconds(n.getUTCMilliseconds()+t);break;case"second":n.setUTCSeconds(n.getUTCSeconds()+t);break;case"minute":n.setUTCMinutes(n.getUTCMinutes()+t);break;case"hour":n.setUTCHours(n.getUTCHours()+t);break;case"day":n.setUTCDate(n.getUTCDate()+t);break;case"week":n.setUTCDate(n.getUTCDate()+t*7);break;case"month":n.setUTCMonth(n.getUTCMonth()+t);break;case"quarter":n.setUTCMonth(n.getUTCMonth()+t*3);break;case"year":n.setUTCFullYear(n.getUTCFullYear()+t);break}return new r(n,this.config)}subtract(t,e){return this.add(-t,e)}startOf(t){let e=new Date(this.date);switch(t){case"year":e.setUTCMonth(0);case"quarter":if(t==="quarter"){let s=this.quarter();e.setUTCMonth((s-1)*3)}case"month":e.setUTCDate(1);case"day":e.setUTCHours(0);case"hour":e.setUTCMinutes(0);case"minute":e.setUTCSeconds(0);case"second":e.setUTCMilliseconds(0);break;case"week":let n=e.getUTCDay(),a=(n<this.config.weekStartsOn?7:0)+n-this.config.weekStartsOn;e.setUTCDate(e.getUTCDate()-a),e.setUTCHours(0,0,0,0);break}return new r(e,this.config)}endOf(t){return this.startOf(t).add(1,t).subtract(1,"millisecond")}isBefore(t,e){return e?this.startOf(e).valueOf()<new r(t).startOf(e).valueOf():this.date.getTime()<l(t).getTime()}isAfter(t,e){return e?this.startOf(e).valueOf()>new r(t).startOf(e).valueOf():this.date.getTime()>l(t).getTime()}isSame(t,e){if(!e)return this.date.getTime()===l(t).getTime();let n=this.startOf(e),a=new r(t,this.config).startOf(e);return n.date.getTime()===a.date.getTime()}isSameOrBefore(t,e){return this.isSame(t,e)||this.isBefore(t,e)}isSameOrAfter(t,e){return this.isSame(t,e)||this.isAfter(t,e)}isBetween(t,e,n,a="()"){let s=n?new r(t).startOf(n).valueOf():l(t).getTime(),o=n?new r(e).startOf(n).valueOf():l(e).getTime(),i=n?this.startOf(n).valueOf():this.date.getTime(),c=a[0]==="["?i>=s:i>s,d=a[1]==="]"?i<=o:i<o;return c&&d}isToday(){return this.isSame(new Date,"day")}isTomorrow(){let t=new r().add(1,"day");return this.isSame(t.toDate(),"day")}isYesterday(){let t=new r().subtract(1,"day");return this.isSame(t.toDate(),"day")}isThisWeek(){return this.isSame(new Date,"week")}isThisMonth(){return this.isSame(new Date,"month")}isThisQuarter(){return this.isSame(new Date,"quarter")}isThisYear(){return this.isSame(new Date,"year")}isWeekend(){let t=this.date.getUTCDay();return t===0||t===6}isWeekday(){return!this.isWeekend()}isLeapYear(){let t=this.date.getUTCFullYear();return t%4===0&&t%100!==0||t%400===0}isDST(){let t=new Date(this.year(),0,1),e=new Date(this.year(),6,1),n=Math.max(t.getTimezoneOffset(),e.getTimezoneOffset());return this.date.getTimezoneOffset()<n}diff(t,e="millisecond",n=!1){let a=l(t),s=this.date.getTime()-a.getTime(),o=1;switch(e){case"millisecond":return s;case"second":o=1e3;break;case"minute":o=1e3*60;break;case"hour":o=1e3*60*60;break;case"day":o=1e3*60*60*24;break;case"week":o=1e3*60*60*24*7;break;case"month":return n?s/(1e3*60*60*24*30.436875):this.diffMonth(a);case"quarter":return n?s/(1e3*60*60*24*91.3125):Math.floor(this.diffMonth(a)/3);case"year":return n?s/(1e3*60*60*24*365.25):this.diffYear(a)}let i=s/o;return n?i:Math.floor(i)}diffMonth(t){let e=this.date.getUTCFullYear()-t.getUTCFullYear(),n=this.date.getUTCMonth()-t.getUTCMonth();return e*12+n}diffYear(t){return this.date.getUTCFullYear()-t.getUTCFullYear()}fromNow(t=!1){let e=Date.now()-this.date.getTime();return I(e,this.config.locale,t)}toNow(t=!1){let e=this.date.getTime()-Date.now();return I(e,this.config.locale,t)}from(t,e=!1){let n=l(t).getTime()-this.date.getTime();return I(n,this.config.locale,e)}to(t,e=!1){let n=this.date.getTime()-l(t).getTime();return I(n,this.config.locale,e)}calendar(t){let e=t?l(t):new Date;return H(this.date,e,this.config.locale)}duration(t){return t?f.between(this.date,l(t)):new f(this.date.getTime())}daysInMonth(){return new Date(Date.UTC(this.date.getUTCFullYear(),this.date.getUTCMonth()+1,0)).getUTCDate()}weeksInYear(){let t=new Date(Date.UTC(this.year(),11,31)),n=new r(t).isoWeek();return n===1?52:n}age(t){let e=t?l(t):new Date,n=this.date,a=e.getUTCFullYear()-n.getUTCFullYear(),s=n.getUTCMonth(),o=n.getUTCDate(),i=e.getUTCMonth(),c=e.getUTCDate();return(i<s||i===s&&c<o)&&a--,a}clone(){return new r(this.date,this.config)}isBusinessDay(t=[]){return O(this.date,t)}addBusinessDays(t,e=[]){return new r(F(this.date,t,e),this.config)}subtractBusinessDays(t,e=[]){return new r(F(this.date,-t,e),this.config)}businessDaysUntil(t,e=[]){return z(this.date,l(t),e)}locale(t){return t===void 0?this.config.locale:new r(this.date,{...this.config,locale:t})}static eachDayOfInterval(t){let e=new r(t.start),n=new r(t.end),a=[],s=e.clone();for(;s.isSameOrBefore(n.toDate(),"day");)a.push(s.clone()),s=s.add(1,"day");return a}static eachWeekOfInterval(t){let e=new r(t.start).startOf("week"),n=new r(t.end),a=[],s=e.clone();for(;s.isSameOrBefore(n.toDate(),"week");)a.push(s.clone()),s=s.add(1,"week");return a}static eachMonthOfInterval(t){let e=new r(t.start).startOf("month"),n=new r(t.end),a=[],s=e.clone();for(;s.isSameOrBefore(n.toDate(),"month");)a.push(s.clone()),s=s.add(1,"month");return a}static now(){return new r}static utc(t){return t?new r(t):new r(new Date)}static unix(t){return new r(t*1e3)}static isValid(t){try{return C(l(t))}catch{return!1}}static max(...t){let e=t.map(n=>l(n).getTime());return new r(Math.max(...e))}static min(...t){let e=t.map(n=>l(n).getTime());return new r(Math.min(...e))}static isDuration(t){return t instanceof f}static duration(t,e){return typeof t=="number"&&e?new f(t,e):new f(t)}};0&&(module.exports={DateKit,Duration,en,es,getLocale,registerLocale});
|
|
1
|
+
"use strict";var F=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var le=(r,e)=>{for(var t in e)F(r,t,{get:e[t],enumerable:!0})},ce=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of me(e))!ue.call(r,a)&&a!==t&&F(r,a,{get:()=>e[a],enumerable:!(n=de(e,a))||n.enumerable});return r};var he=r=>ce(F({},"__esModule",{value:!0}),r);var ye={};le(ye,{DateKit:()=>p,DateRange:()=>A,Duration:()=>T,ar:()=>z,bn:()=>P,de:()=>R,en:()=>N,es:()=>H,fr:()=>J,getLocale:()=>w,hi:()=>B,ja:()=>_,ko:()=>j,pt:()=>V,registerLocale:()=>ee,ru:()=>q,ur:()=>Z,zh:()=>Q});module.exports=he(ye);var N={name:"en",dir:"ltr",weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekdaysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinal:r=>{let e=["th","st","nd","rd"],t=r%100;return r+(e[(t-20)%10]||e[t]||e[0])},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"}};var H={name:"es",dir:"ltr",weekdays:["Domingo","Lunes","Martes","Mi\xE9rcoles","Jueves","Viernes","S\xE1bado"],weekdaysShort:["Dom","Lun","Mar","Mi\xE9","Jue","Vie","S\xE1b"],weekdaysMin:["Do","Lu","Ma","Mi","Ju","Vi","S\xE1"],months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthsShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],ordinal:r=>`${r}\xBA`,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un d\xEDa",dd:"%d d\xEDas",M:"un mes",MM:"%d meses",y:"un a\xF1o",yy:"%d a\xF1os"},calendar:{sameDay:"[Hoy a las] LT",nextDay:"[Ma\xF1ana a las] LT",nextWeek:"dddd [a las] LT",lastDay:"[Ayer a las] LT",lastWeek:"[El] dddd [pasado a las] LT",sameElse:"L"}};var J={name:"fr",dir:"ltr",weekdays:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],weekdaysShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],weekdaysMin:["Di","Lu","Ma","Me","Je","Ve","Sa"],months:["Janvier","F\xE9vrier","Mars","Avril","Mai","Juin","Juillet","Ao\xFBt","Septembre","Octobre","Novembre","D\xE9cembre"],monthsShort:["Janv.","F\xE9vr.","Mars","Avr.","Mai","Juin","Juil.","Ao\xFBt","Sept.","Oct.","Nov.","D\xE9c."],ordinal:r=>r===1?`${r}er`:`${r}e`,relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},calendar:{sameDay:"[Aujourd'hui \xE0] LT",nextDay:"[Demain \xE0] LT",nextWeek:"dddd [\xE0] LT",lastDay:"[Hier \xE0] LT",lastWeek:"[Le] dddd [dernier \xE0] LT",sameElse:"L"}};var R={name:"de",dir:"ltr",weekdays:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],weekdaysShort:["So","Mo","Di","Mi","Do","Fr","Sa"],weekdaysMin:["So","Mo","Di","Mi","Do","Fr","Sa"],months:["Januar","Februar","M\xE4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],monthsShort:["Jan","Feb","M\xE4r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],ordinal:r=>`${r}.`,relativeTime:{future:"in %s",past:"vor %s",s:"ein paar Sekunden",m:"einer Minute",mm:"%d Minuten",h:"einer Stunde",hh:"%d Stunden",d:"einem Tag",dd:"%d Tagen",M:"einem Monat",MM:"%d Monaten",y:"einem Jahr",yy:"%d Jahren"},calendar:{sameDay:"[Heute um] LT [Uhr]",nextDay:"[Morgen um] LT [Uhr]",nextWeek:"dddd [um] LT [Uhr]",lastDay:"[Gestern um] LT [Uhr]",lastWeek:"[Letzten] dddd [um] LT [Uhr]",sameElse:"L"}};var z={name:"ar",dir:"rtl",weekdays:["\u0627\u0644\u0623\u062D\u062F","\u0627\u0644\u0627\u062B\u0646\u064A\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621","\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621","\u0627\u0644\u062E\u0645\u064A\u0633","\u0627\u0644\u062C\u0645\u0639\u0629","\u0627\u0644\u0633\u0628\u062A"],weekdaysShort:["\u0623\u062D\u062F","\u0627\u062B\u0646\u064A\u0646","\u062B\u0644\u0627\u062B\u0627\u0621","\u0623\u0631\u0628\u0639\u0627\u0621","\u062E\u0645\u064A\u0633","\u062C\u0645\u0639\u0629","\u0633\u0628\u062A"],weekdaysMin:["\u062D","\u0646","\u062B","\u0631","\u062E","\u062C","\u0633"],months:["\u064A\u0646\u0627\u064A\u0631","\u0641\u0628\u0631\u0627\u064A\u0631","\u0645\u0627\u0631\u0633","\u0623\u0628\u0631\u064A\u0644","\u0645\u0627\u064A\u0648","\u064A\u0648\u0646\u064A\u0648","\u064A\u0648\u0644\u064A\u0648","\u0623\u063A\u0633\u0637\u0633","\u0633\u0628\u062A\u0645\u0628\u0631","\u0623\u0643\u062A\u0648\u0628\u0631","\u0646\u0648\u0641\u0645\u0628\u0631","\u062F\u064A\u0633\u0645\u0628\u0631"],monthsShort:["\u064A\u0646\u0627\u064A\u0631","\u0641\u0628\u0631\u0627\u064A\u0631","\u0645\u0627\u0631\u0633","\u0623\u0628\u0631\u064A\u0644","\u0645\u0627\u064A\u0648","\u064A\u0648\u0646\u064A\u0648","\u064A\u0648\u0644\u064A\u0648","\u0623\u063A\u0633\u0637\u0633","\u0633\u0628\u062A\u0645\u0628\u0631","\u0623\u0643\u062A\u0648\u0628\u0631","\u0646\u0648\u0641\u0645\u0628\u0631","\u062F\u064A\u0633\u0645\u0628\u0631"],ordinal:r=>`${r}`,relativeTime:{future:"\u0628\u0639\u062F %s",past:"\u0645\u0646\u0630 %s",s:"\u062B\u0648\u0627\u0646\u064D",m:"\u062F\u0642\u064A\u0642\u0629",mm:"%d \u062F\u0642\u0627\u0626\u0642",h:"\u0633\u0627\u0639\u0629",hh:"%d \u0633\u0627\u0639\u0627\u062A",d:"\u064A\u0648\u0645",dd:"%d \u0623\u064A\u0627\u0645",M:"\u0634\u0647\u0631",MM:"%d \u0623\u0634\u0647\u0631",y:"\u0633\u0646\u0629",yy:"%d \u0633\u0646\u0648\u0627\u062A"},calendar:{sameDay:"[\u0627\u0644\u064A\u0648\u0645 \u0639\u0646\u062F \u0627\u0644\u0633\u0627\u0639\u0629] LT",nextDay:"[\u063A\u062F\u0627\u064B \u0639\u0646\u062F \u0627\u0644\u0633\u0627\u0639\u0629] LT",nextWeek:"dddd [\u0639\u0646\u062F \u0627\u0644\u0633\u0627\u0639\u0629] LT",lastDay:"[\u0623\u0645\u0633 \u0639\u0646\u062F \u0627\u0644\u0633\u0627\u0639\u0629] LT",lastWeek:"dddd [\u0627\u0644\u0645\u0627\u0636\u064A \u0639\u0646\u062F \u0627\u0644\u0633\u0627\u0639\u0629] LT",sameElse:"L"}};var Q={name:"zh",dir:"ltr",weekdays:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],weekdaysShort:["\u5468\u65E5","\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D"],weekdaysMin:["\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],months:["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],monthsShort:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],ordinal:r=>`\u7B2C${r}`,relativeTime:{future:"%s\u540E",past:"%s\u524D",s:"\u51E0\u79D2",m:"1 \u5206\u949F",mm:"%d \u5206\u949F",h:"1 \u5C0F\u65F6",hh:"%d \u5C0F\u65F6",d:"1 \u5929",dd:"%d \u5929",M:"1 \u4E2A\u6708",MM:"%d \u4E2A\u6708",y:"1 \u5E74",yy:"%d \u5E74"},calendar:{sameDay:"[\u4ECA\u5929] LT",nextDay:"[\u660E\u5929] LT",nextWeek:"dddd LT",lastDay:"[\u6628\u5929] LT",lastWeek:"[\u4E0A] dddd LT",sameElse:"L"}};var B={name:"hi",dir:"ltr",weekdays:["\u0930\u0935\u093F\u0935\u093E\u0930","\u0938\u094B\u092E\u0935\u093E\u0930","\u092E\u0902\u0917\u0932\u0935\u093E\u0930","\u092C\u0941\u0927\u0935\u093E\u0930","\u0917\u0941\u0930\u0941\u0935\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u0935\u093E\u0930","\u0936\u0928\u093F\u0935\u093E\u0930"],weekdaysShort:["\u0930\u0935\u093F","\u0938\u094B\u092E","\u092E\u0902\u0917\u0932","\u092C\u0941\u0927","\u0917\u0941\u0930\u0941","\u0936\u0941\u0915\u094D\u0930","\u0936\u0928\u093F"],weekdaysMin:["\u0930","\u0938\u094B","\u092E","\u092C\u0941","\u0917\u0941","\u0936\u0941","\u0936"],months:["\u091C\u0928\u0935\u0930\u0940","\u092B\u093C\u0930\u0935\u0930\u0940","\u092E\u093E\u0930\u094D\u091A","\u0905\u092A\u094D\u0930\u0948\u0932","\u092E\u0908","\u091C\u0942\u0928","\u091C\u0941\u0932\u093E\u0908","\u0905\u0917\u0938\u094D\u0924","\u0938\u093F\u0924\u0902\u092C\u0930","\u0905\u0915\u094D\u091F\u0942\u092C\u0930","\u0928\u0935\u0902\u092C\u0930","\u0926\u093F\u0938\u0902\u092C\u0930"],monthsShort:["\u091C\u0928","\u092B\u093C\u0930","\u092E\u093E\u0930\u094D\u091A","\u0905\u092A\u094D\u0930","\u092E\u0908","\u091C\u0942\u0928","\u091C\u0941\u0932\u093E","\u0905\u0917","\u0938\u093F\u0924","\u0905\u0915\u094D\u091F","\u0928\u0935","\u0926\u093F\u0938"],ordinal:r=>`${r}\u0935\u093E\u0901`,relativeTime:{future:"%s \u092E\u0947\u0902",past:"%s \u092A\u0939\u0932\u0947",s:"\u0915\u0941\u091B \u0938\u0947\u0915\u0902\u0921",m:"\u090F\u0915 \u092E\u093F\u0928\u091F",mm:"%d \u092E\u093F\u0928\u091F",h:"\u090F\u0915 \u0918\u0902\u091F\u093E",hh:"%d \u0918\u0902\u091F\u0947",d:"\u090F\u0915 \u0926\u093F\u0928",dd:"%d \u0926\u093F\u0928",M:"\u090F\u0915 \u092E\u0939\u0940\u0928\u093E",MM:"%d \u092E\u0939\u0940\u0928\u0947",y:"\u090F\u0915 \u0938\u093E\u0932",yy:"%d \u0938\u093E\u0932"},calendar:{sameDay:"[\u0906\u091C] LT [\u092C\u091C\u0947]",nextDay:"[\u0915\u0932] LT [\u092C\u091C\u0947]",nextWeek:"dddd [\u0915\u094B] LT [\u092C\u091C\u0947]",lastDay:"[\u0915\u0932] LT [\u092C\u091C\u0947]",lastWeek:"[\u092A\u093F\u091B\u0932\u0947] dddd [\u0915\u094B] LT [\u092C\u091C\u0947]",sameElse:"L"}};var P={name:"bn",dir:"ltr",weekdays:["\u09B0\u09AC\u09BF\u09AC\u09BE\u09B0","\u09B8\u09CB\u09AE\u09AC\u09BE\u09B0","\u09AE\u0999\u09CD\u0997\u09B2\u09AC\u09BE\u09B0","\u09AC\u09C1\u09A7\u09AC\u09BE\u09B0","\u09AC\u09C3\u09B9\u09B8\u09CD\u09AA\u09A4\u09BF\u09AC\u09BE\u09B0","\u09B6\u09C1\u0995\u09CD\u09B0\u09AC\u09BE\u09B0","\u09B6\u09A8\u09BF\u09AC\u09BE\u09B0"],weekdaysShort:["\u09B0\u09AC\u09BF","\u09B8\u09CB\u09AE","\u09AE\u0999\u09CD\u0997\u09B2","\u09AC\u09C1\u09A7","\u09AC\u09C3\u09B9\u09B8\u09CD\u09AA\u09A4\u09BF","\u09B6\u09C1\u0995\u09CD\u09B0","\u09B6\u09A8\u09BF"],weekdaysMin:["\u09B0","\u09B8\u09CB","\u09AE","\u09AC\u09C1","\u09AC\u09C3","\u09B6\u09C1","\u09B6"],months:["\u099C\u09BE\u09A8\u09C1\u09AF\u09BC\u09BE\u09B0\u09BF","\u09AB\u09C7\u09AC\u09CD\u09B0\u09C1\u09AF\u09BC\u09BE\u09B0\u09BF","\u09AE\u09BE\u09B0\u09CD\u099A","\u098F\u09AA\u09CD\u09B0\u09BF\u09B2","\u09AE\u09C7","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE\u0987","\u0986\u0997\u09B8\u09CD\u099F","\u09B8\u09C7\u09AA\u09CD\u099F\u09C7\u09AE\u09CD\u09AC\u09B0","\u0985\u0995\u09CD\u099F\u09CB\u09AC\u09B0","\u09A8\u09AD\u09C7\u09AE\u09CD\u09AC\u09B0","\u09A1\u09BF\u09B8\u09C7\u09AE\u09CD\u09AC\u09B0"],monthsShort:["\u099C\u09BE\u09A8","\u09AB\u09C7\u09AC","\u09AE\u09BE\u09B0\u09CD\u099A","\u098F\u09AA\u09CD\u09B0","\u09AE\u09C7","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE","\u0986\u0997","\u09B8\u09C7\u09AA\u09CD\u099F","\u0985\u0995\u09CD\u099F","\u09A8\u09AD\u09C7","\u09A1\u09BF\u09B8\u09C7"],ordinal:r=>`${r}\u09A4\u09AE`,relativeTime:{future:"%s \u09AA\u09B0\u09C7",past:"%s \u0986\u0997\u09C7",s:"\u0995\u09AF\u09BC\u09C7\u0995 \u09B8\u09C7\u0995\u09C7\u09A8\u09CD\u09A1",m:"\u098F\u0995 \u09AE\u09BF\u09A8\u09BF\u099F",mm:"%d \u09AE\u09BF\u09A8\u09BF\u099F",h:"\u098F\u0995 \u0998\u09A3\u09CD\u099F\u09BE",hh:"%d \u0998\u09A3\u09CD\u099F\u09BE",d:"\u098F\u0995 \u09A6\u09BF\u09A8",dd:"%d \u09A6\u09BF\u09A8",M:"\u098F\u0995 \u09AE\u09BE\u09B8",MM:"%d \u09AE\u09BE\u09B8",y:"\u098F\u0995 \u09AC\u099B\u09B0",yy:"%d \u09AC\u099B\u09B0"},calendar:{sameDay:"[\u0986\u099C] LT [\u09B8\u09AE\u09AF\u09BC]",nextDay:"[\u0986\u0997\u09BE\u09AE\u09C0\u0995\u09BE\u09B2] LT [\u09B8\u09AE\u09AF\u09BC]",nextWeek:"dddd [\u098F] LT [\u09B8\u09AE\u09AF\u09BC]",lastDay:"[\u0997\u09A4\u0995\u09BE\u09B2] LT [\u09B8\u09AE\u09AF\u09BC]",lastWeek:"[\u0997\u09A4] dddd [\u098F] LT [\u09B8\u09AE\u09AF\u09BC]",sameElse:"L"}};var Z={name:"ur",dir:"rtl",weekdays:["\u0627\u062A\u0648\u0627\u0631","\u067E\u06CC\u0631","\u0645\u0646\u06AF\u0644","\u0628\u062F\u06BE","\u062C\u0645\u0639\u0631\u0627\u062A","\u062C\u0645\u0639\u06C1","\u06C1\u0641\u062A\u06C1"],weekdaysShort:["\u0627\u062A\u0648\u0627\u0631","\u067E\u06CC\u0631","\u0645\u0646\u06AF\u0644","\u0628\u062F\u06BE","\u062C\u0645\u0639\u0631\u0627\u062A","\u062C\u0645\u0639\u06C1","\u06C1\u0641\u062A\u06C1"],weekdaysMin:["\u0627\u062A","\u067E\u06CC","\u0645\u0646","\u0628\u062F","\u062C\u0645","\u062C\u0639","\u06C1\u0641"],months:["\u062C\u0646\u0648\u0631\u06CC","\u0641\u0631\u0648\u0631\u06CC","\u0645\u0627\u0631\u0686","\u0627\u067E\u0631\u06CC\u0644","\u0645\u0626\u06CC","\u062C\u0648\u0646","\u062C\u0648\u0644\u0627\u0626\u06CC","\u0627\u06AF\u0633\u062A","\u0633\u062A\u0645\u0628\u0631","\u0627\u06A9\u062A\u0648\u0628\u0631","\u0646\u0648\u0645\u0628\u0631","\u062F\u0633\u0645\u0628\u0631"],monthsShort:["\u062C\u0646","\u0641\u0631","\u0645\u0627\u0631","\u0627\u067E\u0631","\u0645\u0626\u06CC","\u062C\u0648\u0646","\u062C\u0648\u0644","\u0627\u06AF","\u0633\u062A","\u0627\u06A9\u062A","\u0646\u0648","\u062F\u0633"],ordinal:r=>`${r}\u0648\u0627\u06BA`,relativeTime:{future:"%s \u0645\u06CC\u06BA",past:"%s \u067E\u06C1\u0644\u06D2",s:"\u0686\u0646\u062F \u0633\u06CC\u06A9\u0646\u0688",m:"\u0627\u06CC\u06A9 \u0645\u0646\u0679",mm:"%d \u0645\u0646\u0679",h:"\u0627\u06CC\u06A9 \u06AF\u06BE\u0646\u0679\u06C1",hh:"%d \u06AF\u06BE\u0646\u0679\u06D2",d:"\u0627\u06CC\u06A9 \u062F\u0646",dd:"%d \u062F\u0646",M:"\u0627\u06CC\u06A9 \u0645\u06C1\u06CC\u0646\u06C1",MM:"%d \u0645\u06C1\u06CC\u0646\u06D2",y:"\u0627\u06CC\u06A9 \u0633\u0627\u0644",yy:"%d \u0633\u0627\u0644"},calendar:{sameDay:"[\u0622\u062C] LT [\u0628\u062C\u06D2]",nextDay:"[\u06A9\u0644] LT [\u0628\u062C\u06D2]",nextWeek:"dddd [\u06A9\u0648] LT [\u0628\u062C\u06D2]",lastDay:"[\u06AF\u0632\u0634\u062A\u06C1 \u06A9\u0644] LT [\u0628\u062C\u06D2]",lastWeek:"[\u06AF\u0632\u0634\u062A\u06C1] dddd [\u06A9\u0648] LT [\u0628\u062C\u06D2]",sameElse:"L"}};var V={name:"pt",dir:"ltr",weekdays:["Domingo","Segunda-feira","Ter\xE7a-feira","Quarta-feira","Quinta-feira","Sexta-feira","S\xE1bado"],weekdaysShort:["Dom","Seg","Ter","Qua","Qui","Sex","S\xE1b"],weekdaysMin:["Do","Se","Te","Qa","Qi","Sx","S\xE1"],months:["Janeiro","Fevereiro","Mar\xE7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthsShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],ordinal:r=>`${r}\xBA`,relativeTime:{future:"em %s",past:"h\xE1 %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um m\xEAs",MM:"%d meses",y:"um ano",yy:"%d anos"},calendar:{sameDay:"[Hoje \xE0s] LT",nextDay:"[Amanh\xE3 \xE0s] LT",nextWeek:"dddd [\xE0s] LT",lastDay:"[Ontem \xE0s] LT",lastWeek:"dddd [passado \xE0s] LT",sameElse:"L"}};var _={name:"ja",dir:"ltr",weekdays:["\u65E5\u66DC\u65E5","\u6708\u66DC\u65E5","\u706B\u66DC\u65E5","\u6C34\u66DC\u65E5","\u6728\u66DC\u65E5","\u91D1\u66DC\u65E5","\u571F\u66DC\u65E5"],weekdaysShort:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"],weekdaysMin:["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"],months:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],monthsShort:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],ordinal:r=>`${r}\u65E5`,relativeTime:{future:"%s\u5F8C",past:"%s\u524D",s:"\u6570\u79D2",m:"1\u5206",mm:"%d\u5206",h:"1\u6642\u9593",hh:"%d\u6642\u9593",d:"1\u65E5",dd:"%d\u65E5",M:"1\u30F6\u6708",MM:"%d\u30F6\u6708",y:"1\u5E74",yy:"%d\u5E74"},calendar:{sameDay:"[\u4ECA\u65E5] LT",nextDay:"[\u660E\u65E5] LT",nextWeek:"dddd LT",lastDay:"[\u6628\u65E5] LT",lastWeek:"[\u5148\u9031] dddd LT",sameElse:"L"}};var j={name:"ko",dir:"ltr",weekdays:["\uC77C\uC694\uC77C","\uC6D4\uC694\uC77C","\uD654\uC694\uC77C","\uC218\uC694\uC77C","\uBAA9\uC694\uC77C","\uAE08\uC694\uC77C","\uD1A0\uC694\uC77C"],weekdaysShort:["\uC77C","\uC6D4","\uD654","\uC218","\uBAA9","\uAE08","\uD1A0"],weekdaysMin:["\uC77C","\uC6D4","\uD654","\uC218","\uBAA9","\uAE08","\uD1A0"],months:["1\uC6D4","2\uC6D4","3\uC6D4","4\uC6D4","5\uC6D4","6\uC6D4","7\uC6D4","8\uC6D4","9\uC6D4","10\uC6D4","11\uC6D4","12\uC6D4"],monthsShort:["1\uC6D4","2\uC6D4","3\uC6D4","4\uC6D4","5\uC6D4","6\uC6D4","7\uC6D4","8\uC6D4","9\uC6D4","10\uC6D4","11\uC6D4","12\uC6D4"],ordinal:r=>`${r}\uC77C`,relativeTime:{future:"%s \uD6C4",past:"%s \uC804",s:"\uBA87 \uCD08",m:"1\uBD84",mm:"%d\uBD84",h:"\uD55C \uC2DC\uAC04",hh:"%d\uC2DC\uAC04",d:"\uD558\uB8E8",dd:"%d\uC77C",M:"\uD55C \uB2EC",MM:"%d\uB2EC",y:"\uC77C \uB144",yy:"%d\uB144"},calendar:{sameDay:"[\uC624\uB298] LT",nextDay:"[\uB0B4\uC77C] LT",nextWeek:"dddd LT",lastDay:"[\uC5B4\uC81C] LT",lastWeek:"[\uC9C0\uB09C] dddd LT",sameElse:"L"}};function L(r,e,t,n){let a=Math.abs(Math.round(r)),s=a%10,i=a%100;return i>=11&&i<=19?`${r} ${n}`:s===1?`${r} ${e}`:s>=2&&s<=4?`${r} ${t}`:`${r} ${n}`}var q={name:"ru",dir:"ltr",weekdays:["\u0412\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435","\u041F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A","\u0412\u0442\u043E\u0440\u043D\u0438\u043A","\u0421\u0440\u0435\u0434\u0430","\u0427\u0435\u0442\u0432\u0435\u0440\u0433","\u041F\u044F\u0442\u043D\u0438\u0446\u0430","\u0421\u0443\u0431\u0431\u043E\u0442\u0430"],weekdaysShort:["\u0412\u0441","\u041F\u043D","\u0412\u0442","\u0421\u0440","\u0427\u0442","\u041F\u0442","\u0421\u0431"],weekdaysMin:["\u0432\u0441","\u043F\u043D","\u0432\u0442","\u0441\u0440","\u0447\u0442","\u043F\u0442","\u0441\u0431"],months:["\u042F\u043D\u0432\u0430\u0440\u044C","\u0424\u0435\u0432\u0440\u0430\u043B\u044C","\u041C\u0430\u0440\u0442","\u0410\u043F\u0440\u0435\u043B\u044C","\u041C\u0430\u0439","\u0418\u044E\u043D\u044C","\u0418\u044E\u043B\u044C","\u0410\u0432\u0433\u0443\u0441\u0442","\u0421\u0435\u043D\u0442\u044F\u0431\u0440\u044C","\u041E\u043A\u0442\u044F\u0431\u0440\u044C","\u041D\u043E\u044F\u0431\u0440\u044C","\u0414\u0435\u043A\u0430\u0431\u0440\u044C"],monthsShort:["\u042F\u043D\u0432","\u0424\u0435\u0432","\u041C\u0430\u0440","\u0410\u043F\u0440","\u041C\u0430\u0439","\u0418\u044E\u043D","\u0418\u044E\u043B","\u0410\u0432\u0433","\u0421\u0435\u043D","\u041E\u043A\u0442","\u041D\u043E\u044F","\u0414\u0435\u043A"],ordinal:r=>`${r}-\u0439`,relativeTime:{future:"\u0447\u0435\u0440\u0435\u0437 %s",past:"%s \u043D\u0430\u0437\u0430\u0434",s:"\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0441\u0435\u043A\u0443\u043D\u0434",m:"\u043C\u0438\u043D\u0443\u0442\u0443",mm:r=>L(r,"\u043C\u0438\u043D\u0443\u0442\u0430","\u043C\u0438\u043D\u0443\u0442\u044B","\u043C\u0438\u043D\u0443\u0442"),h:"\u0447\u0430\u0441",hh:r=>L(r,"\u0447\u0430\u0441","\u0447\u0430\u0441\u0430","\u0447\u0430\u0441\u043E\u0432"),d:"\u0434\u0435\u043D\u044C",dd:r=>L(r,"\u0434\u0435\u043D\u044C","\u0434\u043D\u044F","\u0434\u043D\u0435\u0439"),M:"\u043C\u0435\u0441\u044F\u0446",MM:r=>L(r,"\u043C\u0435\u0441\u044F\u0446","\u043C\u0435\u0441\u044F\u0446\u0430","\u043C\u0435\u0441\u044F\u0446\u0435\u0432"),y:"\u0433\u043E\u0434",yy:r=>L(r,"\u0433\u043E\u0434","\u0433\u043E\u0434\u0430","\u043B\u0435\u0442")},calendar:{sameDay:"[\u0421\u0435\u0433\u043E\u0434\u043D\u044F \u0432] LT",nextDay:"[\u0417\u0430\u0432\u0442\u0440\u0430 \u0432] LT",nextWeek:"dddd [\u0432] LT",lastDay:"[\u0412\u0447\u0435\u0440\u0430 \u0432] LT",lastWeek:"[\u0412 \u043F\u0440\u043E\u0448\u043B\u044B\u0439] dddd [\u0432] LT",sameElse:"L"}};var Y={en:N,es:H,fr:J,de:R,ar:z,zh:Q,hi:B,bn:P,ur:Z,pt:V,ja:_,ko:j,ru:q};function w(r){return r in Y||console.warn(`[DateKit] Locale "${r}" is not registered. Falling back to "en". Register it with registerLocale() or import it from "datekit/locales/${r}".`),Y[r]||Y.en}function ee(r){Y[r.name]=r}function G(r,e,t="en"){let n=w(t),a=r.getUTCFullYear(),s=r.getUTCMonth(),i=r.getUTCDate(),o=r.getUTCHours(),l=r.getUTCMinutes(),m=r.getUTCSeconds(),u=r.getUTCMilliseconds(),c=r.getUTCDay(),d=new Date(Date.UTC(a,0,1)),D=Math.floor((r.getTime()-d.getTime())/864e5)+1,g=Math.floor(s/3)+1,f=ge(r),k=new Map,K=new Map,I={YYYY:a.toString(),YY:a.toString().slice(-2),Qo:n.ordinal(g),Q:g.toString(),MMMM:n.months[s],MMM:n.monthsShort[s],Mo:n.ordinal(s+1),MM:(s+1).toString().padStart(2,"0"),M:(s+1).toString(),Wo:n.ordinal(f),WW:f.toString().padStart(2,"0"),W:f.toString(),wo:n.ordinal(f),ww:f.toString().padStart(2,"0"),w:f.toString(),DDDo:n.ordinal(D),DDDD:D.toString().padStart(3,"0"),DDD:D.toString(),Do:n.ordinal(i),DD:i.toString().padStart(2,"0"),D:i.toString(),dddd:n.weekdays[c],ddd:n.weekdaysShort[c],do:n.ordinal(c),dd:n.weekdaysMin[c],d:c.toString(),HH:o.toString().padStart(2,"0"),H:o.toString(),hh:(o%12||12).toString().padStart(2,"0"),h:(o%12||12).toString(),mm:l.toString().padStart(2,"0"),m:l.toString(),ss:m.toString().padStart(2,"0"),s:m.toString(),SSS:u.toString().padStart(3,"0"),SS:u.toString().padStart(2,"0").slice(0,2),S:Math.floor(u/100).toString(),A:o>=12?"PM":"AM",a:o>=12?"pm":"am",Z:te(r.getTimezoneOffset()),ZZ:te(r.getTimezoneOffset()).replace(":",""),X:Math.floor(r.getTime()/1e3).toString(),x:r.getTime().toString()},y=e,U=[];return y=y.replace(/\[([^\]]*?)\]/g,(M,S)=>{let v=`${U.length}`;return U.push(S),v}),Object.keys(I).sort((M,S)=>S.length-M.length).forEach((M,S)=>{let v=`\0${S}\0`,oe=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ie=new RegExp(oe,"g");y=y.replace(ie,v),K.set(v,I[M])}),K.forEach((M,S)=>{y=y.replace(new RegExp(S,"g"),M)}),U.forEach((M,S)=>{y=y.split(`${S}`).join(M)}),y}function ge(r){let e=new Date(r.getTime());e.setUTCHours(0,0,0,0),e.setUTCDate(e.getUTCDate()+4-(e.getUTCDay()||7));let t=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-t.getTime())/864e5+1)/7)}function te(r){let e=r<=0?"+":"-",t=Math.abs(r),n=Math.floor(t/60),a=t%60;return`${e}${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}var fe=[{token:"YYYY",regex:"(\\d{4})",key:"year"},{token:"YY",regex:"(\\d{2})",key:"year2"},{token:"MM",regex:"(\\d{1,2})",key:"month"},{token:"M",regex:"(\\d{1,2})",key:"month"},{token:"DD",regex:"(\\d{1,2})",key:"day"},{token:"D",regex:"(\\d{1,2})",key:"day"},{token:"HH",regex:"(\\d{1,2})",key:"hour"},{token:"H",regex:"(\\d{1,2})",key:"hour"},{token:"hh",regex:"(\\d{1,2})",key:"hour12"},{token:"h",regex:"(\\d{1,2})",key:"hour12"},{token:"mm",regex:"(\\d{1,2})",key:"minute"},{token:"m",regex:"(\\d{1,2})",key:"minute"},{token:"ss",regex:"(\\d{1,2})",key:"second"},{token:"s",regex:"(\\d{1,2})",key:"second"},{token:"SSS",regex:"(\\d{1,3})",key:"ms"},{token:"A",regex:"(AM|PM)",key:"ampm"},{token:"a",regex:"(am|pm)",key:"ampm"}],De=[...fe].sort((r,e)=>e.token.length-r.token.length);function re(r,e){let t=[],n=e.replace(/\[([^\]]*?)\]/g,(d,D)=>{let g=`${t.length}`;return t.push(D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),g}),a=n;a=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let s=[],i=[],o=n;for(;o.length>0;){let d=o.match(/^\x02(\d+)\x02/);if(d){i.push(t[parseInt(d[1])]),o=o.slice(d[0].length);continue}let D=!1;for(let{token:g,regex:f,key:k}of De)if(o.startsWith(g)){i.push(f),s.push(k),o=o.slice(g.length),D=!0;break}if(!D){let g=o[0];i.push(g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=o.slice(1)}}let l=new RegExp(`^${i.join("")}$`),m=r.trim().match(l);if(!m)throw new Error(`DateKit.parse: "${r}" does not match format "${e}".`);let u={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0},c="";if(s.forEach((d,D)=>{let g=m[D+1];if(d==="ampm")c=g.toUpperCase();else if(d==="year2"){let f=parseInt(g,10);u.year=f>=70?1900+f:2e3+f}else u[d]=parseInt(g,10)}),"hour12"in u||c){let d=u.hour12??u.hour;c==="PM"&&d<12&&(d+=12),c==="AM"&&d===12&&(d=0),u.hour=d,delete u.hour12}return new Date(Date.UTC(u.year,u.month-1,u.day,u.hour??0,u.minute??0,u.second??0,u.ms??0))}var Te=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function h(r,e){if(r instanceof Date)return new Date(r);if(typeof r=="number")return new Date(r);if(typeof r=="string"){if(e&&!Te.test(r.trim()))throw new Error(`Strict parsing failed: "${r}" is not an unambiguous ISO 8601 date string. Use a format like "YYYY-MM-DD" or "YYYY-MM-DDTHH:mm:ssZ", or disable strict mode.`);return new Date(r)}throw new Error("Invalid date input")}function O(r){return r instanceof Date&&!isNaN(r.getTime())}function x(r,e){return typeof r=="function"?r(e):r.replace("%d",String(e))}function b(r,e="en",t=!1){let n=w(e),a=r<0,i=Math.abs(r)/1e3,o=i/60,l=o/60,m=l/24,u=m/30.44,c=m/365.25,d;return i<45?d=n.relativeTime.s:i<90?d=n.relativeTime.m:o<45?d=x(n.relativeTime.mm,Math.round(o)):o<90?d=n.relativeTime.h:l<22?d=x(n.relativeTime.hh,Math.round(l)):l<36?d=n.relativeTime.d:m<25?d=x(n.relativeTime.dd,Math.round(m)):m<45?d=n.relativeTime.M:m<345?d=x(n.relativeTime.MM,Math.round(u)):c<1.5?d=n.relativeTime.y:d=x(n.relativeTime.yy,Math.round(c)),t?d:(a?n.relativeTime.future:n.relativeTime.past).replace("%s",d)}function ne(r,e=new Date,t="en"){let n=w(t),a=new p(r),s=new p(e),i=a.startOf("day").diff(s.startOf("day").toDate(),"day"),o;return i===0?o=n.calendar.sameDay:i===1?o=n.calendar.nextDay:i===-1?o=n.calendar.lastDay:i>1&&i<=7?o=n.calendar.nextWeek:i<-1&&i>=-7?o=n.calendar.lastWeek:o=n.calendar.sameElse,o=o.replace(/\[([^\]]*?)\]/g,"$1").replace(/\bLT\b/g,a.format("HH:mm")).replace(/\bL\b/g,a.format("MM/DD/YYYY")).replace(/\bdddd\b/g,n.weekdays[r.getUTCDay()]),o}var ae=[1,2,3,4,5];function $(r,e=[]){let t=r.getUTCDay();if(!ae.includes(t))return!1;let n=r.toISOString().split("T")[0];return!e.some(a=>a.toISOString().split("T")[0]===n)}function X(r,e,t=[]){let n=new Date(r),a=Math.abs(e),s=e>0?1:-1;for(;a>0;)n.setUTCDate(n.getUTCDate()+s),$(n,t)&&a--;return n}function se(r,e,t=[]){let n=0,a=new Date(r);a.setUTCDate(a.getUTCDate()+1);let s=new Date(e);for(;a<=s;)$(a,t)&&n++,a.setUTCDate(a.getUTCDate()+1);return n}function C(r,e){let n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),a=o=>parseInt(n.find(l=>l.type===o)?.value??"0"),s=a("hour");return s===24&&(s=0),Date.UTC(a("year"),a("month")-1,a("day"),s,a("minute"),a("second"))-(r.getTime()-r.getUTCMilliseconds())}var E=315576e5,W=26298e5,T=class r{constructor(e,t="milliseconds"){typeof e=="number"?this._milliseconds=this.convertToMilliseconds(e,t):this._milliseconds=this.objectToMilliseconds(e)}convertToMilliseconds(e,t){return e*({milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5,weeks:6048e5}[t]||1)}objectToMilliseconds(e){let t=0;return e.years&&(t+=e.years*E),e.months&&(t+=e.months*W),e.weeks&&(t+=e.weeks*6048e5),e.days&&(t+=e.days*864e5),e.hours&&(t+=e.hours*36e5),e.minutes&&(t+=e.minutes*6e4),e.seconds&&(t+=e.seconds*1e3),e.milliseconds&&(t+=e.milliseconds),t}asMilliseconds(){return this._milliseconds}asSeconds(){return this._milliseconds/1e3}asMinutes(){return this._milliseconds/6e4}asHours(){return this._milliseconds/36e5}asDays(){return this._milliseconds/864e5}asWeeks(){return this._milliseconds/6048e5}asMonths(){return this._milliseconds/W}asYears(){return this._milliseconds/E}humanize(e="en",t=!0){return b(this._milliseconds,e,t)}toObject(){let e=Math.abs(this._milliseconds),t=Math.floor(e/E);e-=t*E;let n=Math.floor(e/W);e-=n*W;let a=Math.floor(e/864e5);e-=a*864e5;let s=Math.floor(e/36e5);e-=s*36e5;let i=Math.floor(e/6e4);e-=i*6e4;let o=Math.floor(e/1e3);e-=o*1e3;let l=Math.floor(e);return{years:t,months:n,days:a,hours:s,minutes:i,seconds:o,milliseconds:l}}add(e){return new r(this._milliseconds+e.asMilliseconds())}subtract(e){return new r(this._milliseconds-e.asMilliseconds())}static between(e,t){return new r(Math.abs(t.getTime()-e.getTime()))}};var p=class r{constructor(e,t){if(this.config={locale:"en",weekStartsOn:0,strictParsing:!1,...t},this.date=e?h(e,this.config.strictParsing):new Date,!O(this.date))throw new Error("Invalid date provided")}toDate(){return new Date(this.date)}toISOString(){return this.date.toISOString()}toUnix(){return Math.floor(this.date.getTime()/1e3)}valueOf(){return this.date.getTime()}toArray(){return[this.date.getUTCFullYear(),this.date.getUTCMonth(),this.date.getUTCDate(),this.date.getUTCHours(),this.date.getUTCMinutes(),this.date.getUTCSeconds(),this.date.getUTCMilliseconds()]}toObject(){return{year:this.date.getUTCFullYear(),month:this.date.getUTCMonth(),date:this.date.getUTCDate(),hour:this.date.getUTCHours(),minute:this.date.getUTCMinutes(),second:this.date.getUTCSeconds(),millisecond:this.date.getUTCMilliseconds()}}toJSON(){return this.toISOString()}toString(){return this.date.toString()}format(e){return G(this.date,e,this.config.locale)}static formatFromTimezoneString(e,t){let n,a;if(e instanceof Date?(a=e,n=e.toString()):typeof e=="number"?(a=new Date(e),n=a.toString()):(n=e,a=new Date(e)),isNaN(a.getTime()))throw new Error("Invalid date provided");let s=n.match(/GMT([+-]\d{2}):?(\d{2})|UTC([+-]\d{2}):?(\d{2})/i),i=0;if(s){let I=(s[1]||s[3])[0],y=parseInt((s[1]||s[3]).substring(1)),U=parseInt(s[2]||s[4]||"0");i=(y*60+U)*(I==="+"?1:-1)}else i=-a.getTimezoneOffset();let l=a.getTime()+i*60*1e3,m=new Date(l),u=m.getUTCFullYear(),c=m.getUTCMonth(),d=m.getUTCDate(),D=m.getUTCHours(),g=m.getUTCMinutes(),f=m.getUTCSeconds(),k=m.getUTCMilliseconds();return new r(Date.UTC(u,c,d,D,g,f,k)).format(t)}static formatZonedDate(e,t="DD-MM-YYYY",n="en"){let a,s;if(e instanceof Date?(s=e,a=e.toString()):typeof e=="number"?(s=new Date(e),a=s.toString()):(a=e,s=new Date(e)),isNaN(s.getTime()))throw new Error("Invalid date input for formatZonedDate");let i=a.match(/GMT([+-])(\d{2}):?(\d{2})/i),o=s;if(i){let l=i[1]==="-"?-1:1,m=parseInt(i[2],10),u=parseInt(i[3],10),c=l*(m*60+u),d=s.getTime()+c*6e4;o=new Date(d)}return G(o,t,n)}formatZonedDate(e,t="DD-MM-YYYY"){let n=this.config?.locale??"en";return r.formatZonedDate(e,t,n)}static convertTimezone(e,t,n,a){let s=h(e);if(!O(s))throw new Error("Invalid date provided");let i,o,l,m,u,c;if(typeof e=="string"&&!e.includes("Z")&&!e.includes("+")&&!e.includes("GMT")){let d=e.match(/(\d{4})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2}):(\d{2})/);d?(i=parseInt(d[1]),o=parseInt(d[2]),l=parseInt(d[3]),m=parseInt(d[4]),u=parseInt(d[5]),c=parseInt(d[6])):(i=s.getUTCFullYear(),o=s.getUTCMonth()+1,l=s.getUTCDate(),m=s.getUTCHours(),u=s.getUTCMinutes(),c=s.getUTCSeconds());let D=`${i}-${o.toString().padStart(2,"0")}-${l.toString().padStart(2,"0")}T${m.toString().padStart(2,"0")}:${u.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`,g=new Date(Date.UTC(i,o-1,l,m,u,c)),f=g.getTime()-C(g,t);f=g.getTime()-C(new Date(f),t);let k=new Date(f);return r.formatInTimezone(k,n,a)}else return r.formatInTimezone(s,n,a)}static formatInTimezone(e,t,n){let a=h(e);if(!O(a))throw new Error("Invalid date provided");let i=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(a),o={};return i.forEach(m=>{m.type!=="literal"&&(o[m.type]=m.value)}),new r(Date.UTC(parseInt(o.year),parseInt(o.month)-1,parseInt(o.day),parseInt(o.hour),parseInt(o.minute),parseInt(o.second))).format(n)}static fromTimezone(e,t,n,a=0,s=0,i=0,o="UTC"){let l=`${e}-${t.toString().padStart(2,"0")}-${n.toString().padStart(2,"0")}T${a.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`,m=new Intl.DateTimeFormat("en-US",{timeZone:o,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),u=new Date(Date.UTC(e,t-1,n,a,s,i)),c=u.getTime()-C(u,o);return c=u.getTime()-C(new Date(c),o),new r(c)}static getTimezoneOffset(e,t=new Date){return C(t,e)/6e4}year(){return this.date.getUTCFullYear()}month(){return this.date.getUTCMonth()}getDate(){return this.date.getUTCDate()}day(){return this.date.getUTCDay()}hour(){return this.date.getUTCHours()}minute(){return this.date.getUTCMinutes()}second(){return this.date.getUTCSeconds()}millisecond(){return this.date.getUTCMilliseconds()}quarter(){return Math.floor(this.date.getUTCMonth()/3)+1}week(){return this.isoWeek()}isoWeek(){let e=new Date(this.date.getTime());e.setUTCHours(0,0,0,0),e.setUTCDate(e.getUTCDate()+4-(e.getUTCDay()||7));let t=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-t.getTime())/864e5+1)/7)}weekday(){return(this.date.getUTCDay()+7-this.config.weekStartsOn)%7}isoWeekday(){return this.date.getUTCDay()||7}dayOfYear(){let e=new Date(Date.UTC(this.date.getUTCFullYear(),0,1));return Math.floor((this.date.getTime()-e.getTime())/864e5)+1}weekYear(){let e=new Date(this.date.getTime());return e.setUTCDate(e.getUTCDate()+4-(e.getUTCDay()||7)),e.getUTCFullYear()}set(e){let t=new Date(this.date);return e.year!==void 0&&t.setUTCFullYear(e.year),e.month!==void 0&&t.setUTCMonth(e.month),e.date!==void 0&&t.setUTCDate(e.date),e.hour!==void 0&&t.setUTCHours(e.hour),e.minute!==void 0&&t.setUTCMinutes(e.minute),e.second!==void 0&&t.setUTCSeconds(e.second),e.millisecond!==void 0&&t.setUTCMilliseconds(e.millisecond),new r(t,this.config)}setYear(e){return this.set({year:e})}setMonth(e){return this.set({month:e})}setDate(e){return this.set({date:e})}setHour(e){return this.set({hour:e})}setMinute(e){return this.set({minute:e})}setSecond(e){return this.set({second:e})}setMillisecond(e){return this.set({millisecond:e})}setQuarter(e){let t=(e-1)*3;return this.set({month:t})}add(e,t){let n=new Date(this.date);switch(t){case"millisecond":n.setUTCMilliseconds(n.getUTCMilliseconds()+e);break;case"second":n.setUTCSeconds(n.getUTCSeconds()+e);break;case"minute":n.setUTCMinutes(n.getUTCMinutes()+e);break;case"hour":n.setUTCHours(n.getUTCHours()+e);break;case"day":n.setUTCDate(n.getUTCDate()+e);break;case"week":n.setUTCDate(n.getUTCDate()+e*7);break;case"month":n.setUTCMonth(n.getUTCMonth()+e);break;case"quarter":n.setUTCMonth(n.getUTCMonth()+e*3);break;case"year":n.setUTCFullYear(n.getUTCFullYear()+e);break}return new r(n,this.config)}subtract(e,t){return this.add(-e,t)}startOf(e){let t=new Date(this.date);switch(e){case"year":t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);break;case"quarter":{let n=this.quarter();t.setUTCMonth((n-1)*3,1),t.setUTCHours(0,0,0,0);break}case"month":t.setUTCDate(1),t.setUTCHours(0,0,0,0);break;case"week":{let n=t.getUTCDay(),a=(n<this.config.weekStartsOn?7:0)+n-this.config.weekStartsOn;t.setUTCDate(t.getUTCDate()-a),t.setUTCHours(0,0,0,0);break}case"day":t.setUTCHours(0,0,0,0);break;case"hour":t.setUTCMinutes(0,0,0);break;case"minute":t.setUTCSeconds(0,0);break;case"second":t.setUTCMilliseconds(0);break}return new r(t,this.config)}endOf(e){return this.startOf(e).add(1,e).subtract(1,"millisecond")}isBefore(e,t){return t?this.startOf(t).valueOf()<new r(e).startOf(t).valueOf():this.date.getTime()<h(e).getTime()}isAfter(e,t){return t?this.startOf(t).valueOf()>new r(e).startOf(t).valueOf():this.date.getTime()>h(e).getTime()}isSame(e,t){if(!t)return this.date.getTime()===h(e).getTime();let n=this.startOf(t),a=new r(e,this.config).startOf(t);return n.date.getTime()===a.date.getTime()}isSameOrBefore(e,t){return this.isSame(e,t)||this.isBefore(e,t)}isSameOrAfter(e,t){return this.isSame(e,t)||this.isAfter(e,t)}isBetween(e,t,n,a="()"){let s=n?new r(e).startOf(n).valueOf():h(e).getTime(),i=n?new r(t).startOf(n).valueOf():h(t).getTime(),o=n?this.startOf(n).valueOf():this.date.getTime(),l=a[0]==="["?o>=s:o>s,m=a[1]==="]"?o<=i:o<i;return l&&m}isToday(){return this.isSame(new Date,"day")}isTomorrow(){let e=new r().add(1,"day");return this.isSame(e.toDate(),"day")}isYesterday(){let e=new r().subtract(1,"day");return this.isSame(e.toDate(),"day")}isThisWeek(){return this.isSame(new Date,"week")}isThisMonth(){return this.isSame(new Date,"month")}isThisQuarter(){return this.isSame(new Date,"quarter")}isThisYear(){return this.isSame(new Date,"year")}isWeekend(){let e=this.date.getUTCDay();return e===0||e===6}isWeekday(){return!this.isWeekend()}isLeapYear(){let e=this.date.getUTCFullYear();return e%4===0&&e%100!==0||e%400===0}isDST(){let e=new Date(Date.UTC(this.year(),0,1)),t=new Date(Date.UTC(this.year(),6,1)),n=Math.max(e.getTimezoneOffset(),t.getTimezoneOffset());return this.date.getTimezoneOffset()<n}diff(e,t="millisecond",n=!1){let a=h(e),s=this.date.getTime()-a.getTime(),i=1;switch(t){case"millisecond":return s;case"second":i=1e3;break;case"minute":i=1e3*60;break;case"hour":i=1e3*60*60;break;case"day":i=1e3*60*60*24;break;case"week":i=1e3*60*60*24*7;break;case"month":return n?s/(1e3*60*60*24*30.436875):this.diffMonth(a);case"quarter":return n?s/(1e3*60*60*24*91.3125):Math.floor(this.diffMonth(a)/3);case"year":return n?s/(1e3*60*60*24*365.25):this.diffYear(a)}let o=s/i;return n?o:Math.floor(o)}diffMonth(e){let t=this.date.getUTCFullYear()-e.getUTCFullYear(),n=this.date.getUTCMonth()-e.getUTCMonth();return t*12+n}diffYear(e){return this.date.getUTCFullYear()-e.getUTCFullYear()}fromNow(e=!1){let t=Date.now()-this.date.getTime();return b(t,this.config.locale,e)}toNow(e=!1){let t=this.date.getTime()-Date.now();return b(t,this.config.locale,e)}from(e,t=!1){let n=h(e).getTime()-this.date.getTime();return b(n,this.config.locale,t)}to(e,t=!1){let n=this.date.getTime()-h(e).getTime();return b(n,this.config.locale,t)}calendar(e){let t=e?h(e):new Date;return ne(this.date,t,this.config.locale)}duration(e){return e?T.between(this.date,h(e)):new T(this.date.getTime())}daysInMonth(){return new Date(Date.UTC(this.date.getUTCFullYear(),this.date.getUTCMonth()+1,0)).getUTCDate()}weeksInYear(){let e=new Date(Date.UTC(this.year(),11,28));return new r(e).isoWeek()}age(e){let t=e?h(e):new Date,n=this.date;if(n>t)throw new RangeError("age(): this date is in the future relative to the reference date. Pass a birthdate, not a future date.");let a=t.getUTCFullYear()-n.getUTCFullYear(),s=n.getUTCMonth(),i=n.getUTCDate(),o=t.getUTCMonth(),l=t.getUTCDate();return(o<s||o===s&&l<i)&&a--,a}clone(){return new r(this.date,this.config)}isBusinessDay(e=[]){return $(this.date,e)}addBusinessDays(e,t=[]){return new r(X(this.date,e,t),this.config)}subtractBusinessDays(e,t=[]){return new r(X(this.date,-e,t),this.config)}businessDaysUntil(e,t=[]){return se(this.date,h(e),t)}locale(e){return e===void 0?this.config.locale:new r(this.date,{...this.config,locale:e})}static eachDayOfInterval(e){let t=new r(e.start),n=new r(e.end);if(t.isAfter(n.toDate(),"day"))throw new RangeError(`eachDayOfInterval: start date must not be after end date. Got start=${t.toISOString()}, end=${n.toISOString()}.`);let a=[],s=t.clone();for(;s.isSameOrBefore(n.toDate(),"day");)a.push(s.clone()),s=s.add(1,"day");return a}static eachWeekOfInterval(e){let t=new r(e.start).startOf("week"),n=new r(e.end);if(t.isAfter(n.toDate(),"week"))throw new RangeError(`eachWeekOfInterval: start date must not be after end date. Got start=${new r(e.start).toISOString()}, end=${n.toISOString()}.`);let a=[],s=t.clone();for(;s.isSameOrBefore(n.toDate(),"week");)a.push(s.clone()),s=s.add(1,"week");return a}static eachMonthOfInterval(e){let t=new r(e.start).startOf("month"),n=new r(e.end);if(t.isAfter(n.toDate(),"month"))throw new RangeError(`eachMonthOfInterval: start date must not be after end date. Got start=${new r(e.start).toISOString()}, end=${n.toISOString()}.`);let a=[],s=t.clone();for(;s.isSameOrBefore(n.toDate(),"month");)a.push(s.clone()),s=s.add(1,"month");return a}static now(){return new r}static utc(e){return e?new r(e):new r(new Date)}static unix(e){return new r(e*1e3)}static isValid(e){try{return O(h(e))}catch{return!1}}static max(...e){let t=e.map(n=>h(n).getTime());return new r(Math.max(...t))}static min(...e){let t=e.map(n=>h(n).getTime());return new r(Math.min(...t))}static isDuration(e){return e instanceof T}static duration(e,t){return typeof e=="number"&&t?new T(e,t):new T(e)}static parse(e,t,n){let a=re(e,t);return new r(a,n)}};var A=class r{constructor(e,t){if(this.start=new p(e),this.end=new p(t),this.start.valueOf()>this.end.valueOf())throw new RangeError(`DateRange: start must not be after end. start=${this.start.toISOString()}, end=${this.end.toISOString()}`)}contains(e){let t=h(e).getTime();return t>=this.start.valueOf()&&t<=this.end.valueOf()}overlaps(e){return this.start.valueOf()<=e.end.valueOf()&&this.end.valueOf()>=e.start.valueOf()}intersection(e){let t=Math.max(this.start.valueOf(),e.start.valueOf()),n=Math.min(this.end.valueOf(),e.end.valueOf());return t>n?null:new r(t,n)}union(e){let t=Math.min(this.start.valueOf(),e.start.valueOf()),n=Math.max(this.end.valueOf(),e.end.valueOf());return new r(t,n)}duration(){return T.between(this.start.toDate(),this.end.toDate())}toArray(e="day"){let t=[],n=this.start.startOf(e);for(;n.valueOf()<=this.end.valueOf();)t.push(n.clone()),n=n.add(1,e);return t}days(){return Math.floor(this.duration().asDays())}toString(){return`[${this.start.toISOString()} / ${this.end.toISOString()}]`}toJSON(){return{start:this.start.toISOString(),end:this.end.toISOString()}}};0&&(module.exports={DateKit,DateRange,Duration,ar,bn,de,en,es,fr,getLocale,hi,ja,ko,pt,registerLocale,ru,ur,zh});
|