date-and-time 2.1.2 → 2.3.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.
Files changed (54) hide show
  1. package/PLUGINS.md +42 -26
  2. package/README.md +88 -95
  3. package/date-and-time.d.ts +304 -0
  4. package/date-and-time.js +85 -74
  5. package/date-and-time.min.js +11 -10
  6. package/esm/date-and-time.es.js +85 -74
  7. package/esm/date-and-time.es.min.js +10 -10
  8. package/esm/date-and-time.mjs +85 -74
  9. package/esm/plugin/timezone.es.js +8 -6
  10. package/esm/plugin/timezone.mjs +8 -6
  11. package/locale/ar.d.ts +1 -0
  12. package/locale/az.d.ts +1 -0
  13. package/locale/bn.d.ts +1 -0
  14. package/locale/cs.d.ts +1 -0
  15. package/locale/de.d.ts +1 -0
  16. package/locale/dk.d.ts +1 -0
  17. package/locale/el.d.ts +1 -0
  18. package/locale/en.d.ts +1 -0
  19. package/locale/es.d.ts +1 -0
  20. package/locale/fa.d.ts +1 -0
  21. package/locale/fr.d.ts +1 -0
  22. package/locale/hi.d.ts +1 -0
  23. package/locale/hu.d.ts +1 -0
  24. package/locale/id.d.ts +1 -0
  25. package/locale/it.d.ts +1 -0
  26. package/locale/ja.d.ts +1 -0
  27. package/locale/jv.d.ts +1 -0
  28. package/locale/ko.d.ts +1 -0
  29. package/locale/my.d.ts +1 -0
  30. package/locale/nl.d.ts +1 -0
  31. package/locale/pa-in.d.ts +1 -0
  32. package/locale/pl.d.ts +1 -0
  33. package/locale/pt.d.ts +1 -0
  34. package/locale/ro.d.ts +1 -0
  35. package/locale/ru.d.ts +1 -0
  36. package/locale/rw.d.ts +1 -0
  37. package/locale/sr.d.ts +1 -0
  38. package/locale/sv.d.ts +1 -0
  39. package/locale/th.d.ts +1 -0
  40. package/locale/tr.d.ts +1 -0
  41. package/locale/uk.d.ts +1 -0
  42. package/locale/uz.d.ts +1 -0
  43. package/locale/vi.d.ts +1 -0
  44. package/locale/zh-cn.d.ts +1 -0
  45. package/locale/zh-tw.d.ts +1 -0
  46. package/package.json +7 -4
  47. package/plugin/day-of-week.d.ts +1 -0
  48. package/plugin/meridiem.d.ts +1 -0
  49. package/plugin/microsecond.d.ts +1 -0
  50. package/plugin/ordinal.d.ts +1 -0
  51. package/plugin/timespan.d.ts +24 -0
  52. package/plugin/timezone.d.ts +79 -0
  53. package/plugin/timezone.js +8 -6
  54. package/plugin/two-digit-year.d.ts +1 -0
@@ -42,6 +42,11 @@ var locales = {},
42
42
  var offset = d.getTimezoneOffset() / 0.6 | 0;
43
43
  return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
44
44
  },
45
+ ZZ: function (d/*, formatString*/) {
46
+ var offset = d.getTimezoneOffset();
47
+ var mod = Math.abs(offset);
48
+ return (offset > 0 ? '-' : '+') + ('0' + (mod / 60 | 0)).slice(-2) + ':' + ('0' + mod % 60).slice(-2);
49
+ },
45
50
  post: function (str) { return str; },
46
51
  res: _res
47
52
  },
@@ -87,6 +92,10 @@ var locales = {},
87
92
  result.value = (result.value / 100 | 0) * -60 - result.value % 100;
88
93
  return result;
89
94
  },
95
+ ZZ: function (str/*, formatString */) {
96
+ var arr = /^([\+-])(\d{2}):([0-5]\d)/.exec(str) || ['', '', '', ''];
97
+ return { value: 0 - ((arr[1] + arr[2] | 0) * 60 + (arr[1] + arr[3] | 0)), length: arr[0].length };
98
+ },
90
99
  h12: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
91
100
  exec: function (re, str) {
92
101
  var result = (re.exec(str) || [''])[0];
@@ -131,9 +140,9 @@ var locales = {},
131
140
  date;
132
141
 
133
142
  /**
134
- * Compiling a format string
135
- * @param {string} formatString - a format string
136
- * @returns {Array.<string>} a compiled object
143
+ * Compiling format strings
144
+ * @param {string} formatString - A format string
145
+ * @returns {Array.<string>} A compiled object
137
146
  */
138
147
  proto.compile = function (formatString) {
139
148
  var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
@@ -145,11 +154,11 @@ proto.compile = function (formatString) {
145
154
  };
146
155
 
147
156
  /**
148
- * Formatting a Date and Time
149
- * @param {Date} dateObj - a Date object
150
- * @param {string|Array.<string>} arg - a format string or its compiled object
151
- * @param {boolean} [utc] - output as UTC
152
- * @returns {string} a formatted string
157
+ * Formatting date and time objects (Date -> String)
158
+ * @param {Date} dateObj - A Date object
159
+ * @param {string|Array.<string>} arg - A format string or its compiled object
160
+ * @param {boolean} [utc] - Output as UTC
161
+ * @returns {string} A formatted string
153
162
  */
154
163
  proto.format = function (dateObj, arg, utc) {
155
164
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -166,10 +175,11 @@ proto.format = function (dateObj, arg, utc) {
166
175
  };
167
176
 
168
177
  /**
169
- * Pre-parsing a Date and Time string
170
- * @param {string} dateString - a date string
171
- * @param {string|Array.<string>} arg - a format string or its compiled object
172
- * @returns {Object} a date structure
178
+ * Pre-parsing date and time strings
179
+ * @param {string} dateString - A date and time string
180
+ * @param {string|Array.<string>} arg - A format string or its compiled object
181
+ * @param {boolean} [utc] - Input as UTC
182
+ * @returns {Object} A pre-parsed result object
173
183
  */
174
184
  proto.preparse = function (dateString, arg) {
175
185
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -205,18 +215,19 @@ proto.preparse = function (dateString, arg) {
205
215
  };
206
216
 
207
217
  /**
208
- * Parsing a Date and Time string
209
- * @param {string} dateString - a date string
210
- * @param {string|Array.<string>} arg - a format string or its compiled object
211
- * @param {boolean} [utc] - input as UTC
212
- * @returns {Date} a constructed date
218
+ * Parsing of date and time string (String -> Date)
219
+ * @param {string} dateString - A date-time string
220
+ * @param {string|Array.<string>} arg - A format string or its compiled object
221
+ * @param {boolean} [utc] - Input as UTC
222
+ * @returns {Date} A Date object
213
223
  */
214
224
  proto.parse = function (dateString, arg, utc) {
215
- var ctx = this || date, dt = ctx.preparse(dateString, arg);
225
+ var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
226
+ dt = ctx.preparse(dateString, pattern);
216
227
 
217
228
  if (ctx.isValid(dt)) {
218
229
  dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1
219
- if (utc || dt.Z) {
230
+ if (utc || ~ctx._parser.find(pattern, 'ZZ').value) {
220
231
  return new Date(Date.UTC(dt.Y, dt.M, dt.D, dt.H, dt.m + dt.Z, dt.s, dt.S));
221
232
  }
222
233
  return new Date(dt.Y, dt.M, dt.D, dt.H, dt.m, dt.s, dt.S);
@@ -225,10 +236,10 @@ proto.parse = function (dateString, arg, utc) {
225
236
  };
226
237
 
227
238
  /**
228
- * Validation
229
- * @param {Object|string} arg1 - a date structure or a date string
230
- * @param {string|Array.<string>} [arg2] - a format string or its compiled object
231
- * @returns {boolean} whether the date string is a valid date
239
+ * Date and time string validation
240
+ * @param {Object|string} arg1 - A pre-parsed result object or a date and time string
241
+ * @param {string|Array.<string>} [arg2] - A format string or its compiled object
242
+ * @returns {boolean} Whether the date and time string is a valid date and time
232
243
  */
233
244
  proto.isValid = function (arg1, arg2) {
234
245
  var ctx = this || date, dt = typeof arg1 === 'string' ? ctx.preparse(arg1, arg2) : arg1,
@@ -243,12 +254,12 @@ proto.isValid = function (arg1, arg2) {
243
254
  };
244
255
 
245
256
  /**
246
- * Transforming a Date and Time string
247
- * @param {string} dateString - a date string
248
- * @param {string|Array.<string>} arg1 - a format string or its compiled object
249
- * @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
250
- * @param {boolean} [utc] - output as UTC
251
- * @returns {string} a formatted string
257
+ * Format transformation of date and time string (String -> String)
258
+ * @param {string} dateString - A date and time string
259
+ * @param {string|Array.<string>} arg1 - A format string or its compiled object before transformation
260
+ * @param {string|Array.<string>} arg2 - A format string or its compiled object after transformation
261
+ * @param {boolean} [utc] - Output as UTC
262
+ * @returns {string} A formatted string
252
263
  */
253
264
  proto.transform = function (dateString, arg1, arg2, utc) {
254
265
  const ctx = this || date;
@@ -257,9 +268,9 @@ proto.transform = function (dateString, arg1, arg2, utc) {
257
268
 
258
269
  /**
259
270
  * Adding years
260
- * @param {Date} dateObj - a date object
261
- * @param {number} years - number of years to add
262
- * @returns {Date} a date after adding the value
271
+ * @param {Date} dateObj - A Date object
272
+ * @param {number} years - Number of years to add
273
+ * @returns {Date} The Date object after adding the value
263
274
  */
264
275
  proto.addYears = function (dateObj, years) {
265
276
  return (this || date).addMonths(dateObj, years * 12);
@@ -267,9 +278,9 @@ proto.addYears = function (dateObj, years) {
267
278
 
268
279
  /**
269
280
  * Adding months
270
- * @param {Date} dateObj - a date object
271
- * @param {number} months - number of months to add
272
- * @returns {Date} a date after adding the value
281
+ * @param {Date} dateObj - A Date object
282
+ * @param {number} months - Number of months to add
283
+ * @returns {Date} The Date object after adding the value
273
284
  */
274
285
  proto.addMonths = function (dateObj, months) {
275
286
  var d = new Date(dateObj.getTime());
@@ -280,9 +291,9 @@ proto.addMonths = function (dateObj, months) {
280
291
 
281
292
  /**
282
293
  * Adding days
283
- * @param {Date} dateObj - a date object
284
- * @param {number} days - number of days to add
285
- * @returns {Date} a date after adding the value
294
+ * @param {Date} dateObj - A Date object
295
+ * @param {number} days - Number of days to add
296
+ * @returns {Date} The Date object after adding the value
286
297
  */
287
298
  proto.addDays = function (dateObj, days) {
288
299
  var d = new Date(dateObj.getTime());
@@ -293,9 +304,9 @@ proto.addDays = function (dateObj, days) {
293
304
 
294
305
  /**
295
306
  * Adding hours
296
- * @param {Date} dateObj - a date object
297
- * @param {number} hours - number of hours to add
298
- * @returns {Date} a date after adding the value
307
+ * @param {Date} dateObj - A Date object
308
+ * @param {number} hours - Number of hours to add
309
+ * @returns {Date} The Date object after adding the value
299
310
  */
300
311
  proto.addHours = function (dateObj, hours) {
301
312
  return (this || date).addMinutes(dateObj, hours * 60);
@@ -303,9 +314,9 @@ proto.addHours = function (dateObj, hours) {
303
314
 
304
315
  /**
305
316
  * Adding minutes
306
- * @param {Date} dateObj - a date object
307
- * @param {number} minutes - number of minutes to add
308
- * @returns {Date} a date after adding the value
317
+ * @param {Date} dateObj - A Date object
318
+ * @param {number} minutes - Number of minutes to add
319
+ * @returns {Date} The Date object after adding the value
309
320
  */
310
321
  proto.addMinutes = function (dateObj, minutes) {
311
322
  return (this || date).addSeconds(dateObj, minutes * 60);
@@ -313,9 +324,9 @@ proto.addMinutes = function (dateObj, minutes) {
313
324
 
314
325
  /**
315
326
  * Adding seconds
316
- * @param {Date} dateObj - a date object
317
- * @param {number} seconds - number of seconds to add
318
- * @returns {Date} a date after adding the value
327
+ * @param {Date} dateObj - A Date object
328
+ * @param {number} seconds - Number of seconds to add
329
+ * @returns {Date} The Date object after adding the value
319
330
  */
320
331
  proto.addSeconds = function (dateObj, seconds) {
321
332
  return (this || date).addMilliseconds(dateObj, seconds * 1000);
@@ -323,19 +334,19 @@ proto.addSeconds = function (dateObj, seconds) {
323
334
 
324
335
  /**
325
336
  * Adding milliseconds
326
- * @param {Date} dateObj - a date object
327
- * @param {number} milliseconds - number of milliseconds to add
328
- * @returns {Date} a date after adding the value
337
+ * @param {Date} dateObj - A Date object
338
+ * @param {number} milliseconds - Number of milliseconds to add
339
+ * @returns {Date} The Date object after adding the value
329
340
  */
330
341
  proto.addMilliseconds = function (dateObj, milliseconds) {
331
342
  return new Date(dateObj.getTime() + milliseconds);
332
343
  };
333
344
 
334
345
  /**
335
- * Subtracting two dates
336
- * @param {Date} date1 - a Date object
337
- * @param {Date} date2 - a Date object
338
- * @returns {Object} a result object subtracting date2 from date1
346
+ * Subtracting two dates (date1 - date2)
347
+ * @param {Date} date1 - A Date object
348
+ * @param {Date} date2 - A Date object
349
+ * @returns {Object} The result object of subtracting date2 from date1
339
350
  */
340
351
  proto.subtract = function (date1, date2) {
341
352
  var delta = date1.getTime() - date2.getTime();
@@ -360,9 +371,9 @@ proto.subtract = function (date1, date2) {
360
371
  };
361
372
 
362
373
  /**
363
- * Whether year is leap year
364
- * @param {number} y - year
365
- * @returns {boolean} whether year is leap year
374
+ * Whether a year is a leap year
375
+ * @param {number} y - A year to check
376
+ * @returns {boolean} Whether the year is a leap year
366
377
  */
367
378
  proto.isLeapYear = function (y) {
368
379
  return (!(y % 4) && !!(y % 100)) || !(y % 400);
@@ -370,19 +381,19 @@ proto.isLeapYear = function (y) {
370
381
 
371
382
  /**
372
383
  * Comparison of two dates
373
- * @param {Date} date1 - a Date object
374
- * @param {Date} date2 - a Date object
375
- * @returns {boolean} whether the two dates are the same day (time is ignored)
384
+ * @param {Date} date1 - A Date object
385
+ * @param {Date} date2 - A Date object
386
+ * @returns {boolean} Whether the two dates are the same day (time is ignored)
376
387
  */
377
388
  proto.isSameDay = function (date1, date2) {
378
389
  return date1.toDateString() === date2.toDateString();
379
390
  };
380
391
 
381
392
  /**
382
- * Defining new locale
383
- * @param {string} code - language code
384
- * @param {Function} locale - locale installer
385
- * @returns {string} current language code
393
+ * Definition of new locale
394
+ * @param {string} code - A language code
395
+ * @param {Function} locale - A locale installer
396
+ * @returns {void}
386
397
  */
387
398
  proto.locale = function (code, locale) {
388
399
  if (!locales[code]) {
@@ -391,9 +402,9 @@ proto.locale = function (code, locale) {
391
402
  };
392
403
 
393
404
  /**
394
- * Defining new plugin
395
- * @param {string} name - plugin name
396
- * @param {Function} plugin - plugin installer
405
+ * Definition of new plugin
406
+ * @param {string} name - A plugin name
407
+ * @param {Function} plugin - A plugin installer
397
408
  * @returns {void}
398
409
  */
399
410
  proto.plugin = function (name, plugin) {
@@ -406,9 +417,9 @@ localized_proto = extend(proto);
406
417
  date = extend(proto);
407
418
 
408
419
  /**
409
- * Changing locale
410
- * @param {Function|string} [locale] - locale object | language code
411
- * @returns {string} current language code
420
+ * Changing locales
421
+ * @param {Function|string} [locale] - A locale installer or language code
422
+ * @returns {string} The current language code
412
423
  */
413
424
  date.locale = function (locale) {
414
425
  var install = typeof locale === 'function' ? locale : date.locale[locale];
@@ -434,8 +445,8 @@ date.locale = function (locale) {
434
445
  };
435
446
 
436
447
  /**
437
- * Feature extension
438
- * @param {Object} extension - extension object
448
+ * Functional extension
449
+ * @param {Object} extension - An extension object
439
450
  * @returns {void}
440
451
  */
441
452
  date.extend = function (extension) {
@@ -453,8 +464,8 @@ date.extend = function (extension) {
453
464
  };
454
465
 
455
466
  /**
456
- * Importing plugin
457
- * @param {Function|string} plugin - plugin object | plugin name
467
+ * Importing plugins
468
+ * @param {Function|string} plugin - A plugin installer or plugin name
458
469
  * @returns {void}
459
470
  */
460
471
  date.plugin = function (plugin) {
@@ -4,15 +4,15 @@
4
4
  var e={},f={},m="en",n={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},q={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+
5
5
  a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)},D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11<a.getHours()|0]},hh:function(a){return("0"+(a.getHours()%12||12)).slice(-2)},
6
6
  h:function(a){return""+(a.getHours()%12||12)},mm:function(a){return("0"+a.getMinutes()).slice(-2)},m:function(a){return""+a.getMinutes()},ss:function(a){return("0"+a.getSeconds()).slice(-2)},s:function(a){return""+a.getSeconds()},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},SS:function(a){return("0"+(a.getMilliseconds()/10|0)).slice(-2)},S:function(a){return""+(a.getMilliseconds()/100|0)},dddd:function(a){return this.res.dddd[a.getDay()]},ddd:function(a){return this.res.ddd[a.getDay()]},
7
- dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},post:function(a){return a},res:n},r={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},
8
- DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,
9
- a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/100|0)-a.value%100;return a},h12:function(a,b){return(12===a?0:a)+12*b},exec:function(a,b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var c=-1,d=0,h=0,g=a.length,l;h<g;h++)l=a[h],!b.indexOf(l)&&l.length>d&&(c=h,d=l.length);return{value:c,length:d}},pre:function(a){return a},
10
- res:n};function t(a,b,c,d){var h={},g;for(g in a)h[g]=a[g];for(g in b||{})!!c^!!h[g]||(h[g]=b[g]);d&&(h.res=d);return h}var u={_formatter:q,_parser:r},w,x;u.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,d=[a];c=b.exec(a);)d[d.length]=c[0];return d};
11
- u.format=function(a,b,c){var d=this||x;b="string"===typeof b?d.compile(b):b;var h=a.getTimezoneOffset();a=d.addMinutes(a,c?h:0);d=d._formatter;var g="";a.getTimezoneOffset=function(){return c?0:h};for(var l=1,v=b.length,k;l<v;l++)k=b[l],g+=d[k]?d.post(d[k](a,b[0])):k.replace(/\[(.*)]/,"$1");return g};
12
- u.preparse=function(a,b){var c=this||x;b="string"===typeof b?c.compile(b):b;var d={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},h=/\[(.*)]/;c=c._parser;var g=0;a=c.pre(a);for(var l=1,v=b.length,k,p;l<v;l++)if(k=b[l],c[k]){p=c[k](a.slice(g),b[0]);if(!p.length)break;g+=p.length;d[p.token||k.charAt(0)]=p.value;d._match++}else if(k===a.charAt(g)||" "===k)g++;else if(h.test(k)&&!a.slice(g).indexOf(h.exec(k)[1]))g+=k.length-2;else{"..."===k&&(g=a.length);break}d.H=d.H||c.h12(d.h,
13
- d.A);d._index=g;d._length=a.length;return d};u.parse=function(a,b,c){var d=this||x;a=d.preparse(a,b);return d.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};
14
- u.isValid=function(a,b){var c=this||x;a="string"===typeof a?c.preparse(a,b):a;c=[31,28+c.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>c||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-840>a.Z||720<a.Z)};u.transform=function(a,b,c,d){let h=this||x;return h.format(h.parse(a,b),c,d)};u.addYears=function(a,b){return(this||x).addMonths(a,12*b)};
7
+ dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},ZZ:function(a){a=a.getTimezoneOffset();var b=Math.abs(a);return(0<a?"-":"+")+("0"+(b/60|0)).slice(-2)+":"+("0"+b%60).slice(-2)},post:function(a){return a},res:n},r={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,
8
+ a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,
9
+ a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/100|0)-a.value%100;return a},ZZ:function(a){a=/^([\+-])(\d{2}):([0-5]\d)/.exec(a)||["","","",""];return{value:-(60*(a[1]+a[2]|0)+(a[1]+a[3]|0)),length:a[0].length}},h12:function(a,
10
+ b){return(12===a?0:a)+12*b},exec:function(a,b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var d=-1,c=0,h=0,g=a.length,l;h<g;h++)l=a[h],!b.indexOf(l)&&l.length>c&&(d=h,c=l.length);return{value:d,length:c}},pre:function(a){return a},res:n};function t(a,b,d,c){var h={},g;for(g in a)h[g]=a[g];for(g in b||{})!!d^!!h[g]||(h[g]=b[g]);c&&(h.res=c);return h}var u={_formatter:q,_parser:r},w,x;
11
+ u.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,d,c=[a];d=b.exec(a);)c[c.length]=d[0];return c};u.format=function(a,b,d){var c=this||x;b="string"===typeof b?c.compile(b):b;var h=a.getTimezoneOffset();a=c.addMinutes(a,d?h:0);c=c._formatter;var g="";a.getTimezoneOffset=function(){return d?0:h};for(var l=1,v=b.length,k;l<v;l++)k=b[l],g+=c[k]?c.post(c[k](a,b[0])):k.replace(/\[(.*)]/,"$1");return g};
12
+ u.preparse=function(a,b){var d=this||x;b="string"===typeof b?d.compile(b):b;var c={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},h=/\[(.*)]/;d=d._parser;var g=0;a=d.pre(a);for(var l=1,v=b.length,k,p;l<v;l++)if(k=b[l],d[k]){p=d[k](a.slice(g),b[0]);if(!p.length)break;g+=p.length;c[p.token||k.charAt(0)]=p.value;c._match++}else if(k===a.charAt(g)||" "===k)g++;else if(h.test(k)&&!a.slice(g).indexOf(h.exec(k)[1]))g+=k.length-2;else{"..."===k&&(g=a.length);break}c.H=c.H||d.h12(c.h,
13
+ c.A);c._index=g;c._length=a.length;return c};u.parse=function(a,b,d){var c=this||x;b="string"===typeof b?c.compile(b):b;a=c.preparse(a,b);return c.isValid(a)?(a.M-=100>a.Y?22801:1,d||~c._parser.find(b,"ZZ").value?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};
14
+ u.isValid=function(a,b){var d=this||x;a="string"===typeof a?d.preparse(a,b):a;d=[31,28+d.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>d||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-840>a.Z||720<a.Z)};u.transform=function(a,b,d,c){let h=this||x;return h.format(h.parse(a,b),d,c)};u.addYears=function(a,b){return(this||x).addMonths(a,12*b)};
15
15
  u.addMonths=function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a};u.addDays=function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a};u.addHours=function(a,b){return(this||x).addMinutes(a,60*b)};u.addMinutes=function(a,b){return(this||x).addSeconds(a,60*b)};u.addSeconds=function(a,b){return(this||x).addMilliseconds(a,1E3*b)};u.addMilliseconds=function(a,b){return new Date(a.getTime()+b)};
16
- u.subtract=function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}};u.isLeapYear=function(a){return!(a%4)&&!!(a%100)||!(a%400)};u.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};u.locale=function(a,b){e[a]||(e[a]=b)};u.plugin=function(a,b){f[a]||(f[a]=b)};w=t(u);x=t(u);
17
- x.locale=function(a){a="function"===typeof a?a:x.locale[a];if(!a)return m;m=a(u);var b=e[m]||{},c=t(n,b.res,!0);a=t(q,b.formatter,!0,c);b=t(r,b.parser,!0,c);x._formatter=w._formatter=a;x._parser=w._parser=b;for(var d in f)x.extend(f[d]);return m};x.extend=function(a){var b=t(x._parser.res,a.res),c=a.extender||{};x._formatter=t(x._formatter,a.formatter,!1,b);x._parser=t(x._parser,a.parser,!1,b);for(var d in c)x[d]||(x[d]=c[d])};
16
+ u.subtract=function(a,b){var d=a.getTime()-b.getTime();return{toMilliseconds:function(){return d},toSeconds:function(){return d/1E3},toMinutes:function(){return d/6E4},toHours:function(){return d/36E5},toDays:function(){return d/864E5}}};u.isLeapYear=function(a){return!(a%4)&&!!(a%100)||!(a%400)};u.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};u.locale=function(a,b){e[a]||(e[a]=b)};u.plugin=function(a,b){f[a]||(f[a]=b)};w=t(u);x=t(u);
17
+ x.locale=function(a){a="function"===typeof a?a:x.locale[a];if(!a)return m;m=a(u);var b=e[m]||{},d=t(n,b.res,!0);a=t(q,b.formatter,!0,d);b=t(r,b.parser,!0,d);x._formatter=w._formatter=a;x._parser=w._parser=b;for(var c in f)x.extend(f[c]);return m};x.extend=function(a){var b=t(x._parser.res,a.res),d=a.extender||{};x._formatter=t(x._formatter,a.formatter,!1,b);x._parser=t(x._parser,a.parser,!1,b);for(var c in d)x[c]||(x[c]=d[c])};
18
18
  x.plugin=function(a){(a="function"===typeof a?a:x.plugin[a])&&x.extend(f[a(u,w)]||{})};export default x