date-and-time 2.2.1 → 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 (52) hide show
  1. package/PLUGINS.md +22 -22
  2. package/README.md +81 -80
  3. package/date-and-time.d.ts +304 -0
  4. package/date-and-time.js +73 -72
  5. package/esm/date-and-time.es.js +73 -72
  6. package/esm/date-and-time.mjs +73 -72
  7. package/esm/plugin/timezone.es.js +1 -1
  8. package/esm/plugin/timezone.mjs +1 -1
  9. package/locale/ar.d.ts +1 -0
  10. package/locale/az.d.ts +1 -0
  11. package/locale/bn.d.ts +1 -0
  12. package/locale/cs.d.ts +1 -0
  13. package/locale/de.d.ts +1 -0
  14. package/locale/dk.d.ts +1 -0
  15. package/locale/el.d.ts +1 -0
  16. package/locale/en.d.ts +1 -0
  17. package/locale/es.d.ts +1 -0
  18. package/locale/fa.d.ts +1 -0
  19. package/locale/fr.d.ts +1 -0
  20. package/locale/hi.d.ts +1 -0
  21. package/locale/hu.d.ts +1 -0
  22. package/locale/id.d.ts +1 -0
  23. package/locale/it.d.ts +1 -0
  24. package/locale/ja.d.ts +1 -0
  25. package/locale/jv.d.ts +1 -0
  26. package/locale/ko.d.ts +1 -0
  27. package/locale/my.d.ts +1 -0
  28. package/locale/nl.d.ts +1 -0
  29. package/locale/pa-in.d.ts +1 -0
  30. package/locale/pl.d.ts +1 -0
  31. package/locale/pt.d.ts +1 -0
  32. package/locale/ro.d.ts +1 -0
  33. package/locale/ru.d.ts +1 -0
  34. package/locale/rw.d.ts +1 -0
  35. package/locale/sr.d.ts +1 -0
  36. package/locale/sv.d.ts +1 -0
  37. package/locale/th.d.ts +1 -0
  38. package/locale/tr.d.ts +1 -0
  39. package/locale/uk.d.ts +1 -0
  40. package/locale/uz.d.ts +1 -0
  41. package/locale/vi.d.ts +1 -0
  42. package/locale/zh-cn.d.ts +1 -0
  43. package/locale/zh-tw.d.ts +1 -0
  44. package/package.json +6 -3
  45. package/plugin/day-of-week.d.ts +1 -0
  46. package/plugin/meridiem.d.ts +1 -0
  47. package/plugin/microsecond.d.ts +1 -0
  48. package/plugin/ordinal.d.ts +1 -0
  49. package/plugin/timespan.d.ts +24 -0
  50. package/plugin/timezone.d.ts +79 -0
  51. package/plugin/timezone.js +1 -1
  52. package/plugin/two-digit-year.d.ts +1 -0
@@ -140,9 +140,9 @@ var locales = {},
140
140
  date;
141
141
 
142
142
  /**
143
- * Compiling a format string
144
- * @param {string} formatString - a format string
145
- * @returns {Array.<string>} a compiled object
143
+ * Compiling format strings
144
+ * @param {string} formatString - A format string
145
+ * @returns {Array.<string>} A compiled object
146
146
  */
147
147
  proto.compile = function (formatString) {
148
148
  var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
@@ -154,11 +154,11 @@ proto.compile = function (formatString) {
154
154
  };
155
155
 
156
156
  /**
157
- * Formatting a Date and Time
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
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
162
162
  */
163
163
  proto.format = function (dateObj, arg, utc) {
164
164
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -175,10 +175,11 @@ proto.format = function (dateObj, arg, utc) {
175
175
  };
176
176
 
177
177
  /**
178
- * Pre-parsing a Date and Time string
179
- * @param {string} dateString - a date string
180
- * @param {string|Array.<string>} arg - a format string or its compiled object
181
- * @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
182
183
  */
183
184
  proto.preparse = function (dateString, arg) {
184
185
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -214,11 +215,11 @@ proto.preparse = function (dateString, arg) {
214
215
  };
215
216
 
216
217
  /**
217
- * Parsing a Date and Time string
218
- * @param {string} dateString - a date string
219
- * @param {string|Array.<string>} arg - a format string or its compiled object
220
- * @param {boolean} [utc] - input as UTC
221
- * @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
222
223
  */
223
224
  proto.parse = function (dateString, arg, utc) {
224
225
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -235,10 +236,10 @@ proto.parse = function (dateString, arg, utc) {
235
236
  };
236
237
 
237
238
  /**
238
- * Validation
239
- * @param {Object|string} arg1 - a date structure or a date string
240
- * @param {string|Array.<string>} [arg2] - a format string or its compiled object
241
- * @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
242
243
  */
243
244
  proto.isValid = function (arg1, arg2) {
244
245
  var ctx = this || date, dt = typeof arg1 === 'string' ? ctx.preparse(arg1, arg2) : arg1,
@@ -253,12 +254,12 @@ proto.isValid = function (arg1, arg2) {
253
254
  };
254
255
 
255
256
  /**
256
- * Transforming a Date and Time string
257
- * @param {string} dateString - a date string
258
- * @param {string|Array.<string>} arg1 - a format string or its compiled object
259
- * @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
260
- * @param {boolean} [utc] - output as UTC
261
- * @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
262
263
  */
263
264
  proto.transform = function (dateString, arg1, arg2, utc) {
264
265
  const ctx = this || date;
@@ -267,9 +268,9 @@ proto.transform = function (dateString, arg1, arg2, utc) {
267
268
 
268
269
  /**
269
270
  * Adding years
270
- * @param {Date} dateObj - a date object
271
- * @param {number} years - number of years to add
272
- * @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
273
274
  */
274
275
  proto.addYears = function (dateObj, years) {
275
276
  return (this || date).addMonths(dateObj, years * 12);
@@ -277,9 +278,9 @@ proto.addYears = function (dateObj, years) {
277
278
 
278
279
  /**
279
280
  * Adding months
280
- * @param {Date} dateObj - a date object
281
- * @param {number} months - number of months to add
282
- * @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
283
284
  */
284
285
  proto.addMonths = function (dateObj, months) {
285
286
  var d = new Date(dateObj.getTime());
@@ -290,9 +291,9 @@ proto.addMonths = function (dateObj, months) {
290
291
 
291
292
  /**
292
293
  * Adding days
293
- * @param {Date} dateObj - a date object
294
- * @param {number} days - number of days to add
295
- * @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
296
297
  */
297
298
  proto.addDays = function (dateObj, days) {
298
299
  var d = new Date(dateObj.getTime());
@@ -303,9 +304,9 @@ proto.addDays = function (dateObj, days) {
303
304
 
304
305
  /**
305
306
  * Adding hours
306
- * @param {Date} dateObj - a date object
307
- * @param {number} hours - number of hours to add
308
- * @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
309
310
  */
310
311
  proto.addHours = function (dateObj, hours) {
311
312
  return (this || date).addMinutes(dateObj, hours * 60);
@@ -313,9 +314,9 @@ proto.addHours = function (dateObj, hours) {
313
314
 
314
315
  /**
315
316
  * Adding minutes
316
- * @param {Date} dateObj - a date object
317
- * @param {number} minutes - number of minutes to add
318
- * @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
319
320
  */
320
321
  proto.addMinutes = function (dateObj, minutes) {
321
322
  return (this || date).addSeconds(dateObj, minutes * 60);
@@ -323,9 +324,9 @@ proto.addMinutes = function (dateObj, minutes) {
323
324
 
324
325
  /**
325
326
  * Adding seconds
326
- * @param {Date} dateObj - a date object
327
- * @param {number} seconds - number of seconds to add
328
- * @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
329
330
  */
330
331
  proto.addSeconds = function (dateObj, seconds) {
331
332
  return (this || date).addMilliseconds(dateObj, seconds * 1000);
@@ -333,19 +334,19 @@ proto.addSeconds = function (dateObj, seconds) {
333
334
 
334
335
  /**
335
336
  * Adding milliseconds
336
- * @param {Date} dateObj - a date object
337
- * @param {number} milliseconds - number of milliseconds to add
338
- * @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
339
340
  */
340
341
  proto.addMilliseconds = function (dateObj, milliseconds) {
341
342
  return new Date(dateObj.getTime() + milliseconds);
342
343
  };
343
344
 
344
345
  /**
345
- * Subtracting two dates
346
- * @param {Date} date1 - a Date object
347
- * @param {Date} date2 - a Date object
348
- * @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
349
350
  */
350
351
  proto.subtract = function (date1, date2) {
351
352
  var delta = date1.getTime() - date2.getTime();
@@ -370,9 +371,9 @@ proto.subtract = function (date1, date2) {
370
371
  };
371
372
 
372
373
  /**
373
- * Whether year is leap year
374
- * @param {number} y - year
375
- * @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
376
377
  */
377
378
  proto.isLeapYear = function (y) {
378
379
  return (!(y % 4) && !!(y % 100)) || !(y % 400);
@@ -380,19 +381,19 @@ proto.isLeapYear = function (y) {
380
381
 
381
382
  /**
382
383
  * Comparison of two dates
383
- * @param {Date} date1 - a Date object
384
- * @param {Date} date2 - a Date object
385
- * @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)
386
387
  */
387
388
  proto.isSameDay = function (date1, date2) {
388
389
  return date1.toDateString() === date2.toDateString();
389
390
  };
390
391
 
391
392
  /**
392
- * Defining new locale
393
- * @param {string} code - language code
394
- * @param {Function} locale - locale installer
395
- * @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}
396
397
  */
397
398
  proto.locale = function (code, locale) {
398
399
  if (!locales[code]) {
@@ -401,9 +402,9 @@ proto.locale = function (code, locale) {
401
402
  };
402
403
 
403
404
  /**
404
- * Defining new plugin
405
- * @param {string} name - plugin name
406
- * @param {Function} plugin - plugin installer
405
+ * Definition of new plugin
406
+ * @param {string} name - A plugin name
407
+ * @param {Function} plugin - A plugin installer
407
408
  * @returns {void}
408
409
  */
409
410
  proto.plugin = function (name, plugin) {
@@ -416,9 +417,9 @@ localized_proto = extend(proto);
416
417
  date = extend(proto);
417
418
 
418
419
  /**
419
- * Changing locale
420
- * @param {Function|string} [locale] - locale object | language code
421
- * @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
422
423
  */
423
424
  date.locale = function (locale) {
424
425
  var install = typeof locale === 'function' ? locale : date.locale[locale];
@@ -444,8 +445,8 @@ date.locale = function (locale) {
444
445
  };
445
446
 
446
447
  /**
447
- * Feature extension
448
- * @param {Object} extension - extension object
448
+ * Functional extension
449
+ * @param {Object} extension - An extension object
449
450
  * @returns {void}
450
451
  */
451
452
  date.extend = function (extension) {
@@ -463,8 +464,8 @@ date.extend = function (extension) {
463
464
  };
464
465
 
465
466
  /**
466
- * Importing plugin
467
- * @param {Function|string} plugin - plugin object | plugin name
467
+ * Importing plugins
468
+ * @param {Function|string} plugin - A plugin installer or plugin name
468
469
  * @returns {void}
469
470
  */
470
471
  date.plugin = function (plugin) {
@@ -140,9 +140,9 @@ var locales = {},
140
140
  date;
141
141
 
142
142
  /**
143
- * Compiling a format string
144
- * @param {string} formatString - a format string
145
- * @returns {Array.<string>} a compiled object
143
+ * Compiling format strings
144
+ * @param {string} formatString - A format string
145
+ * @returns {Array.<string>} A compiled object
146
146
  */
147
147
  proto.compile = function (formatString) {
148
148
  var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
@@ -154,11 +154,11 @@ proto.compile = function (formatString) {
154
154
  };
155
155
 
156
156
  /**
157
- * Formatting a Date and Time
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
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
162
162
  */
163
163
  proto.format = function (dateObj, arg, utc) {
164
164
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -175,10 +175,11 @@ proto.format = function (dateObj, arg, utc) {
175
175
  };
176
176
 
177
177
  /**
178
- * Pre-parsing a Date and Time string
179
- * @param {string} dateString - a date string
180
- * @param {string|Array.<string>} arg - a format string or its compiled object
181
- * @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
182
183
  */
183
184
  proto.preparse = function (dateString, arg) {
184
185
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -214,11 +215,11 @@ proto.preparse = function (dateString, arg) {
214
215
  };
215
216
 
216
217
  /**
217
- * Parsing a Date and Time string
218
- * @param {string} dateString - a date string
219
- * @param {string|Array.<string>} arg - a format string or its compiled object
220
- * @param {boolean} [utc] - input as UTC
221
- * @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
222
223
  */
223
224
  proto.parse = function (dateString, arg, utc) {
224
225
  var ctx = this || date, pattern = typeof arg === 'string' ? ctx.compile(arg) : arg,
@@ -235,10 +236,10 @@ proto.parse = function (dateString, arg, utc) {
235
236
  };
236
237
 
237
238
  /**
238
- * Validation
239
- * @param {Object|string} arg1 - a date structure or a date string
240
- * @param {string|Array.<string>} [arg2] - a format string or its compiled object
241
- * @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
242
243
  */
243
244
  proto.isValid = function (arg1, arg2) {
244
245
  var ctx = this || date, dt = typeof arg1 === 'string' ? ctx.preparse(arg1, arg2) : arg1,
@@ -253,12 +254,12 @@ proto.isValid = function (arg1, arg2) {
253
254
  };
254
255
 
255
256
  /**
256
- * Transforming a Date and Time string
257
- * @param {string} dateString - a date string
258
- * @param {string|Array.<string>} arg1 - a format string or its compiled object
259
- * @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
260
- * @param {boolean} [utc] - output as UTC
261
- * @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
262
263
  */
263
264
  proto.transform = function (dateString, arg1, arg2, utc) {
264
265
  const ctx = this || date;
@@ -267,9 +268,9 @@ proto.transform = function (dateString, arg1, arg2, utc) {
267
268
 
268
269
  /**
269
270
  * Adding years
270
- * @param {Date} dateObj - a date object
271
- * @param {number} years - number of years to add
272
- * @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
273
274
  */
274
275
  proto.addYears = function (dateObj, years) {
275
276
  return (this || date).addMonths(dateObj, years * 12);
@@ -277,9 +278,9 @@ proto.addYears = function (dateObj, years) {
277
278
 
278
279
  /**
279
280
  * Adding months
280
- * @param {Date} dateObj - a date object
281
- * @param {number} months - number of months to add
282
- * @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
283
284
  */
284
285
  proto.addMonths = function (dateObj, months) {
285
286
  var d = new Date(dateObj.getTime());
@@ -290,9 +291,9 @@ proto.addMonths = function (dateObj, months) {
290
291
 
291
292
  /**
292
293
  * Adding days
293
- * @param {Date} dateObj - a date object
294
- * @param {number} days - number of days to add
295
- * @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
296
297
  */
297
298
  proto.addDays = function (dateObj, days) {
298
299
  var d = new Date(dateObj.getTime());
@@ -303,9 +304,9 @@ proto.addDays = function (dateObj, days) {
303
304
 
304
305
  /**
305
306
  * Adding hours
306
- * @param {Date} dateObj - a date object
307
- * @param {number} hours - number of hours to add
308
- * @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
309
310
  */
310
311
  proto.addHours = function (dateObj, hours) {
311
312
  return (this || date).addMinutes(dateObj, hours * 60);
@@ -313,9 +314,9 @@ proto.addHours = function (dateObj, hours) {
313
314
 
314
315
  /**
315
316
  * Adding minutes
316
- * @param {Date} dateObj - a date object
317
- * @param {number} minutes - number of minutes to add
318
- * @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
319
320
  */
320
321
  proto.addMinutes = function (dateObj, minutes) {
321
322
  return (this || date).addSeconds(dateObj, minutes * 60);
@@ -323,9 +324,9 @@ proto.addMinutes = function (dateObj, minutes) {
323
324
 
324
325
  /**
325
326
  * Adding seconds
326
- * @param {Date} dateObj - a date object
327
- * @param {number} seconds - number of seconds to add
328
- * @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
329
330
  */
330
331
  proto.addSeconds = function (dateObj, seconds) {
331
332
  return (this || date).addMilliseconds(dateObj, seconds * 1000);
@@ -333,19 +334,19 @@ proto.addSeconds = function (dateObj, seconds) {
333
334
 
334
335
  /**
335
336
  * Adding milliseconds
336
- * @param {Date} dateObj - a date object
337
- * @param {number} milliseconds - number of milliseconds to add
338
- * @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
339
340
  */
340
341
  proto.addMilliseconds = function (dateObj, milliseconds) {
341
342
  return new Date(dateObj.getTime() + milliseconds);
342
343
  };
343
344
 
344
345
  /**
345
- * Subtracting two dates
346
- * @param {Date} date1 - a Date object
347
- * @param {Date} date2 - a Date object
348
- * @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
349
350
  */
350
351
  proto.subtract = function (date1, date2) {
351
352
  var delta = date1.getTime() - date2.getTime();
@@ -370,9 +371,9 @@ proto.subtract = function (date1, date2) {
370
371
  };
371
372
 
372
373
  /**
373
- * Whether year is leap year
374
- * @param {number} y - year
375
- * @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
376
377
  */
377
378
  proto.isLeapYear = function (y) {
378
379
  return (!(y % 4) && !!(y % 100)) || !(y % 400);
@@ -380,19 +381,19 @@ proto.isLeapYear = function (y) {
380
381
 
381
382
  /**
382
383
  * Comparison of two dates
383
- * @param {Date} date1 - a Date object
384
- * @param {Date} date2 - a Date object
385
- * @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)
386
387
  */
387
388
  proto.isSameDay = function (date1, date2) {
388
389
  return date1.toDateString() === date2.toDateString();
389
390
  };
390
391
 
391
392
  /**
392
- * Defining new locale
393
- * @param {string} code - language code
394
- * @param {Function} locale - locale installer
395
- * @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}
396
397
  */
397
398
  proto.locale = function (code, locale) {
398
399
  if (!locales[code]) {
@@ -401,9 +402,9 @@ proto.locale = function (code, locale) {
401
402
  };
402
403
 
403
404
  /**
404
- * Defining new plugin
405
- * @param {string} name - plugin name
406
- * @param {Function} plugin - plugin installer
405
+ * Definition of new plugin
406
+ * @param {string} name - A plugin name
407
+ * @param {Function} plugin - A plugin installer
407
408
  * @returns {void}
408
409
  */
409
410
  proto.plugin = function (name, plugin) {
@@ -416,9 +417,9 @@ localized_proto = extend(proto);
416
417
  date = extend(proto);
417
418
 
418
419
  /**
419
- * Changing locale
420
- * @param {Function|string} [locale] - locale object | language code
421
- * @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
422
423
  */
423
424
  date.locale = function (locale) {
424
425
  var install = typeof locale === 'function' ? locale : date.locale[locale];
@@ -444,8 +445,8 @@ date.locale = function (locale) {
444
445
  };
445
446
 
446
447
  /**
447
- * Feature extension
448
- * @param {Object} extension - extension object
448
+ * Functional extension
449
+ * @param {Object} extension - An extension object
449
450
  * @returns {void}
450
451
  */
451
452
  date.extend = function (extension) {
@@ -463,8 +464,8 @@ date.extend = function (extension) {
463
464
  };
464
465
 
465
466
  /**
466
- * Importing plugin
467
- * @param {Function|string} plugin - plugin object | plugin name
467
+ * Importing plugins
468
+ * @param {Function|string} plugin - A plugin installer or plugin name
468
469
  * @returns {void}
469
470
  */
470
471
  date.plugin = function (plugin) {
@@ -54,7 +54,7 @@ var plugin = function (date, localized_date) {
54
54
  return d;
55
55
  }
56
56
  }
57
- return NaN;
57
+ return new Date(NaN);
58
58
  };
59
59
  var transformTZ = function (dateString, arg1, arg2, timeZone) {
60
60
  return formatTZ(localized_date.parse(dateString, arg1), arg2, timeZone);
@@ -54,7 +54,7 @@ var plugin = function (date, localized_date) {
54
54
  return d;
55
55
  }
56
56
  }
57
- return NaN;
57
+ return new Date(NaN);
58
58
  };
59
59
  var transformTZ = function (dateString, arg1, arg2, timeZone) {
60
60
  return formatTZ(localized_date.parse(dateString, arg1), arg2, timeZone);
package/locale/ar.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/az.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/bn.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/cs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/de.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/dk.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/el.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/en.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/es.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/fa.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/fr.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/hi.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/hu.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/id.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/it.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/ja.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/jv.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/ko.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/my.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
package/locale/nl.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;
@@ -0,0 +1 @@
1
+ export default function (date: unknown): string;