date-and-time 3.4.1 → 3.5.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/PLUGINS.md +32 -5
- package/README.md +45 -34
- package/date-and-time.d.ts +53 -21
- package/date-and-time.js +20 -22
- package/date-and-time.min.js +1 -1
- package/esm/date-and-time.es.js +20 -22
- package/esm/date-and-time.es.min.js +1 -1
- package/esm/date-and-time.mjs +20 -22
- package/esm/plugin/timezone.es.js +92 -39
- package/esm/plugin/timezone.mjs +92 -39
- package/package.json +3 -3
- package/plugin/timezone.d.ts +27 -0
- package/plugin/timezone.js +92 -39
package/PLUGINS.md
CHANGED
|
@@ -76,7 +76,7 @@ date.plugin('foobar');
|
|
|
76
76
|
- It adds `timeSpan()` function that calculates the difference of two dates to the library.
|
|
77
77
|
|
|
78
78
|
- [timezone](#timezone)
|
|
79
|
-
- It adds `formatTZ()`, `parseTZ()` and `
|
|
79
|
+
- It adds `formatTZ()`, `parseTZ()`, `transformTZ()`, `addYearsTZ()`, `addMonthsTZ()` and `addDaysTZ()` that support `IANA time zone names` to the library.
|
|
80
80
|
|
|
81
81
|
- [two-digit-year](#two-digit-year)
|
|
82
82
|
- It adds two-digit year notation to the parser.
|
|
@@ -290,7 +290,7 @@ In these functions can be available some tokens to format the calculation result
|
|
|
290
290
|
|
|
291
291
|
### timezone
|
|
292
292
|
|
|
293
|
-
It adds `formatTZ()`, `parseTZ()` and `
|
|
293
|
+
It adds `formatTZ()`, `parseTZ()`, `transformTZ()`, `addYearsTZ()`, `addMonthsTZ()` and `addDaysTZ()` that support `IANA time zone names` (`America/Los_Angeles`, `Asia/Tokyo`, and so on) to the library.
|
|
294
294
|
|
|
295
295
|
#### formatTZ(dateObj, arg[, timeZone])
|
|
296
296
|
|
|
@@ -299,7 +299,7 @@ It adds `formatTZ()`, `parseTZ()` and `transformTZ()` that support `IANA time zo
|
|
|
299
299
|
- @param {**string**} [timeZone] - Output as this time zone
|
|
300
300
|
- @returns {**string**} A formatted string
|
|
301
301
|
|
|
302
|
-
`formatTZ()` is upward compatible with `format()`. Tokens available for `arg` are the same as those for `format()`. If `timeZone` is omitted, this function assumes `timeZone` to be
|
|
302
|
+
`formatTZ()` is upward compatible with `format()`. Tokens available for `arg` are the same as those for `format()`. If `timeZone` is omitted, this function assumes `timeZone` to be the local time zone and outputs a string. This means that the result is the same as when `format()` is used.
|
|
303
303
|
|
|
304
304
|
#### parseTZ(dateString, arg[, timeZone])
|
|
305
305
|
|
|
@@ -308,7 +308,7 @@ It adds `formatTZ()`, `parseTZ()` and `transformTZ()` that support `IANA time zo
|
|
|
308
308
|
- @param {**string**} [timeZone] - Input as this time zone
|
|
309
309
|
- @returns {**Date**} A Date object
|
|
310
310
|
|
|
311
|
-
`parseTZ()` is upward compatible with `parse()`. Tokens available for `arg` are the same as those for `parse()`. `timeZone` in this function is used as supplemental information. if `dateString` contains a time zone offset value (i.e. -0800, +0900), `timeZone` is not be used. If `dateString` doesn't contain a time zone offset value and `timeZone` is omitted, this function assumes `timeZone` to be
|
|
311
|
+
`parseTZ()` is upward compatible with `parse()`. Tokens available for `arg` are the same as those for `parse()`. `timeZone` in this function is used as supplemental information. if `dateString` contains a time zone offset value (i.e. -0800, +0900), `timeZone` is not be used. If `dateString` doesn't contain a time zone offset value and `timeZone` is omitted, this function assumes `timeZone` to be the local time zone. This means that the result is the same as when `parse()` is used.
|
|
312
312
|
|
|
313
313
|
#### transformTZ(dateString, arg1, arg2[, timeZone])
|
|
314
314
|
|
|
@@ -318,7 +318,34 @@ It adds `formatTZ()`, `parseTZ()` and `transformTZ()` that support `IANA time zo
|
|
|
318
318
|
- @param {**string**} [timeZone] - Output as this time zone
|
|
319
319
|
- @returns {**string**} A formatted string
|
|
320
320
|
|
|
321
|
-
`transformTZ()` is upward compatible with `transform()`. `dateString` must itself contain a time zone offset value (i.e. -0800, +0900), otherwise this function assumes it is
|
|
321
|
+
`transformTZ()` is upward compatible with `transform()`. `dateString` must itself contain a time zone offset value (i.e. -0800, +0900), otherwise this function assumes it is the local time zone. Tokens available for `arg1` are the same as those for `parse()`, also tokens available for `arg2` are the same as those for `format()`. `timeZone` is a `IANA time zone names`, which is required to output a new formatted string. If it is omitted, this function assumes `timeZone` to be the local time zone. This means that the result is the same as when `transform()` is used.
|
|
322
|
+
|
|
323
|
+
#### addYearsTZ(dateObj, years[, timeZone])
|
|
324
|
+
|
|
325
|
+
- @param {**Date**} dateObj - A Date object
|
|
326
|
+
- @param {**number**} years - The number of years to add
|
|
327
|
+
- @param {**string**} [timeZone] - The time zone to use for the calculation
|
|
328
|
+
- @returns {**Date**} The Date object after adding the specified number of years
|
|
329
|
+
|
|
330
|
+
`addYearsTZ()` can calculate adding years in the specified time zone regardless of the execution environment.
|
|
331
|
+
|
|
332
|
+
#### addMonthsTZ(dateObj, months[, timeZone])
|
|
333
|
+
|
|
334
|
+
- @param {**Date**} dateObj - A Date object
|
|
335
|
+
- @param {**number**} months - The number of months to add
|
|
336
|
+
- @param {**string**} [timeZone] - The time zone to use for the calculation
|
|
337
|
+
- @returns {**Date**} The Date object after adding the specified number of months
|
|
338
|
+
|
|
339
|
+
`addMonthsTZ()` can calculate adding months in the specified time zone regardless of the execution environment.
|
|
340
|
+
|
|
341
|
+
#### addDaysTZ(dateObj, days[, timeZone])
|
|
342
|
+
|
|
343
|
+
- @param {**Date**} dateObj - A Date object
|
|
344
|
+
- @param {**number**} days - The number of days to add
|
|
345
|
+
- @param {**string**} [timeZone] - The time zone to use for the calculation
|
|
346
|
+
- @returns {**Date**} The Date object after adding the specified number of days
|
|
347
|
+
|
|
348
|
+
`addDaysTZ()` can calculate adding days in the specified time zone regardless of the execution environment.
|
|
322
349
|
|
|
323
350
|
```javascript
|
|
324
351
|
const date = require('date-and-time');
|
package/README.md
CHANGED
|
@@ -25,6 +25,10 @@ npm i date-and-time
|
|
|
25
25
|
|
|
26
26
|
## Recent Changes
|
|
27
27
|
|
|
28
|
+
- 3.5.0
|
|
29
|
+
- Added `addYearsTZ()`, `addMonthsTZ()`, and `addDaysTZ()` to the `timezone` plugin.
|
|
30
|
+
- Revised the approach to adding time and removed the third parameter from `addHours()`, `addMinutes()`, `addSeconds()`, and `addMilliseconds()`.
|
|
31
|
+
|
|
28
32
|
- 3.4.1
|
|
29
33
|
- Fixed an issue where `formatTZ()` would output 0:00 as 24:00 in 24-hour format in Node.js.
|
|
30
34
|
|
|
@@ -32,9 +36,6 @@ npm i date-and-time
|
|
|
32
36
|
- Added `zz` (time zone name) and `z` (time zone name abbreviation) tokens to the `timezone` plugin.
|
|
33
37
|
- Fixed an issue where token extensions by other plugins were not reflected in functions provided by the `timezone` plugin.
|
|
34
38
|
|
|
35
|
-
- 3.3.0
|
|
36
|
-
- Refactored `format()`, `isValid()`, and `preparse()`, further improved performance.
|
|
37
|
-
|
|
38
39
|
## Usage
|
|
39
40
|
|
|
40
41
|
- ES Modules:
|
|
@@ -98,16 +99,16 @@ import date from '/path/to/date-and-time.es.min.js';
|
|
|
98
99
|
- [addDays](#adddaysdateobj-days-utc)
|
|
99
100
|
- Adding days
|
|
100
101
|
|
|
101
|
-
- [addHours](#addhoursdateobj-hours
|
|
102
|
+
- [addHours](#addhoursdateobj-hours)
|
|
102
103
|
- Adding hours
|
|
103
104
|
|
|
104
|
-
- [addMinutes](#addminutesdateobj-minutes
|
|
105
|
+
- [addMinutes](#addminutesdateobj-minutes)
|
|
105
106
|
- Adding minutes
|
|
106
107
|
|
|
107
|
-
- [addSeconds](#addsecondsdateobj-seconds
|
|
108
|
+
- [addSeconds](#addsecondsdateobj-seconds)
|
|
108
109
|
- Adding seconds
|
|
109
110
|
|
|
110
|
-
- [addMilliseconds](#addmillisecondsdateobj-milliseconds
|
|
111
|
+
- [addMilliseconds](#addmillisecondsdateobj-milliseconds)
|
|
111
112
|
- Adding milliseconds
|
|
112
113
|
|
|
113
114
|
- [subtract](#subtractdate1-date2)
|
|
@@ -434,11 +435,11 @@ date.transform('13:05', 'HH:mm', 'hh:mm A');
|
|
|
434
435
|
### addYears(dateObj, years[, utc])
|
|
435
436
|
|
|
436
437
|
- @param {**Date**} dateObj - A Date object
|
|
437
|
-
- @param {**number**} years -
|
|
438
|
-
- @param {**boolean**} [utc] -
|
|
439
|
-
- @returns {**Date**} The Date object after adding the
|
|
438
|
+
- @param {**number**} years - The number of years to add
|
|
439
|
+
- @param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`
|
|
440
|
+
- @returns {**Date**} The Date object after adding the specified number of years
|
|
440
441
|
|
|
441
|
-
Adds years to
|
|
442
|
+
Adds years to a date object. Subtraction is also possible by specifying a negative value. If the third parameter is false or omitted, this function calculates based on the system's default time zone. If you need to obtain calculation results based on a specific time zone regardless of the execution system, consider using the `addYearsTZ()`, which allows you to specify a time zone name as the third parameter. See [PLUGINS.md](./PLUGINS.md) for details.
|
|
442
443
|
|
|
443
444
|
```javascript
|
|
444
445
|
const now = new Date();
|
|
@@ -456,11 +457,11 @@ const next_next_year = date.addYears(next_year, 1, true); // => Feb 28 2022
|
|
|
456
457
|
### addMonths(dateObj, months[, utc])
|
|
457
458
|
|
|
458
459
|
- @param {**Date**} dateObj - A Date object
|
|
459
|
-
- @param {**number**} months -
|
|
460
|
-
- @param {**boolean**} [utc] -
|
|
461
|
-
- @returns {**Date**} The Date object after adding the
|
|
460
|
+
- @param {**number**} months - The number of months to add
|
|
461
|
+
- @param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`
|
|
462
|
+
- @returns {**Date**} The Date object after adding the specified number of months
|
|
462
463
|
|
|
463
|
-
Adds months to
|
|
464
|
+
Adds months to a date object. Subtraction is also possible by specifying a negative value. If the third parameter is false or omitted, this function calculates based on the system's default time zone. If you need to obtain calculation results based on a specific time zone regardless of the execution system, consider using the `addMonthsTZ()`, which allows you to specify a time zone name as the third parameter. See [PLUGINS.md](./PLUGINS.md) for details.
|
|
464
465
|
|
|
465
466
|
```javascript
|
|
466
467
|
const now = new Date();
|
|
@@ -478,57 +479,67 @@ const next_next_month = date.addMonths(next_month, 1, true); // => Mar 28 202
|
|
|
478
479
|
### addDays(dateObj, days[, utc])
|
|
479
480
|
|
|
480
481
|
- @param {**Date**} dateObj - A Date object
|
|
481
|
-
- @param {**number**} days -
|
|
482
|
-
- @param {**boolean**} [utc] -
|
|
483
|
-
- @returns {**Date**} The Date object after adding the
|
|
482
|
+
- @param {**number**} days - The number of days to add
|
|
483
|
+
- @param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`
|
|
484
|
+
- @returns {**Date**} The Date object after adding the specified number of days
|
|
485
|
+
|
|
486
|
+
Adds days to a date object. Subtraction is also possible by specifying a negative value. If the third parameter is false or omitted, this function calculates based on the system's default time zone. If you need to obtain calculation results based on a specific time zone regardless of the execution system, consider using the `addDaysTZ()`, which allows you to specify a time zone name as the third parameter. See [PLUGINS.md](./PLUGINS.md) for details.
|
|
484
487
|
|
|
485
488
|
```javascript
|
|
486
489
|
const now = new Date();
|
|
487
490
|
const yesterday = date.addDays(now, -1);
|
|
488
491
|
```
|
|
489
492
|
|
|
490
|
-
### addHours(dateObj, hours
|
|
493
|
+
### addHours(dateObj, hours)
|
|
491
494
|
|
|
492
495
|
- @param {**Date**} dateObj - A Date object
|
|
493
|
-
- @param {**number**} hours -
|
|
494
|
-
-
|
|
495
|
-
- @returns {**Date**} The Date object after adding the
|
|
496
|
+
- @param {**number**} hours - The number of hours to add
|
|
497
|
+
- ~~@param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`~~ `Removed in: v3.5.0`
|
|
498
|
+
- @returns {**Date**} The Date object after adding the specified number of hours
|
|
499
|
+
|
|
500
|
+
Adds hours to a date object. Subtraction is also possible by specifying a negative value. The third parameter was deprecated in version 3.5.0. Regardless of what is specified for this parameter, the calculation results will not change.
|
|
496
501
|
|
|
497
502
|
```javascript
|
|
498
503
|
const now = new Date();
|
|
499
504
|
const an_hour_ago = date.addHours(now, -1);
|
|
500
505
|
```
|
|
501
506
|
|
|
502
|
-
### addMinutes(dateObj, minutes
|
|
507
|
+
### addMinutes(dateObj, minutes)
|
|
503
508
|
|
|
504
509
|
- @param {**Date**} dateObj - A Date object
|
|
505
|
-
- @param {**number**} minutes -
|
|
506
|
-
-
|
|
507
|
-
- @returns {**Date**} The Date object after adding the
|
|
510
|
+
- @param {**number**} minutes - The number of minutes to add
|
|
511
|
+
- ~~@param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`~~ `Removed in: v3.5.0`
|
|
512
|
+
- @returns {**Date**} The Date object after adding the specified number of minutes
|
|
513
|
+
|
|
514
|
+
Adds minutes to a date object. Subtraction is also possible by specifying a negative value. The third parameter was deprecated in version 3.5.0. Regardless of what is specified for this parameter, the calculation results will not change.
|
|
508
515
|
|
|
509
516
|
```javascript
|
|
510
517
|
const now = new Date();
|
|
511
518
|
const two_minutes_later = date.addMinutes(now, 2);
|
|
512
519
|
```
|
|
513
520
|
|
|
514
|
-
### addSeconds(dateObj, seconds
|
|
521
|
+
### addSeconds(dateObj, seconds)
|
|
515
522
|
|
|
516
523
|
- @param {**Date**} dateObj - A Date object
|
|
517
|
-
- @param {**number**} seconds -
|
|
518
|
-
-
|
|
519
|
-
- @returns {**Date**} The Date object after adding the
|
|
524
|
+
- @param {**number**} seconds - The number of seconds to add
|
|
525
|
+
- ~~@param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`~~ `Removed in: v3.5.0`
|
|
526
|
+
- @returns {**Date**} The Date object after adding the specified number of seconds
|
|
527
|
+
|
|
528
|
+
Adds seconds to a date object. Subtraction is also possible by specifying a negative value. The third parameter was deprecated in version 3.5.0. Regardless of what is specified for this parameter, the calculation results will not change.
|
|
520
529
|
|
|
521
530
|
```javascript
|
|
522
531
|
const now = new Date();
|
|
523
532
|
const three_seconds_ago = date.addSeconds(now, -3);
|
|
524
533
|
```
|
|
525
534
|
|
|
526
|
-
### addMilliseconds(dateObj, milliseconds
|
|
535
|
+
### addMilliseconds(dateObj, milliseconds)
|
|
527
536
|
|
|
528
537
|
- @param {**Date**} dateObj - A Date object
|
|
529
|
-
- @param {**number**} milliseconds -
|
|
530
|
-
-
|
|
531
|
-
- @returns {**Date**} The Date object after adding the
|
|
538
|
+
- @param {**number**} milliseconds - The number of milliseconds to add
|
|
539
|
+
- ~~@param {**boolean**} [utc] - If true, calculates the date in UTC `Added in: v3.0.0`~~ `Removed in: v3.5.0`
|
|
540
|
+
- @returns {**Date**} The Date object after adding the specified number of milliseconds
|
|
541
|
+
|
|
542
|
+
Adds milliseconds to a date object. Subtraction is also possible by specifying a negative value. The third parameter was deprecated in version 3.5.0. Regardless of what is specified for this parameter, the calculation results will not change.
|
|
532
543
|
|
|
533
544
|
```javascript
|
|
534
545
|
const now = new Date();
|
package/date-and-time.d.ts
CHANGED
|
@@ -153,63 +153,95 @@ export function transform(dateString: string, compiledObj1: string[], compiledOb
|
|
|
153
153
|
/**
|
|
154
154
|
* Adding years
|
|
155
155
|
* @param dateObj - A Date object
|
|
156
|
-
* @param years -
|
|
157
|
-
* @param [utc] -
|
|
158
|
-
* @returns The Date object after adding the
|
|
156
|
+
* @param years - The number of years to add
|
|
157
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
158
|
+
* @returns The Date object after adding the specified number of years
|
|
159
159
|
*/
|
|
160
160
|
export function addYears(dateObj: Date, years: number, utc?: boolean): Date;
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Adding months
|
|
164
164
|
* @param dateObj - A Date object
|
|
165
|
-
* @param months -
|
|
166
|
-
* @param [utc] -
|
|
167
|
-
* @returns The Date object after adding the
|
|
165
|
+
* @param months - The number of months to add
|
|
166
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
167
|
+
* @returns The Date object after adding the specified number of months
|
|
168
168
|
*/
|
|
169
169
|
export function addMonths(dateObj: Date, months: number, utc?: boolean): Date;
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Adding days
|
|
173
173
|
* @param dateObj - A Date object
|
|
174
|
-
* @param days -
|
|
175
|
-
* @param [utc] -
|
|
176
|
-
* @returns The Date object after adding the
|
|
174
|
+
* @param days - The number of days to add
|
|
175
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
176
|
+
* @returns The Date object after adding the specified number of days
|
|
177
177
|
*/
|
|
178
178
|
export function addDays(dateObj: Date, days: number, utc?: boolean): Date;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Adding hours
|
|
182
182
|
* @param dateObj - A Date object
|
|
183
|
-
* @param hours -
|
|
184
|
-
* @
|
|
185
|
-
|
|
183
|
+
* @param hours - The number of hours to add
|
|
184
|
+
* @returns The Date object after adding the specified number of hours
|
|
185
|
+
*/
|
|
186
|
+
export function addHours(dateObj: Date, hours: number): Date;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated The `utc` parameter is ignored. The function always returns the same result regardless of this value.
|
|
190
|
+
* @param dateObj - A Date object
|
|
191
|
+
* @param hours - The number of hours to add
|
|
192
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
193
|
+
* @returns The Date object after adding the specified number of hours
|
|
186
194
|
*/
|
|
187
195
|
export function addHours(dateObj: Date, hours: number, utc?: boolean): Date;
|
|
188
196
|
|
|
189
197
|
/**
|
|
190
198
|
* Adding minutes
|
|
191
199
|
* @param dateObj - A Date object
|
|
192
|
-
* @param minutes -
|
|
193
|
-
* @
|
|
194
|
-
|
|
200
|
+
* @param minutes - The number of minutes to add
|
|
201
|
+
* @returns The Date object after adding the specified number of minutes
|
|
202
|
+
*/
|
|
203
|
+
export function addMinutes(dateObj: Date, minutes: number): Date;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated The `utc` parameter is ignored. The function always returns the same result regardless of this value.
|
|
207
|
+
* @param dateObj - A Date object
|
|
208
|
+
* @param minutes - The number of minutes to add
|
|
209
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
210
|
+
* @returns The Date object after adding the specified number of minutes
|
|
195
211
|
*/
|
|
196
212
|
export function addMinutes(dateObj: Date, minutes: number, utc?: boolean): Date;
|
|
197
213
|
|
|
198
214
|
/**
|
|
199
215
|
* Adding seconds
|
|
200
216
|
* @param dateObj - A Date object
|
|
201
|
-
* @param seconds -
|
|
202
|
-
* @
|
|
203
|
-
|
|
217
|
+
* @param seconds - The number of seconds to add
|
|
218
|
+
* @returns The Date object after adding the specified number of seconds
|
|
219
|
+
*/
|
|
220
|
+
export function addSeconds(dateObj: Date, seconds: number): Date;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @deprecated The `utc` parameter is ignored. The function always returns the same result regardless of this value.
|
|
224
|
+
* @param dateObj - A Date object
|
|
225
|
+
* @param seconds - The number of seconds to add
|
|
226
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
227
|
+
* @returns The Date object after adding the specified number of seconds
|
|
204
228
|
*/
|
|
205
229
|
export function addSeconds(dateObj: Date, seconds: number, utc?: boolean): Date;
|
|
206
230
|
|
|
207
231
|
/**
|
|
208
232
|
* Adding milliseconds
|
|
209
233
|
* @param dateObj - A Date object
|
|
210
|
-
* @param milliseconds -
|
|
211
|
-
* @
|
|
212
|
-
|
|
234
|
+
* @param milliseconds - The number of milliseconds to add
|
|
235
|
+
* @returns The Date object after adding the specified number of milliseconds
|
|
236
|
+
*/
|
|
237
|
+
export function addMilliseconds(dateObj: Date, milliseconds: number): Date;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @deprecated The `utc` parameter is ignored. The function always returns the same result regardless of this value.
|
|
241
|
+
* @param dateObj - A Date object
|
|
242
|
+
* @param milliseconds - The number of milliseconds to add
|
|
243
|
+
* @param [utc] - If true, calculates the date in UTC
|
|
244
|
+
* @returns The Date object after adding the specified number of milliseconds
|
|
213
245
|
*/
|
|
214
246
|
export function addMilliseconds(dateObj: Date, milliseconds: number, utc?: boolean): Date;
|
|
215
247
|
|
package/date-and-time.js
CHANGED
|
@@ -309,12 +309,14 @@
|
|
|
309
309
|
if (utc) {
|
|
310
310
|
d.setUTCMonth(d.getUTCMonth() + months);
|
|
311
311
|
if (d.getUTCDate() < dateObj.getUTCDate()) {
|
|
312
|
-
|
|
312
|
+
d.setUTCDate(0);
|
|
313
|
+
return d;
|
|
313
314
|
}
|
|
314
315
|
} else {
|
|
315
316
|
d.setMonth(d.getMonth() + months);
|
|
316
317
|
if (d.getDate() < dateObj.getDate()) {
|
|
317
|
-
|
|
318
|
+
d.setDate(0);
|
|
319
|
+
return d;
|
|
318
320
|
}
|
|
319
321
|
}
|
|
320
322
|
return d;
|
|
@@ -328,58 +330,54 @@
|
|
|
328
330
|
* @returns {Date} The Date object after adding the value
|
|
329
331
|
*/
|
|
330
332
|
proto.addDays = function (dateObj, days, utc) {
|
|
331
|
-
|
|
333
|
+
var d = new Date(dateObj.getTime());
|
|
334
|
+
|
|
335
|
+
if (utc) {
|
|
336
|
+
d.setUTCDate(d.getUTCDate() + days);
|
|
337
|
+
} else {
|
|
338
|
+
d.setDate(d.getDate() + days);
|
|
339
|
+
}
|
|
340
|
+
return d;
|
|
332
341
|
};
|
|
333
342
|
|
|
334
343
|
/**
|
|
335
344
|
* Adding hours
|
|
336
345
|
* @param {Date} dateObj - A Date object
|
|
337
346
|
* @param {number} hours - Number of hours to add
|
|
338
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
339
347
|
* @returns {Date} The Date object after adding the value
|
|
340
348
|
*/
|
|
341
|
-
proto.addHours = function (dateObj, hours
|
|
342
|
-
return (
|
|
349
|
+
proto.addHours = function (dateObj, hours) {
|
|
350
|
+
return new Date(dateObj.getTime() + hours * 60 * 60 * 1000);
|
|
343
351
|
};
|
|
344
352
|
|
|
345
353
|
/**
|
|
346
354
|
* Adding minutes
|
|
347
355
|
* @param {Date} dateObj - A Date object
|
|
348
356
|
* @param {number} minutes - Number of minutes to add
|
|
349
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
350
357
|
* @returns {Date} The Date object after adding the value
|
|
351
358
|
*/
|
|
352
|
-
proto.addMinutes = function (dateObj, minutes
|
|
353
|
-
return (
|
|
359
|
+
proto.addMinutes = function (dateObj, minutes) {
|
|
360
|
+
return new Date(dateObj.getTime() + minutes * 60 * 1000);
|
|
354
361
|
};
|
|
355
362
|
|
|
356
363
|
/**
|
|
357
364
|
* Adding seconds
|
|
358
365
|
* @param {Date} dateObj - A Date object
|
|
359
366
|
* @param {number} seconds - Number of seconds to add
|
|
360
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
361
367
|
* @returns {Date} The Date object after adding the value
|
|
362
368
|
*/
|
|
363
|
-
proto.addSeconds = function (dateObj, seconds
|
|
364
|
-
return (
|
|
369
|
+
proto.addSeconds = function (dateObj, seconds) {
|
|
370
|
+
return new Date(dateObj.getTime() + seconds * 1000);
|
|
365
371
|
};
|
|
366
372
|
|
|
367
373
|
/**
|
|
368
374
|
* Adding milliseconds
|
|
369
375
|
* @param {Date} dateObj - A Date object
|
|
370
376
|
* @param {number} milliseconds - Number of milliseconds to add
|
|
371
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
372
377
|
* @returns {Date} The Date object after adding the value
|
|
373
378
|
*/
|
|
374
|
-
proto.addMilliseconds = function (dateObj, milliseconds
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (utc) {
|
|
378
|
-
d.setUTCMilliseconds(d.getUTCMilliseconds() + milliseconds);
|
|
379
|
-
} else {
|
|
380
|
-
d.setMilliseconds(d.getMilliseconds() + milliseconds);
|
|
381
|
-
}
|
|
382
|
-
return d;
|
|
379
|
+
proto.addMilliseconds = function (dateObj, milliseconds) {
|
|
380
|
+
return new Date(dateObj.getTime() + milliseconds);
|
|
383
381
|
};
|
|
384
382
|
|
|
385
383
|
/**
|
package/date-and-time.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).date=t()}(this,(function(){"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
|
|
4
|
-
*/var e,t={},n={},r="en",
|
|
4
|
+
*/var e,t={},n={},r="en",u={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"]},i={YYYY:function(e){return("000"+e.getFullYear()).slice(-4)},YY:function(e){return("0"+e.getFullYear()).slice(-2)},Y:function(e){return""+e.getFullYear()},MMMM:function(e){return this.res.MMMM[e.getMonth()]},MMM:function(e){return this.res.MMM[e.getMonth()]},MM:function(e){return("0"+(e.getMonth()+1)).slice(-2)},M:function(e){return""+(e.getMonth()+1)},DD:function(e){return("0"+e.getDate()).slice(-2)},D:function(e){return""+e.getDate()},HH:function(e){return("0"+e.getHours()).slice(-2)},H:function(e){return""+e.getHours()},A:function(e){return this.res.A[e.getHours()>11|0]},hh:function(e){return("0"+(e.getHours()%12||12)).slice(-2)},h:function(e){return""+(e.getHours()%12||12)},mm:function(e){return("0"+e.getMinutes()).slice(-2)},m:function(e){return""+e.getMinutes()},ss:function(e){return("0"+e.getSeconds()).slice(-2)},s:function(e){return""+e.getSeconds()},SSS:function(e){return("00"+e.getMilliseconds()).slice(-3)},SS:function(e){return("0"+(e.getMilliseconds()/10|0)).slice(-2)},S:function(e){return""+(e.getMilliseconds()/100|0)},dddd:function(e){return this.res.dddd[e.getDay()]},ddd:function(e){return this.res.ddd[e.getDay()]},dd:function(e){return this.res.dd[e.getDay()]},Z:function(e){var t=e.getTimezoneOffset()/.6|0;return(t>0?"-":"+")+("000"+Math.abs(t-(t%100*.4|0))).slice(-4)},ZZ:function(e){var t=e.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+("0"+(n/60|0)).slice(-2)+":"+("0"+n%60).slice(-2)},post:function(e){return e},res:u},o={YYYY:function(e){return this.exec(/^\d{4}/,e)},Y:function(e){return this.exec(/^\d{1,4}/,e)},MMMM:function(e){var t=this.find(this.res.MMMM,e);return t.value++,t},MMM:function(e){var t=this.find(this.res.MMM,e);return t.value++,t},MM:function(e){return this.exec(/^\d\d/,e)},M:function(e){return this.exec(/^\d\d?/,e)},DD:function(e){return this.exec(/^\d\d/,e)},D:function(e){return this.exec(/^\d\d?/,e)},HH:function(e){return this.exec(/^\d\d/,e)},H:function(e){return this.exec(/^\d\d?/,e)},A:function(e){return this.find(this.res.A,e)},hh:function(e){return this.exec(/^\d\d/,e)},h:function(e){return this.exec(/^\d\d?/,e)},mm:function(e){return this.exec(/^\d\d/,e)},m:function(e){return this.exec(/^\d\d?/,e)},ss:function(e){return this.exec(/^\d\d/,e)},s:function(e){return this.exec(/^\d\d?/,e)},SSS:function(e){return this.exec(/^\d{1,3}/,e)},SS:function(e){var t=this.exec(/^\d\d?/,e);return t.value*=10,t},S:function(e){var t=this.exec(/^\d/,e);return t.value*=100,t},Z:function(e){var t=this.exec(/^[+-]\d{2}[0-5]\d/,e);return t.value=-60*(t.value/100|0)-t.value%100,t},ZZ:function(e){var t=/^([+-])(\d{2}):([0-5]\d)/.exec(e)||["","","",""];return{value:0-(60*(t[1]+t[2]|0)+(t[1]+t[3]|0)),length:t[0].length}},h12:function(e,t){return(12===e?0:e)+12*t},exec:function(e,t){var n=(e.exec(t)||[""])[0];return{value:0|n,length:n.length}},find:function(e,t){for(var n,r=-1,u=0,i=0,o=e.length;i<o;i++)n=e[i],!t.indexOf(n)&&n.length>u&&(r=i,u=n.length);return{value:r,length:u}},pre:function(e){return e},res:u},s=function(e,t,n,r){var u,i={};for(u in e)i[u]=e[u];for(u in t||{})!!n^!!i[u]||(i[u]=t[u]);return r&&(i.res=r),i},a={_formatter:i,_parser:o};return a.compile=function(e){return[e].concat(e.match(/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g)||[])},a.format=function(t,n,r){for(var u,i=this||e,o="string"==typeof n?i.compile(n):n,s=i._formatter,a=function(){if(r){var e=new Date(t.getTime());return e.getFullYear=e.getUTCFullYear,e.getMonth=e.getUTCMonth,e.getDate=e.getUTCDate,e.getHours=e.getUTCHours,e.getMinutes=e.getUTCMinutes,e.getSeconds=e.getUTCSeconds,e.getMilliseconds=e.getUTCMilliseconds,e.getDay=e.getUTCDay,e.getTimezoneOffset=function(){return 0},e.getTimezoneName=function(){return"UTC"},e}return t}(),c=/^\[(.*)\]$/,f="",d=1,l=o.length;d<l;d++)f+=s[u=o[d]]?s.post(s[u](a,o[0])):c.test(u)?u.replace(c,"$1"):u;return f},a.preparse=function(t,n){var r=this||e,u="string"==typeof n?r.compile(n):n,i=r._parser,o={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},s=/^\[(.*)\]$/;t=i.pre(t);for(var a,c,f,d=1,l=u.length;d<l;d++)if(a=u[d],c=t.substring(o._index),i[a]){if(!(f=i[a](c,u[0])).length)break;o[f.token||a.charAt(0)]=f.value,o._index+=f.length,o._match++}else if(a===c.charAt(0)||" "===a)o._index++;else{if(!s.test(a)||c.indexOf(a.replace(s,"$1"))){if("..."===a){o._index=t.length;break}break}o._index+=a.length-2}return o.H=o.H||i.h12(o.h,o.A),o._length=t.length,o},a.parse=function(t,n,r){var u=this||e,i="string"==typeof n?u.compile(n):n,o=u.preparse(t,i);return u.isValid(o)?(o.M-=o.Y<100?22801:1,r||~u._parser.find(i,"ZZ").value?new Date(Date.UTC(o.Y,o.M,o.D,o.H,o.m+o.Z,o.s,o.S)):new Date(o.Y,o.M,o.D,o.H,o.m,o.s,o.S)):new Date(NaN)},a.isValid=function(t,n){var r="string"==typeof t?(this||e).preparse(t,n):t;return!(r._index<1||r._length<1||r._index-r._length||r._match<1||r.Y<1||r.Y>9999||r.M<1||r.M>12||r.D<1||r.D>new Date(r.Y,r.M,0).getDate()||r.H<0||r.H>23||r.m<0||r.m>59||r.s<0||r.s>59||r.S<0||r.S>999||r.Z<-840||r.Z>720)},a.transform=function(t,n,r,u){const i=this||e;return i.format(i.parse(t,n),r,u)},a.addYears=function(t,n,r){return(this||e).addMonths(t,12*n,r)},a.addMonths=function(e,t,n){var r=new Date(e.getTime());if(n){if(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate())return r.setUTCDate(0),r}else if(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate())return r.setDate(0),r;return r},a.addDays=function(e,t,n){var r=new Date(e.getTime());return n?r.setUTCDate(r.getUTCDate()+t):r.setDate(r.getDate()+t),r},a.addHours=function(e,t){return new Date(e.getTime()+60*t*60*1e3)},a.addMinutes=function(e,t){return new Date(e.getTime()+60*t*1e3)},a.addSeconds=function(e,t){return new Date(e.getTime()+1e3*t)},a.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},a.subtract=function(e,t){var n=e.getTime()-t.getTime();return{toMilliseconds:function(){return n},toSeconds:function(){return n/1e3},toMinutes:function(){return n/6e4},toHours:function(){return n/36e5},toDays:function(){return n/864e5}}},a.isLeapYear=function(e){return!((e%4||!(e%100))&&e%400)},a.isSameDay=function(e,t){return e.toDateString()===t.toDateString()},a.locale=function(e,n){t[e]||(t[e]=n)},a.plugin=function(e,t){n[e]||(n[e]=t)},(e=s(a)).locale=function(c){var f="function"==typeof c?c:e.locale[c];if(!f)return r;r=f(a);var d=t[r]||{},l=s(u,d.res,!0),g=s(i,d.formatter,!0,l),h=s(o,d.parser,!0,l);for(var M in e._formatter=g,e._parser=h,n)e.extend(n[M]);return r},e.extend=function(t){var n=s(e._parser.res,t.res),r=t.extender||{};for(var u in e._formatter=s(e._formatter,t.formatter,!1,n),e._parser=s(e._parser,t.parser,!1,n),r)e[u]||(e[u]=r[u])},e.plugin=function(t){var r="function"==typeof t?t:e.plugin[t];r&&e.extend(n[r(a,e)]||{})},e}));
|
package/esm/date-and-time.es.js
CHANGED
|
@@ -303,12 +303,14 @@ proto.addMonths = function (dateObj, months, utc) {
|
|
|
303
303
|
if (utc) {
|
|
304
304
|
d.setUTCMonth(d.getUTCMonth() + months);
|
|
305
305
|
if (d.getUTCDate() < dateObj.getUTCDate()) {
|
|
306
|
-
|
|
306
|
+
d.setUTCDate(0);
|
|
307
|
+
return d;
|
|
307
308
|
}
|
|
308
309
|
} else {
|
|
309
310
|
d.setMonth(d.getMonth() + months);
|
|
310
311
|
if (d.getDate() < dateObj.getDate()) {
|
|
311
|
-
|
|
312
|
+
d.setDate(0);
|
|
313
|
+
return d;
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
316
|
return d;
|
|
@@ -322,58 +324,54 @@ proto.addMonths = function (dateObj, months, utc) {
|
|
|
322
324
|
* @returns {Date} The Date object after adding the value
|
|
323
325
|
*/
|
|
324
326
|
proto.addDays = function (dateObj, days, utc) {
|
|
325
|
-
|
|
327
|
+
var d = new Date(dateObj.getTime());
|
|
328
|
+
|
|
329
|
+
if (utc) {
|
|
330
|
+
d.setUTCDate(d.getUTCDate() + days);
|
|
331
|
+
} else {
|
|
332
|
+
d.setDate(d.getDate() + days);
|
|
333
|
+
}
|
|
334
|
+
return d;
|
|
326
335
|
};
|
|
327
336
|
|
|
328
337
|
/**
|
|
329
338
|
* Adding hours
|
|
330
339
|
* @param {Date} dateObj - A Date object
|
|
331
340
|
* @param {number} hours - Number of hours to add
|
|
332
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
333
341
|
* @returns {Date} The Date object after adding the value
|
|
334
342
|
*/
|
|
335
|
-
proto.addHours = function (dateObj, hours
|
|
336
|
-
return (
|
|
343
|
+
proto.addHours = function (dateObj, hours) {
|
|
344
|
+
return new Date(dateObj.getTime() + hours * 60 * 60 * 1000);
|
|
337
345
|
};
|
|
338
346
|
|
|
339
347
|
/**
|
|
340
348
|
* Adding minutes
|
|
341
349
|
* @param {Date} dateObj - A Date object
|
|
342
350
|
* @param {number} minutes - Number of minutes to add
|
|
343
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
344
351
|
* @returns {Date} The Date object after adding the value
|
|
345
352
|
*/
|
|
346
|
-
proto.addMinutes = function (dateObj, minutes
|
|
347
|
-
return (
|
|
353
|
+
proto.addMinutes = function (dateObj, minutes) {
|
|
354
|
+
return new Date(dateObj.getTime() + minutes * 60 * 1000);
|
|
348
355
|
};
|
|
349
356
|
|
|
350
357
|
/**
|
|
351
358
|
* Adding seconds
|
|
352
359
|
* @param {Date} dateObj - A Date object
|
|
353
360
|
* @param {number} seconds - Number of seconds to add
|
|
354
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
355
361
|
* @returns {Date} The Date object after adding the value
|
|
356
362
|
*/
|
|
357
|
-
proto.addSeconds = function (dateObj, seconds
|
|
358
|
-
return (
|
|
363
|
+
proto.addSeconds = function (dateObj, seconds) {
|
|
364
|
+
return new Date(dateObj.getTime() + seconds * 1000);
|
|
359
365
|
};
|
|
360
366
|
|
|
361
367
|
/**
|
|
362
368
|
* Adding milliseconds
|
|
363
369
|
* @param {Date} dateObj - A Date object
|
|
364
370
|
* @param {number} milliseconds - Number of milliseconds to add
|
|
365
|
-
* @param {boolean} [utc] - Calculates as UTC
|
|
366
371
|
* @returns {Date} The Date object after adding the value
|
|
367
372
|
*/
|
|
368
|
-
proto.addMilliseconds = function (dateObj, milliseconds
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (utc) {
|
|
372
|
-
d.setUTCMilliseconds(d.getUTCMilliseconds() + milliseconds);
|
|
373
|
-
} else {
|
|
374
|
-
d.setMilliseconds(d.getMilliseconds() + milliseconds);
|
|
375
|
-
}
|
|
376
|
-
return d;
|
|
373
|
+
proto.addMilliseconds = function (dateObj, milliseconds) {
|
|
374
|
+
return new Date(dateObj.getTime() + milliseconds);
|
|
377
375
|
};
|
|
378
376
|
|
|
379
377
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
|
|
3
3
|
*/
|
|
4
|
-
var e,t={},n={},r="en",
|
|
4
|
+
var e,t={},n={},r="en",u={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"]},i={YYYY:function(e){return("000"+e.getFullYear()).slice(-4)},YY:function(e){return("0"+e.getFullYear()).slice(-2)},Y:function(e){return""+e.getFullYear()},MMMM:function(e){return this.res.MMMM[e.getMonth()]},MMM:function(e){return this.res.MMM[e.getMonth()]},MM:function(e){return("0"+(e.getMonth()+1)).slice(-2)},M:function(e){return""+(e.getMonth()+1)},DD:function(e){return("0"+e.getDate()).slice(-2)},D:function(e){return""+e.getDate()},HH:function(e){return("0"+e.getHours()).slice(-2)},H:function(e){return""+e.getHours()},A:function(e){return this.res.A[e.getHours()>11|0]},hh:function(e){return("0"+(e.getHours()%12||12)).slice(-2)},h:function(e){return""+(e.getHours()%12||12)},mm:function(e){return("0"+e.getMinutes()).slice(-2)},m:function(e){return""+e.getMinutes()},ss:function(e){return("0"+e.getSeconds()).slice(-2)},s:function(e){return""+e.getSeconds()},SSS:function(e){return("00"+e.getMilliseconds()).slice(-3)},SS:function(e){return("0"+(e.getMilliseconds()/10|0)).slice(-2)},S:function(e){return""+(e.getMilliseconds()/100|0)},dddd:function(e){return this.res.dddd[e.getDay()]},ddd:function(e){return this.res.ddd[e.getDay()]},dd:function(e){return this.res.dd[e.getDay()]},Z:function(e){var t=e.getTimezoneOffset()/.6|0;return(t>0?"-":"+")+("000"+Math.abs(t-(t%100*.4|0))).slice(-4)},ZZ:function(e){var t=e.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+("0"+(n/60|0)).slice(-2)+":"+("0"+n%60).slice(-2)},post:function(e){return e},res:u},o={YYYY:function(e){return this.exec(/^\d{4}/,e)},Y:function(e){return this.exec(/^\d{1,4}/,e)},MMMM:function(e){var t=this.find(this.res.MMMM,e);return t.value++,t},MMM:function(e){var t=this.find(this.res.MMM,e);return t.value++,t},MM:function(e){return this.exec(/^\d\d/,e)},M:function(e){return this.exec(/^\d\d?/,e)},DD:function(e){return this.exec(/^\d\d/,e)},D:function(e){return this.exec(/^\d\d?/,e)},HH:function(e){return this.exec(/^\d\d/,e)},H:function(e){return this.exec(/^\d\d?/,e)},A:function(e){return this.find(this.res.A,e)},hh:function(e){return this.exec(/^\d\d/,e)},h:function(e){return this.exec(/^\d\d?/,e)},mm:function(e){return this.exec(/^\d\d/,e)},m:function(e){return this.exec(/^\d\d?/,e)},ss:function(e){return this.exec(/^\d\d/,e)},s:function(e){return this.exec(/^\d\d?/,e)},SSS:function(e){return this.exec(/^\d{1,3}/,e)},SS:function(e){var t=this.exec(/^\d\d?/,e);return t.value*=10,t},S:function(e){var t=this.exec(/^\d/,e);return t.value*=100,t},Z:function(e){var t=this.exec(/^[+-]\d{2}[0-5]\d/,e);return t.value=-60*(t.value/100|0)-t.value%100,t},ZZ:function(e){var t=/^([+-])(\d{2}):([0-5]\d)/.exec(e)||["","","",""];return{value:0-(60*(t[1]+t[2]|0)+(t[1]+t[3]|0)),length:t[0].length}},h12:function(e,t){return(12===e?0:e)+12*t},exec:function(e,t){var n=(e.exec(t)||[""])[0];return{value:0|n,length:n.length}},find:function(e,t){for(var n,r=-1,u=0,i=0,o=e.length;i<o;i++)n=e[i],!t.indexOf(n)&&n.length>u&&(r=i,u=n.length);return{value:r,length:u}},pre:function(e){return e},res:u},s=function(e,t,n,r){var u,i={};for(u in e)i[u]=e[u];for(u in t||{})!!n^!!i[u]||(i[u]=t[u]);return r&&(i.res=r),i},a={_formatter:i,_parser:o};a.compile=function(e){return[e].concat(e.match(/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g)||[])},a.format=function(t,n,r){for(var u,i=this||e,o="string"==typeof n?i.compile(n):n,s=i._formatter,a=function(){if(r){var e=new Date(t.getTime());return e.getFullYear=e.getUTCFullYear,e.getMonth=e.getUTCMonth,e.getDate=e.getUTCDate,e.getHours=e.getUTCHours,e.getMinutes=e.getUTCMinutes,e.getSeconds=e.getUTCSeconds,e.getMilliseconds=e.getUTCMilliseconds,e.getDay=e.getUTCDay,e.getTimezoneOffset=function(){return 0},e.getTimezoneName=function(){return"UTC"},e}return t}(),c=/^\[(.*)\]$/,f="",d=1,g=o.length;d<g;d++)f+=s[u=o[d]]?s.post(s[u](a,o[0])):c.test(u)?u.replace(c,"$1"):u;return f},a.preparse=function(t,n){var r=this||e,u="string"==typeof n?r.compile(n):n,i=r._parser,o={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},s=/^\[(.*)\]$/;t=i.pre(t);for(var a,c,f,d=1,g=u.length;d<g;d++)if(a=u[d],c=t.substring(o._index),i[a]){if(!(f=i[a](c,u[0])).length)break;o[f.token||a.charAt(0)]=f.value,o._index+=f.length,o._match++}else if(a===c.charAt(0)||" "===a)o._index++;else{if(!s.test(a)||c.indexOf(a.replace(s,"$1"))){if("..."===a){o._index=t.length;break}break}o._index+=a.length-2}return o.H=o.H||i.h12(o.h,o.A),o._length=t.length,o},a.parse=function(t,n,r){var u=this||e,i="string"==typeof n?u.compile(n):n,o=u.preparse(t,i);return u.isValid(o)?(o.M-=o.Y<100?22801:1,r||~u._parser.find(i,"ZZ").value?new Date(Date.UTC(o.Y,o.M,o.D,o.H,o.m+o.Z,o.s,o.S)):new Date(o.Y,o.M,o.D,o.H,o.m,o.s,o.S)):new Date(NaN)},a.isValid=function(t,n){var r="string"==typeof t?(this||e).preparse(t,n):t;return!(r._index<1||r._length<1||r._index-r._length||r._match<1||r.Y<1||r.Y>9999||r.M<1||r.M>12||r.D<1||r.D>new Date(r.Y,r.M,0).getDate()||r.H<0||r.H>23||r.m<0||r.m>59||r.s<0||r.s>59||r.S<0||r.S>999||r.Z<-840||r.Z>720)},a.transform=function(t,n,r,u){const i=this||e;return i.format(i.parse(t,n),r,u)},a.addYears=function(t,n,r){return(this||e).addMonths(t,12*n,r)},a.addMonths=function(e,t,n){var r=new Date(e.getTime());if(n){if(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate())return r.setUTCDate(0),r}else if(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate())return r.setDate(0),r;return r},a.addDays=function(e,t,n){var r=new Date(e.getTime());return n?r.setUTCDate(r.getUTCDate()+t):r.setDate(r.getDate()+t),r},a.addHours=function(e,t){return new Date(e.getTime()+60*t*60*1e3)},a.addMinutes=function(e,t){return new Date(e.getTime()+60*t*1e3)},a.addSeconds=function(e,t){return new Date(e.getTime()+1e3*t)},a.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},a.subtract=function(e,t){var n=e.getTime()-t.getTime();return{toMilliseconds:function(){return n},toSeconds:function(){return n/1e3},toMinutes:function(){return n/6e4},toHours:function(){return n/36e5},toDays:function(){return n/864e5}}},a.isLeapYear=function(e){return!((e%4||!(e%100))&&e%400)},a.isSameDay=function(e,t){return e.toDateString()===t.toDateString()},a.locale=function(e,n){t[e]||(t[e]=n)},a.plugin=function(e,t){n[e]||(n[e]=t)},(e=s(a)).locale=function(c){var f="function"==typeof c?c:e.locale[c];if(!f)return r;r=f(a);var d=t[r]||{},g=s(u,d.res,!0),l=s(i,d.formatter,!0,g),h=s(o,d.parser,!0,g);for(var M in e._formatter=l,e._parser=h,n)e.extend(n[M]);return r},e.extend=function(t){var n=s(e._parser.res,t.res),r=t.extender||{};for(var u in e._formatter=s(e._formatter,t.formatter,!1,n),e._parser=s(e._parser,t.parser,!1,n),r)e[u]||(e[u]=r[u])},e.plugin=function(t){var r="function"==typeof t?t:e.plugin[t];r&&e.extend(n[r(a,e)]||{})};var c=e;export{c as default};
|