date-and-time 2.4.3 → 3.0.1

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 CHANGED
@@ -25,14 +25,15 @@ npm i date-and-time
25
25
 
26
26
  ## Recent Changes
27
27
 
28
- - 2.4.3
29
- - Fixed an issue where using the `addMonths` function in regions with daylight saving time would return incorrect results.
28
+ - 3.0.1
29
+ - Fixed calculation of last day of month in `addYears()` and `addMonths()`.
30
+ - Fixed lint errors.
30
31
 
31
- - 2.4.2
32
- - Fixed an issue where the timezone plugin stopped working due to Node.js timezone update.
32
+ - 3.0.0
33
+ - **Breaking Changes!** Added `utc` option to the 3rd parameter of `addYears()`, `addMonths()`, `addDays()`, `addHours()`, `addMinutes()`, `addSeconds()` and `addMilliseconds()`. If you use these functions in timezones with daylight savings time, you may get different results depending on the 3rd parameter.
33
34
 
34
- - 2.4.1
35
- - Fixed the previous Jest support.
35
+ - 2.4.3
36
+ - Fixed an issue where using `addMonths()` in timezones with daylight saving time returned incorrect results.
36
37
 
37
38
  ## Usage
38
39
 
@@ -88,25 +89,25 @@ import date from '/path/to/date-and-time.es.min.js';
88
89
  - [transform](#transformdatestring-arg1-arg2-utc)
89
90
  - Format transformation of date and time strings (String -> String)
90
91
 
91
- - [addYears](#addyearsdateobj-years)
92
+ - [addYears](#addyearsdateobj-years-utc)
92
93
  - Adding years
93
94
 
94
- - [addMonths](#addmonthsdateobj-months)
95
+ - [addMonths](#addmonthsdateobj-months-utc)
95
96
  - Adding months
96
97
 
97
- - [addDays](#adddaysdateobj-days)
98
+ - [addDays](#adddaysdateobj-days-utc)
98
99
  - Adding days
99
100
 
100
- - [addHours](#addhoursdateobj-hours)
101
+ - [addHours](#addhoursdateobj-hours-utc)
101
102
  - Adding hours
102
103
 
103
- - [addMinutes](#addminutesdateobj-minutes)
104
+ - [addMinutes](#addminutesdateobj-minutes-utc)
104
105
  - Adding minutes
105
106
 
106
- - [addSeconds](#addsecondsdateobj-seconds)
107
+ - [addSeconds](#addsecondsdateobj-seconds-utc)
107
108
  - Adding seconds
108
109
 
109
- - [addMilliseconds](#addmillisecondsdateobj-milliseconds)
110
+ - [addMilliseconds](#addmillisecondsdateobj-milliseconds-utc)
110
111
  - Adding milliseconds
111
112
 
112
113
  - [subtract](#subtractdate1-date2)
@@ -428,32 +429,55 @@ date.transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
428
429
  date.transform('13:05', 'HH:mm', 'hh:mm A');
429
430
  ```
430
431
 
431
- ### addYears(dateObj, years)
432
+ ### addYears(dateObj, years[, utc])
432
433
 
433
434
  - @param {**Date**} dateObj - A Date object
434
435
  - @param {**number**} years - Number of years to add
436
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
435
437
  - @returns {**Date**} The Date object after adding the value
436
438
 
439
+ Adds years to the date object.
440
+
437
441
  ```javascript
438
442
  const now = new Date();
439
443
  const next_year = date.addYears(now, 1);
440
444
  ```
441
445
 
442
- ### addMonths(dateObj, months)
446
+ Exceptional behavior of the calculation for the last day of the month:
447
+
448
+ ```javascript
449
+ const now = new Date(Date.UTC(2020, 1, 29)); // => Feb 29 2020
450
+ const next_year = date.addYears(now, 1, true); // => Feb 28 2021
451
+ const next_next_year = date.addYears(next_year, 1, true); // => Feb 28 2022
452
+ ```
453
+
454
+ ### addMonths(dateObj, months[, utc])
443
455
 
444
456
  - @param {**Date**} dateObj - A Date object
445
457
  - @param {**number**} months - Number of months to add
458
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
446
459
  - @returns {**Date**} The Date object after adding the value
447
460
 
461
+ Adds months to the date object.
462
+
448
463
  ```javascript
449
464
  const now = new Date();
450
465
  const next_month = date.addMonths(now, 1);
451
466
  ```
452
467
 
453
- ### addDays(dateObj, days)
468
+ Exceptional behavior of the calculation for the last day of the month:
469
+
470
+ ```javascript
471
+ const now = new Date(Date.UTC(2023, 0, 31)); // => Jan 31 2023
472
+ const next_month = date.addMonths(now, 1, true); // => Feb 28 2023
473
+ const next_next_month = date.addMonths(next_month, 1, true); // => Mar 28 2023
474
+ ```
475
+
476
+ ### addDays(dateObj, days[, utc])
454
477
 
455
478
  - @param {**Date**} dateObj - A Date object
456
479
  - @param {**number**} days - Number of days to add
480
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
457
481
  - @returns {**Date**} The Date object after adding the value
458
482
 
459
483
  ```javascript
@@ -461,10 +485,11 @@ const now = new Date();
461
485
  const yesterday = date.addDays(now, -1);
462
486
  ```
463
487
 
464
- ### addHours(dateObj, hours)
488
+ ### addHours(dateObj, hours[, utc])
465
489
 
466
490
  - @param {**Date**} dateObj - A Date object
467
491
  - @param {**number**} hours - Number of hours to add
492
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
468
493
  - @returns {**Date**} The Date object after adding the value
469
494
 
470
495
  ```javascript
@@ -472,10 +497,11 @@ const now = new Date();
472
497
  const an_hour_ago = date.addHours(now, -1);
473
498
  ```
474
499
 
475
- ### addMinutes(dateObj, minutes)
500
+ ### addMinutes(dateObj, minutes[, utc])
476
501
 
477
502
  - @param {**Date**} dateObj - A Date object
478
503
  - @param {**number**} minutes - Number of minutes to add
504
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
479
505
  - @returns {**Date**} The Date object after adding the value
480
506
 
481
507
  ```javascript
@@ -483,10 +509,11 @@ const now = new Date();
483
509
  const two_minutes_later = date.addMinutes(now, 2);
484
510
  ```
485
511
 
486
- ### addSeconds(dateObj, seconds)
512
+ ### addSeconds(dateObj, seconds[, utc])
487
513
 
488
514
  - @param {**Date**} dateObj - A Date object
489
515
  - @param {**number**} seconds - Number of seconds to add
516
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
490
517
  - @returns {**Date**} The Date object after adding the value
491
518
 
492
519
  ```javascript
@@ -494,10 +521,11 @@ const now = new Date();
494
521
  const three_seconds_ago = date.addSeconds(now, -3);
495
522
  ```
496
523
 
497
- ### addMilliseconds(dateObj, milliseconds)
524
+ ### addMilliseconds(dateObj, milliseconds[, utc])
498
525
 
499
526
  - @param {**Date**} dateObj - A Date object
500
527
  - @param {**number**} milliseconds - Number of milliseconds to add
528
+ - @param {**boolean**} [utc] - Calculates as UTC `Added in: v3.0.0`
501
529
  - @returns {**Date**} The Date object after adding the value
502
530
 
503
531
  ```javascript
@@ -154,57 +154,64 @@ export function transform(dateString: string, compiledObj1: string[], compiledOb
154
154
  * Adding years
155
155
  * @param dateObj - A Date object
156
156
  * @param years - Number of years to add
157
+ * @param [utc] - Calculates as UTC
157
158
  * @returns The Date object after adding the value
158
159
  */
159
- export function addYears(dateObj: Date, years: number): Date;
160
+ export function addYears(dateObj: Date, years: number, utc?: boolean): Date;
160
161
 
161
162
  /**
162
163
  * Adding months
163
164
  * @param dateObj - A Date object
164
165
  * @param months - Number of months to add
166
+ * @param [utc] - Calculates as UTC
165
167
  * @returns The Date object after adding the value
166
168
  */
167
- export function addMonths(dateObj: Date, months: number): Date;
169
+ export function addMonths(dateObj: Date, months: number, utc?: boolean): Date;
168
170
 
169
171
  /**
170
172
  * Adding days
171
173
  * @param dateObj - A Date object
172
174
  * @param days - Number of days to add
175
+ * @param [utc] - Calculates as UTC
173
176
  * @returns The Date object after adding the value
174
177
  */
175
- export function addDays(dateObj: Date, days: number): Date;
178
+ export function addDays(dateObj: Date, days: number, utc?: boolean): Date;
176
179
 
177
180
  /**
178
181
  * Adding hours
179
182
  * @param dateObj - A Date object
180
183
  * @param hours - Number of hours to add
184
+ * @param [utc] - Calculates as UTC
181
185
  * @returns The Date object after adding the value
182
186
  */
183
- export function addHours(dateObj: Date, hours: number): Date;
187
+ export function addHours(dateObj: Date, hours: number, utc?: boolean): Date;
184
188
 
185
189
  /**
186
190
  * Adding minutes
187
191
  * @param dateObj - A Date object
188
192
  * @param minutes - Number of minutes to add
193
+ * @param [utc] - Calculates as UTC
189
194
  * @returns The Date object after adding the value
190
195
  */
191
- export function addMinutes(dateObj: Date, minutes: number): Date;
196
+ export function addMinutes(dateObj: Date, minutes: number, utc?: boolean): Date;
192
197
 
193
198
  /**
194
199
  * Adding seconds
195
200
  * @param dateObj - A Date object
196
201
  * @param seconds - Number of seconds to add
202
+ * @param [utc] - Calculates as UTC
197
203
  * @returns The Date object after adding the value
198
204
  */
199
- export function addSeconds(dateObj: Date, seconds: number): Date;
205
+ export function addSeconds(dateObj: Date, seconds: number, utc?: boolean): Date;
200
206
 
201
207
  /**
202
208
  * Adding milliseconds
203
209
  * @param dateObj - A Date object
204
210
  * @param milliseconds - Number of milliseconds to add
211
+ * @param [utc] - Calculates as UTC
205
212
  * @returns The Date object after adding the value
206
213
  */
207
- export function addMilliseconds(dateObj: Date, milliseconds: number): Date;
214
+ export function addMilliseconds(dateObj: Date, milliseconds: number, utc?: boolean): Date;
208
215
 
209
216
  /** Subtraction result object */
210
217
  export type SubtractResult = {
package/date-and-time.js CHANGED
@@ -94,12 +94,12 @@
94
94
  return result;
95
95
  },
96
96
  Z: function (str/*, formatString */) {
97
- var result = this.exec(/^[\+-]\d{2}[0-5]\d/, str);
97
+ var result = this.exec(/^[+-]\d{2}[0-5]\d/, str);
98
98
  result.value = (result.value / 100 | 0) * -60 - result.value % 100;
99
99
  return result;
100
100
  },
101
101
  ZZ: function (str/*, formatString */) {
102
- var arr = /^([\+-])(\d{2}):([0-5]\d)/.exec(str) || ['', '', '', ''];
102
+ var arr = /^([+-])(\d{2}):([0-5]\d)/.exec(str) || ['', '', '', ''];
103
103
  return { value: 0 - ((arr[1] + arr[2] | 0) * 60 + (arr[1] + arr[3] | 0)), length: arr[0].length };
104
104
  },
105
105
  h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
@@ -151,7 +151,7 @@
151
151
  * @returns {Array.<string>} A compiled object
152
152
  */
153
153
  proto.compile = function (formatString) {
154
- var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
154
+ var re = /\[([^[\]]|\[[^[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
155
155
 
156
156
  while ((keys = re.exec(formatString))) {
157
157
  pattern[pattern.length] = keys[0];
@@ -214,7 +214,7 @@
214
214
  break;
215
215
  }
216
216
  }
217
- dt.H = dt.H || parser.h12(dt.h, dt.A);
217
+ dt.H ||= dt.H || parser.h12(dt.h, dt.A);
218
218
  dt._index = offset;
219
219
  dt._length = dateString.length;
220
220
  return dt;
@@ -276,22 +276,34 @@
276
276
  * Adding years
277
277
  * @param {Date} dateObj - A Date object
278
278
  * @param {number} years - Number of years to add
279
+ * @param {boolean} [utc] - Calculates as UTC
279
280
  * @returns {Date} The Date object after adding the value
280
281
  */
281
- proto.addYears = function (dateObj, years) {
282
- return (this || date).addMonths(dateObj, years * 12);
282
+ proto.addYears = function (dateObj, years, utc) {
283
+ return (this || date).addMonths(dateObj, years * 12, utc);
283
284
  };
284
285
 
285
286
  /**
286
287
  * Adding months
287
288
  * @param {Date} dateObj - A Date object
288
289
  * @param {number} months - Number of months to add
290
+ * @param {boolean} [utc] - Calculates as UTC
289
291
  * @returns {Date} The Date object after adding the value
290
292
  */
291
- proto.addMonths = function (dateObj, months) {
293
+ proto.addMonths = function (dateObj, months, utc) {
292
294
  var d = new Date(dateObj.getTime());
293
295
 
294
- d.setUTCMonth(d.getUTCMonth() + months);
296
+ if (utc) {
297
+ d.setUTCMonth(d.getUTCMonth() + months);
298
+ if (d.getUTCDate() < dateObj.getUTCDate()) {
299
+ return (this || date).addDays(d, -d.getUTCDate(), utc);
300
+ }
301
+ } else {
302
+ d.setMonth(d.getMonth() + months);
303
+ if (d.getDate() < dateObj.getDate()) {
304
+ return (this || date).addDays(d, -d.getDate(), utc);
305
+ }
306
+ }
295
307
  return d;
296
308
  };
297
309
 
@@ -299,53 +311,62 @@
299
311
  * Adding days
300
312
  * @param {Date} dateObj - A Date object
301
313
  * @param {number} days - Number of days to add
314
+ * @param {boolean} [utc] - Calculates as UTC
302
315
  * @returns {Date} The Date object after adding the value
303
316
  */
304
- proto.addDays = function (dateObj, days) {
305
- var d = new Date(dateObj.getTime());
306
-
307
- d.setUTCDate(d.getUTCDate() + days);
308
- return d;
317
+ proto.addDays = function (dateObj, days, utc) {
318
+ return (this || date).addHours(dateObj, days * 24, utc);
309
319
  };
310
320
 
311
321
  /**
312
322
  * Adding hours
313
323
  * @param {Date} dateObj - A Date object
314
324
  * @param {number} hours - Number of hours to add
325
+ * @param {boolean} [utc] - Calculates as UTC
315
326
  * @returns {Date} The Date object after adding the value
316
327
  */
317
- proto.addHours = function (dateObj, hours) {
318
- return (this || date).addMinutes(dateObj, hours * 60);
328
+ proto.addHours = function (dateObj, hours, utc) {
329
+ return (this || date).addMinutes(dateObj, hours * 60, utc);
319
330
  };
320
331
 
321
332
  /**
322
333
  * Adding minutes
323
334
  * @param {Date} dateObj - A Date object
324
335
  * @param {number} minutes - Number of minutes to add
336
+ * @param {boolean} [utc] - Calculates as UTC
325
337
  * @returns {Date} The Date object after adding the value
326
338
  */
327
- proto.addMinutes = function (dateObj, minutes) {
328
- return (this || date).addSeconds(dateObj, minutes * 60);
339
+ proto.addMinutes = function (dateObj, minutes, utc) {
340
+ return (this || date).addSeconds(dateObj, minutes * 60, utc);
329
341
  };
330
342
 
331
343
  /**
332
344
  * Adding seconds
333
345
  * @param {Date} dateObj - A Date object
334
346
  * @param {number} seconds - Number of seconds to add
347
+ * @param {boolean} [utc] - Calculates as UTC
335
348
  * @returns {Date} The Date object after adding the value
336
349
  */
337
- proto.addSeconds = function (dateObj, seconds) {
338
- return (this || date).addMilliseconds(dateObj, seconds * 1000);
350
+ proto.addSeconds = function (dateObj, seconds, utc) {
351
+ return (this || date).addMilliseconds(dateObj, seconds * 1000, utc);
339
352
  };
340
353
 
341
354
  /**
342
355
  * Adding milliseconds
343
356
  * @param {Date} dateObj - A Date object
344
357
  * @param {number} milliseconds - Number of milliseconds to add
358
+ * @param {boolean} [utc] - Calculates as UTC
345
359
  * @returns {Date} The Date object after adding the value
346
360
  */
347
- proto.addMilliseconds = function (dateObj, milliseconds) {
348
- return new Date(dateObj.getTime() + milliseconds);
361
+ proto.addMilliseconds = function (dateObj, milliseconds, utc) {
362
+ var d = new Date(dateObj.getTime());
363
+
364
+ if (utc) {
365
+ d.setUTCMilliseconds(d.getUTCMilliseconds() + milliseconds);
366
+ } else {
367
+ d.setMilliseconds(d.getMilliseconds() + milliseconds);
368
+ }
369
+ return d;
349
370
  };
350
371
 
351
372
  /**
@@ -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={},i="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"]},o={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},s={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,i=0,u=0,o=e.length;u<o;u++)n=e[u],!t.indexOf(n)&&n.length>i&&(r=u,i=n.length);return{value:r,length:i}},pre:function(e){return e},res:u},c=function(e,t,n,r){var i,u={};for(i in e)u[i]=e[i];for(i in t||{})!!n^!!u[i]||(u[i]=t[i]);return r&&(u.res=r),u},a={_formatter:o,_parser:s};return a.compile=function(e){for(var t,n=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},a.format=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,o=e.getTimezoneOffset(),s=i.addMinutes(e,r?o:0),c=i._formatter,a="";s.getTimezoneOffset=function(){return r?0:o};for(var f,d=1,l=u.length;d<l;d++)a+=c[f=u[d]]?c.post(c[f](s,u[0])):f.replace(/\[(.*)]/,"$1");return a},a.preparse=function(e,n){var r=this||t,i="string"==typeof n?r.compile(n):n,u={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},o=/\[(.*)]/,s=r._parser,c=0;e=s.pre(e);for(var a,f,d=1,l=i.length;d<l;d++)if(s[a=i[d]]){if(!(f=s[a](e.slice(c),i[0])).length)break;c+=f.length,u[f.token||a.charAt(0)]=f.value,u._match++}else if(a===e.charAt(c)||" "===a)c++;else{if(!o.test(a)||e.slice(c).indexOf(o.exec(a)[1])){if("..."===a){c=e.length;break}break}c+=a.length-2}return u.H=u.H||s.h12(u.h,u.A),u._index=c,u._length=e.length,u},a.parse=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,o=i.preparse(e,u);return i.isValid(o)?(o.M-=o.Y<100?22801:1,r||~i._parser.find(u,"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(e,n){var r=this||t,i="string"==typeof e?r.preparse(e,n):e,u=[31,28+r.isLeapYear(i.Y)|0,31,30,31,30,31,31,30,31,30,31][i.M-1];return!(i._index<1||i._length<1||i._index-i._length||i._match<1||i.Y<1||i.Y>9999||i.M<1||i.M>12||i.D<1||i.D>u||i.H<0||i.H>23||i.m<0||i.m>59||i.s<0||i.s>59||i.S<0||i.S>999||i.Z<-840||i.Z>720)},a.transform=function(e,n,r,i){const u=this||t;return u.format(u.parse(e,n),r,i)},a.addYears=function(e,n){return(this||t).addMonths(e,12*n)},a.addMonths=function(e,t){var n=new Date(e.getTime());return n.setUTCMonth(n.getUTCMonth()+t),n},a.addDays=function(e,t){var n=new Date(e.getTime());return n.setUTCDate(n.getUTCDate()+t),n},a.addHours=function(e,n){return(this||t).addMinutes(e,60*n)},a.addMinutes=function(e,n){return(this||t).addSeconds(e,60*n)},a.addSeconds=function(e,n){return(this||t).addMilliseconds(e,1e3*n)},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,t){n[e]||(n[e]=t)},a.plugin=function(e,t){r[e]||(r[e]=t)},e=c(a),(t=c(a)).locale=function(f){var d="function"==typeof f?f:t.locale[f];if(!d)return i;i=d(a);var l=n[i]||{},h=c(u,l.res,!0),M=c(o,l.formatter,!0,h),g=c(s,l.parser,!0,h);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return i},t.extend=function(e){var n=c(t._parser.res,e.res),r=e.extender||{};for(var i in t._formatter=c(t._formatter,e.formatter,!1,n),t._parser=c(t._parser,e.parser,!1,n),r)t[i]||(t[i]=r[i])},t.plugin=function(n){var i="function"==typeof n?n:t.plugin[n];i&&t.extend(r[i(a,e)]||{})},t}));
4
+ */var e,t,n={},r={},i="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"]},s={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,i=0,u=0,s=e.length;u<s;u++)n=e[u],!t.indexOf(n)&&n.length>i&&(r=u,i=n.length);return{value:r,length:i}},pre:function(e){return e},res:u},c=function(e,t,n,r){var i,u={};for(i in e)u[i]=e[i];for(i in t||{})!!n^!!u[i]||(u[i]=t[i]);return r&&(u.res=r),u},a={_formatter:s,_parser:o};return a.compile=function(e){for(var t,n=/\[([^[\]]|\[[^[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},a.format=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,s=e.getTimezoneOffset(),o=i.addMinutes(e,r?s:0),c=i._formatter,a="";o.getTimezoneOffset=function(){return r?0:s};for(var f,d=1,l=u.length;d<l;d++)a+=c[f=u[d]]?c.post(c[f](o,u[0])):f.replace(/\[(.*)]/,"$1");return a},a.preparse=function(e,n){var r=this||t,i="string"==typeof n?r.compile(n):n,u={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=/\[(.*)]/,o=r._parser,c=0;e=o.pre(e);for(var a,f,d=1,l=i.length;d<l;d++)if(o[a=i[d]]){if(!(f=o[a](e.slice(c),i[0])).length)break;c+=f.length,u[f.token||a.charAt(0)]=f.value,u._match++}else if(a===e.charAt(c)||" "===a)c++;else{if(!s.test(a)||e.slice(c).indexOf(s.exec(a)[1])){if("..."===a){c=e.length;break}break}c+=a.length-2}return u.H||=u.H||o.h12(u.h,u.A),u._index=c,u._length=e.length,u},a.parse=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,s=i.preparse(e,u);return i.isValid(s)?(s.M-=s.Y<100?22801:1,r||~i._parser.find(u,"ZZ").value?new Date(Date.UTC(s.Y,s.M,s.D,s.H,s.m+s.Z,s.s,s.S)):new Date(s.Y,s.M,s.D,s.H,s.m,s.s,s.S)):new Date(NaN)},a.isValid=function(e,n){var r=this||t,i="string"==typeof e?r.preparse(e,n):e,u=[31,28+r.isLeapYear(i.Y)|0,31,30,31,30,31,31,30,31,30,31][i.M-1];return!(i._index<1||i._length<1||i._index-i._length||i._match<1||i.Y<1||i.Y>9999||i.M<1||i.M>12||i.D<1||i.D>u||i.H<0||i.H>23||i.m<0||i.m>59||i.s<0||i.s>59||i.S<0||i.S>999||i.Z<-840||i.Z>720)},a.transform=function(e,n,r,i){const u=this||t;return u.format(u.parse(e,n),r,i)},a.addYears=function(e,n,r){return(this||t).addMonths(e,12*n,r)},a.addMonths=function(e,n,r){var i=new Date(e.getTime());if(r){if(i.setUTCMonth(i.getUTCMonth()+n),i.getUTCDate()<e.getUTCDate())return(this||t).addDays(i,-i.getUTCDate(),r)}else if(i.setMonth(i.getMonth()+n),i.getDate()<e.getDate())return(this||t).addDays(i,-i.getDate(),r);return i},a.addDays=function(e,n,r){return(this||t).addHours(e,24*n,r)},a.addHours=function(e,n,r){return(this||t).addMinutes(e,60*n,r)},a.addMinutes=function(e,n,r){return(this||t).addSeconds(e,60*n,r)},a.addSeconds=function(e,n,r){return(this||t).addMilliseconds(e,1e3*n,r)},a.addMilliseconds=function(e,t,n){var r=new Date(e.getTime());return n?r.setUTCMilliseconds(r.getUTCMilliseconds()+t):r.setMilliseconds(r.getMilliseconds()+t),r},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,t){n[e]||(n[e]=t)},a.plugin=function(e,t){r[e]||(r[e]=t)},e=c(a),(t=c(a)).locale=function(f){var d="function"==typeof f?f:t.locale[f];if(!d)return i;i=d(a);var l=n[i]||{},h=c(u,l.res,!0),M=c(s,l.formatter,!0,h),g=c(o,l.parser,!0,h);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return i},t.extend=function(e){var n=c(t._parser.res,e.res),r=e.extender||{};for(var i in t._formatter=c(t._formatter,e.formatter,!1,n),t._parser=c(t._parser,e.parser,!1,n),r)t[i]||(t[i]=r[i])},t.plugin=function(n){var i="function"==typeof n?n:t.plugin[n];i&&t.extend(r[i(a,e)]||{})},t}));
@@ -88,12 +88,12 @@ var locales = {},
88
88
  return result;
89
89
  },
90
90
  Z: function (str/*, formatString */) {
91
- var result = this.exec(/^[\+-]\d{2}[0-5]\d/, str);
91
+ var result = this.exec(/^[+-]\d{2}[0-5]\d/, str);
92
92
  result.value = (result.value / 100 | 0) * -60 - result.value % 100;
93
93
  return result;
94
94
  },
95
95
  ZZ: function (str/*, formatString */) {
96
- var arr = /^([\+-])(\d{2}):([0-5]\d)/.exec(str) || ['', '', '', ''];
96
+ var arr = /^([+-])(\d{2}):([0-5]\d)/.exec(str) || ['', '', '', ''];
97
97
  return { value: 0 - ((arr[1] + arr[2] | 0) * 60 + (arr[1] + arr[3] | 0)), length: arr[0].length };
98
98
  },
99
99
  h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
@@ -145,7 +145,7 @@ var locales = {},
145
145
  * @returns {Array.<string>} A compiled object
146
146
  */
147
147
  proto.compile = function (formatString) {
148
- var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
148
+ var re = /\[([^[\]]|\[[^[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
149
149
 
150
150
  while ((keys = re.exec(formatString))) {
151
151
  pattern[pattern.length] = keys[0];
@@ -208,7 +208,7 @@ proto.preparse = function (dateString, arg) {
208
208
  break;
209
209
  }
210
210
  }
211
- dt.H = dt.H || parser.h12(dt.h, dt.A);
211
+ dt.H ||= dt.H || parser.h12(dt.h, dt.A);
212
212
  dt._index = offset;
213
213
  dt._length = dateString.length;
214
214
  return dt;
@@ -270,22 +270,34 @@ proto.transform = function (dateString, arg1, arg2, utc) {
270
270
  * Adding years
271
271
  * @param {Date} dateObj - A Date object
272
272
  * @param {number} years - Number of years to add
273
+ * @param {boolean} [utc] - Calculates as UTC
273
274
  * @returns {Date} The Date object after adding the value
274
275
  */
275
- proto.addYears = function (dateObj, years) {
276
- return (this || date).addMonths(dateObj, years * 12);
276
+ proto.addYears = function (dateObj, years, utc) {
277
+ return (this || date).addMonths(dateObj, years * 12, utc);
277
278
  };
278
279
 
279
280
  /**
280
281
  * Adding months
281
282
  * @param {Date} dateObj - A Date object
282
283
  * @param {number} months - Number of months to add
284
+ * @param {boolean} [utc] - Calculates as UTC
283
285
  * @returns {Date} The Date object after adding the value
284
286
  */
285
- proto.addMonths = function (dateObj, months) {
287
+ proto.addMonths = function (dateObj, months, utc) {
286
288
  var d = new Date(dateObj.getTime());
287
289
 
288
- d.setUTCMonth(d.getUTCMonth() + months);
290
+ if (utc) {
291
+ d.setUTCMonth(d.getUTCMonth() + months);
292
+ if (d.getUTCDate() < dateObj.getUTCDate()) {
293
+ return (this || date).addDays(d, -d.getUTCDate(), utc);
294
+ }
295
+ } else {
296
+ d.setMonth(d.getMonth() + months);
297
+ if (d.getDate() < dateObj.getDate()) {
298
+ return (this || date).addDays(d, -d.getDate(), utc);
299
+ }
300
+ }
289
301
  return d;
290
302
  };
291
303
 
@@ -293,53 +305,62 @@ proto.addMonths = function (dateObj, months) {
293
305
  * Adding days
294
306
  * @param {Date} dateObj - A Date object
295
307
  * @param {number} days - Number of days to add
308
+ * @param {boolean} [utc] - Calculates as UTC
296
309
  * @returns {Date} The Date object after adding the value
297
310
  */
298
- proto.addDays = function (dateObj, days) {
299
- var d = new Date(dateObj.getTime());
300
-
301
- d.setUTCDate(d.getUTCDate() + days);
302
- return d;
311
+ proto.addDays = function (dateObj, days, utc) {
312
+ return (this || date).addHours(dateObj, days * 24, utc);
303
313
  };
304
314
 
305
315
  /**
306
316
  * Adding hours
307
317
  * @param {Date} dateObj - A Date object
308
318
  * @param {number} hours - Number of hours to add
319
+ * @param {boolean} [utc] - Calculates as UTC
309
320
  * @returns {Date} The Date object after adding the value
310
321
  */
311
- proto.addHours = function (dateObj, hours) {
312
- return (this || date).addMinutes(dateObj, hours * 60);
322
+ proto.addHours = function (dateObj, hours, utc) {
323
+ return (this || date).addMinutes(dateObj, hours * 60, utc);
313
324
  };
314
325
 
315
326
  /**
316
327
  * Adding minutes
317
328
  * @param {Date} dateObj - A Date object
318
329
  * @param {number} minutes - Number of minutes to add
330
+ * @param {boolean} [utc] - Calculates as UTC
319
331
  * @returns {Date} The Date object after adding the value
320
332
  */
321
- proto.addMinutes = function (dateObj, minutes) {
322
- return (this || date).addSeconds(dateObj, minutes * 60);
333
+ proto.addMinutes = function (dateObj, minutes, utc) {
334
+ return (this || date).addSeconds(dateObj, minutes * 60, utc);
323
335
  };
324
336
 
325
337
  /**
326
338
  * Adding seconds
327
339
  * @param {Date} dateObj - A Date object
328
340
  * @param {number} seconds - Number of seconds to add
341
+ * @param {boolean} [utc] - Calculates as UTC
329
342
  * @returns {Date} The Date object after adding the value
330
343
  */
331
- proto.addSeconds = function (dateObj, seconds) {
332
- return (this || date).addMilliseconds(dateObj, seconds * 1000);
344
+ proto.addSeconds = function (dateObj, seconds, utc) {
345
+ return (this || date).addMilliseconds(dateObj, seconds * 1000, utc);
333
346
  };
334
347
 
335
348
  /**
336
349
  * Adding milliseconds
337
350
  * @param {Date} dateObj - A Date object
338
351
  * @param {number} milliseconds - Number of milliseconds to add
352
+ * @param {boolean} [utc] - Calculates as UTC
339
353
  * @returns {Date} The Date object after adding the value
340
354
  */
341
- proto.addMilliseconds = function (dateObj, milliseconds) {
342
- return new Date(dateObj.getTime() + milliseconds);
355
+ proto.addMilliseconds = function (dateObj, milliseconds, utc) {
356
+ var d = new Date(dateObj.getTime());
357
+
358
+ if (utc) {
359
+ d.setUTCMilliseconds(d.getUTCMilliseconds() + milliseconds);
360
+ } else {
361
+ d.setMilliseconds(d.getMilliseconds() + milliseconds);
362
+ }
363
+ return d;
343
364
  };
344
365
 
345
366
  /**
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @preserve date-and-time (c) KNOWLEDGECODE | MIT
3
3
  */
4
- var e,t,n={},r={},u="en",i={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"]},o={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:i},s={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:i},c=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:o,_parser:s};a.compile=function(e){for(var t,n=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},a.format=function(e,n,r){var u=this||t,i="string"==typeof n?u.compile(n):n,o=e.getTimezoneOffset(),s=u.addMinutes(e,r?o:0),c=u._formatter,a="";s.getTimezoneOffset=function(){return r?0:o};for(var f,d=1,h=i.length;d<h;d++)a+=c[f=i[d]]?c.post(c[f](s,i[0])):f.replace(/\[(.*)]/,"$1");return a},a.preparse=function(e,n){var r=this||t,u="string"==typeof n?r.compile(n):n,i={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},o=/\[(.*)]/,s=r._parser,c=0;e=s.pre(e);for(var a,f,d=1,h=u.length;d<h;d++)if(s[a=u[d]]){if(!(f=s[a](e.slice(c),u[0])).length)break;c+=f.length,i[f.token||a.charAt(0)]=f.value,i._match++}else if(a===e.charAt(c)||" "===a)c++;else{if(!o.test(a)||e.slice(c).indexOf(o.exec(a)[1])){if("..."===a){c=e.length;break}break}c+=a.length-2}return i.H=i.H||s.h12(i.h,i.A),i._index=c,i._length=e.length,i},a.parse=function(e,n,r){var u=this||t,i="string"==typeof n?u.compile(n):n,o=u.preparse(e,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(e,n){var r=this||t,u="string"==typeof e?r.preparse(e,n):e,i=[31,28+r.isLeapYear(u.Y)|0,31,30,31,30,31,31,30,31,30,31][u.M-1];return!(u._index<1||u._length<1||u._index-u._length||u._match<1||u.Y<1||u.Y>9999||u.M<1||u.M>12||u.D<1||u.D>i||u.H<0||u.H>23||u.m<0||u.m>59||u.s<0||u.s>59||u.S<0||u.S>999||u.Z<-840||u.Z>720)},a.transform=function(e,n,r,u){const i=this||t;return i.format(i.parse(e,n),r,u)},a.addYears=function(e,n){return(this||t).addMonths(e,12*n)},a.addMonths=function(e,t){var n=new Date(e.getTime());return n.setUTCMonth(n.getUTCMonth()+t),n},a.addDays=function(e,t){var n=new Date(e.getTime());return n.setUTCDate(n.getUTCDate()+t),n},a.addHours=function(e,n){return(this||t).addMinutes(e,60*n)},a.addMinutes=function(e,n){return(this||t).addSeconds(e,60*n)},a.addSeconds=function(e,n){return(this||t).addMilliseconds(e,1e3*n)},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,t){n[e]||(n[e]=t)},a.plugin=function(e,t){r[e]||(r[e]=t)},e=c(a),(t=c(a)).locale=function(f){var d="function"==typeof f?f:t.locale[f];if(!d)return u;u=d(a);var h=n[u]||{},l=c(i,h.res,!0),M=c(o,h.formatter,!0,l),g=c(s,h.parser,!0,l);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return u},t.extend=function(e){var n=c(t._parser.res,e.res),r=e.extender||{};for(var u in t._formatter=c(t._formatter,e.formatter,!1,n),t._parser=c(t._parser,e.parser,!1,n),r)t[u]||(t[u]=r[u])},t.plugin=function(n){var u="function"==typeof n?n:t.plugin[n];u&&t.extend(r[u(a,e)]||{})};var f=t;export{f as default};
4
+ var e,t,n={},r={},i="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"]},s={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,i=0,u=0,s=e.length;u<s;u++)n=e[u],!t.indexOf(n)&&n.length>i&&(r=u,i=n.length);return{value:r,length:i}},pre:function(e){return e},res:u},a=function(e,t,n,r){var i,u={};for(i in e)u[i]=e[i];for(i in t||{})!!n^!!u[i]||(u[i]=t[i]);return r&&(u.res=r),u},c={_formatter:s,_parser:o};c.compile=function(e){for(var t,n=/\[([^[\]]|\[[^[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},c.format=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,s=e.getTimezoneOffset(),o=i.addMinutes(e,r?s:0),a=i._formatter,c="";o.getTimezoneOffset=function(){return r?0:s};for(var d,f=1,l=u.length;f<l;f++)c+=a[d=u[f]]?a.post(a[d](o,u[0])):d.replace(/\[(.*)]/,"$1");return c},c.preparse=function(e,n){var r=this||t,i="string"==typeof n?r.compile(n):n,u={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=/\[(.*)]/,o=r._parser,a=0;e=o.pre(e);for(var c,d,f=1,l=i.length;f<l;f++)if(o[c=i[f]]){if(!(d=o[c](e.slice(a),i[0])).length)break;a+=d.length,u[d.token||c.charAt(0)]=d.value,u._match++}else if(c===e.charAt(a)||" "===c)a++;else{if(!s.test(c)||e.slice(a).indexOf(s.exec(c)[1])){if("..."===c){a=e.length;break}break}a+=c.length-2}return u.H||=u.H||o.h12(u.h,u.A),u._index=a,u._length=e.length,u},c.parse=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,s=i.preparse(e,u);return i.isValid(s)?(s.M-=s.Y<100?22801:1,r||~i._parser.find(u,"ZZ").value?new Date(Date.UTC(s.Y,s.M,s.D,s.H,s.m+s.Z,s.s,s.S)):new Date(s.Y,s.M,s.D,s.H,s.m,s.s,s.S)):new Date(NaN)},c.isValid=function(e,n){var r=this||t,i="string"==typeof e?r.preparse(e,n):e,u=[31,28+r.isLeapYear(i.Y)|0,31,30,31,30,31,31,30,31,30,31][i.M-1];return!(i._index<1||i._length<1||i._index-i._length||i._match<1||i.Y<1||i.Y>9999||i.M<1||i.M>12||i.D<1||i.D>u||i.H<0||i.H>23||i.m<0||i.m>59||i.s<0||i.s>59||i.S<0||i.S>999||i.Z<-840||i.Z>720)},c.transform=function(e,n,r,i){const u=this||t;return u.format(u.parse(e,n),r,i)},c.addYears=function(e,n,r){return(this||t).addMonths(e,12*n,r)},c.addMonths=function(e,n,r){var i=new Date(e.getTime());if(r){if(i.setUTCMonth(i.getUTCMonth()+n),i.getUTCDate()<e.getUTCDate())return(this||t).addDays(i,-i.getUTCDate(),r)}else if(i.setMonth(i.getMonth()+n),i.getDate()<e.getDate())return(this||t).addDays(i,-i.getDate(),r);return i},c.addDays=function(e,n,r){return(this||t).addHours(e,24*n,r)},c.addHours=function(e,n,r){return(this||t).addMinutes(e,60*n,r)},c.addMinutes=function(e,n,r){return(this||t).addSeconds(e,60*n,r)},c.addSeconds=function(e,n,r){return(this||t).addMilliseconds(e,1e3*n,r)},c.addMilliseconds=function(e,t,n){var r=new Date(e.getTime());return n?r.setUTCMilliseconds(r.getUTCMilliseconds()+t):r.setMilliseconds(r.getMilliseconds()+t),r},c.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}}},c.isLeapYear=function(e){return!((e%4||!(e%100))&&e%400)},c.isSameDay=function(e,t){return e.toDateString()===t.toDateString()},c.locale=function(e,t){n[e]||(n[e]=t)},c.plugin=function(e,t){r[e]||(r[e]=t)},e=a(c),(t=a(c)).locale=function(d){var f="function"==typeof d?d:t.locale[d];if(!f)return i;i=f(c);var l=n[i]||{},h=a(u,l.res,!0),M=a(s,l.formatter,!0,h),g=a(o,l.parser,!0,h);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return i},t.extend=function(e){var n=a(t._parser.res,e.res),r=e.extender||{};for(var i in t._formatter=a(t._formatter,e.formatter,!1,n),t._parser=a(t._parser,e.parser,!1,n),r)t[i]||(t[i]=r[i])},t.plugin=function(n){var i="function"==typeof n?n:t.plugin[n];i&&t.extend(r[i(c,e)]||{})};var d=t;export{d as default};