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.
- package/PLUGINS.md +22 -22
- package/README.md +81 -80
- package/date-and-time.d.ts +304 -0
- package/date-and-time.js +73 -72
- package/esm/date-and-time.es.js +73 -72
- package/esm/date-and-time.mjs +73 -72
- package/esm/plugin/timezone.es.js +1 -1
- package/esm/plugin/timezone.mjs +1 -1
- package/locale/ar.d.ts +1 -0
- package/locale/az.d.ts +1 -0
- package/locale/bn.d.ts +1 -0
- package/locale/cs.d.ts +1 -0
- package/locale/de.d.ts +1 -0
- package/locale/dk.d.ts +1 -0
- package/locale/el.d.ts +1 -0
- package/locale/en.d.ts +1 -0
- package/locale/es.d.ts +1 -0
- package/locale/fa.d.ts +1 -0
- package/locale/fr.d.ts +1 -0
- package/locale/hi.d.ts +1 -0
- package/locale/hu.d.ts +1 -0
- package/locale/id.d.ts +1 -0
- package/locale/it.d.ts +1 -0
- package/locale/ja.d.ts +1 -0
- package/locale/jv.d.ts +1 -0
- package/locale/ko.d.ts +1 -0
- package/locale/my.d.ts +1 -0
- package/locale/nl.d.ts +1 -0
- package/locale/pa-in.d.ts +1 -0
- package/locale/pl.d.ts +1 -0
- package/locale/pt.d.ts +1 -0
- package/locale/ro.d.ts +1 -0
- package/locale/ru.d.ts +1 -0
- package/locale/rw.d.ts +1 -0
- package/locale/sr.d.ts +1 -0
- package/locale/sv.d.ts +1 -0
- package/locale/th.d.ts +1 -0
- package/locale/tr.d.ts +1 -0
- package/locale/uk.d.ts +1 -0
- package/locale/uz.d.ts +1 -0
- package/locale/vi.d.ts +1 -0
- package/locale/zh-cn.d.ts +1 -0
- package/locale/zh-tw.d.ts +1 -0
- package/package.json +6 -3
- package/plugin/day-of-week.d.ts +1 -0
- package/plugin/meridiem.d.ts +1 -0
- package/plugin/microsecond.d.ts +1 -0
- package/plugin/ordinal.d.ts +1 -0
- package/plugin/timespan.d.ts +24 -0
- package/plugin/timezone.d.ts +79 -0
- package/plugin/timezone.js +1 -1
- package/plugin/two-digit-year.d.ts +1 -0
package/esm/date-and-time.es.js
CHANGED
|
@@ -140,9 +140,9 @@ var locales = {},
|
|
|
140
140
|
date;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* Compiling
|
|
144
|
-
* @param {string} formatString -
|
|
145
|
-
* @returns {Array.<string>}
|
|
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
|
|
158
|
-
* @param {Date} dateObj -
|
|
159
|
-
* @param {string|Array.<string>} arg -
|
|
160
|
-
* @param {boolean} [utc] -
|
|
161
|
-
* @returns {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
|
|
179
|
-
* @param {string} dateString -
|
|
180
|
-
* @param {string|Array.<string>} arg -
|
|
181
|
-
* @
|
|
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
|
|
218
|
-
* @param {string} dateString -
|
|
219
|
-
* @param {string|Array.<string>} arg -
|
|
220
|
-
* @param {boolean} [utc] -
|
|
221
|
-
* @returns {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
|
-
*
|
|
239
|
-
* @param {Object|string} arg1 -
|
|
240
|
-
* @param {string|Array.<string>} [arg2] -
|
|
241
|
-
* @returns {boolean}
|
|
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
|
-
*
|
|
257
|
-
* @param {string} dateString -
|
|
258
|
-
* @param {string|Array.<string>} arg1 -
|
|
259
|
-
* @param {string|Array.<string>} arg2 -
|
|
260
|
-
* @param {boolean} [utc] -
|
|
261
|
-
* @returns {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 -
|
|
271
|
-
* @param {number} years -
|
|
272
|
-
* @returns {Date}
|
|
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 -
|
|
281
|
-
* @param {number} months -
|
|
282
|
-
* @returns {Date}
|
|
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 -
|
|
294
|
-
* @param {number} days -
|
|
295
|
-
* @returns {Date}
|
|
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 -
|
|
307
|
-
* @param {number} hours -
|
|
308
|
-
* @returns {Date}
|
|
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 -
|
|
317
|
-
* @param {number} minutes -
|
|
318
|
-
* @returns {Date}
|
|
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 -
|
|
327
|
-
* @param {number} seconds -
|
|
328
|
-
* @returns {Date}
|
|
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 -
|
|
337
|
-
* @param {number} milliseconds -
|
|
338
|
-
* @returns {Date}
|
|
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 -
|
|
347
|
-
* @param {Date} date2 -
|
|
348
|
-
* @returns {Object}
|
|
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}
|
|
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 -
|
|
384
|
-
* @param {Date} date2 -
|
|
385
|
-
* @returns {boolean}
|
|
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
|
-
*
|
|
393
|
-
* @param {string} code - language code
|
|
394
|
-
* @param {Function} locale - locale installer
|
|
395
|
-
* @returns {
|
|
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
|
-
*
|
|
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
|
|
420
|
-
* @param {Function|string} [locale] - locale
|
|
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
|
-
*
|
|
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
|
|
467
|
-
* @param {Function|string} plugin - plugin
|
|
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) {
|
package/esm/date-and-time.mjs
CHANGED
|
@@ -140,9 +140,9 @@ var locales = {},
|
|
|
140
140
|
date;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* Compiling
|
|
144
|
-
* @param {string} formatString -
|
|
145
|
-
* @returns {Array.<string>}
|
|
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
|
|
158
|
-
* @param {Date} dateObj -
|
|
159
|
-
* @param {string|Array.<string>} arg -
|
|
160
|
-
* @param {boolean} [utc] -
|
|
161
|
-
* @returns {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
|
|
179
|
-
* @param {string} dateString -
|
|
180
|
-
* @param {string|Array.<string>} arg -
|
|
181
|
-
* @
|
|
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
|
|
218
|
-
* @param {string} dateString -
|
|
219
|
-
* @param {string|Array.<string>} arg -
|
|
220
|
-
* @param {boolean} [utc] -
|
|
221
|
-
* @returns {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
|
-
*
|
|
239
|
-
* @param {Object|string} arg1 -
|
|
240
|
-
* @param {string|Array.<string>} [arg2] -
|
|
241
|
-
* @returns {boolean}
|
|
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
|
-
*
|
|
257
|
-
* @param {string} dateString -
|
|
258
|
-
* @param {string|Array.<string>} arg1 -
|
|
259
|
-
* @param {string|Array.<string>} arg2 -
|
|
260
|
-
* @param {boolean} [utc] -
|
|
261
|
-
* @returns {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 -
|
|
271
|
-
* @param {number} years -
|
|
272
|
-
* @returns {Date}
|
|
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 -
|
|
281
|
-
* @param {number} months -
|
|
282
|
-
* @returns {Date}
|
|
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 -
|
|
294
|
-
* @param {number} days -
|
|
295
|
-
* @returns {Date}
|
|
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 -
|
|
307
|
-
* @param {number} hours -
|
|
308
|
-
* @returns {Date}
|
|
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 -
|
|
317
|
-
* @param {number} minutes -
|
|
318
|
-
* @returns {Date}
|
|
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 -
|
|
327
|
-
* @param {number} seconds -
|
|
328
|
-
* @returns {Date}
|
|
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 -
|
|
337
|
-
* @param {number} milliseconds -
|
|
338
|
-
* @returns {Date}
|
|
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 -
|
|
347
|
-
* @param {Date} date2 -
|
|
348
|
-
* @returns {Object}
|
|
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}
|
|
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 -
|
|
384
|
-
* @param {Date} date2 -
|
|
385
|
-
* @returns {boolean}
|
|
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
|
-
*
|
|
393
|
-
* @param {string} code - language code
|
|
394
|
-
* @param {Function} locale - locale installer
|
|
395
|
-
* @returns {
|
|
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
|
-
*
|
|
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
|
|
420
|
-
* @param {Function|string} [locale] - locale
|
|
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
|
-
*
|
|
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
|
|
467
|
-
* @param {Function|string} plugin - plugin
|
|
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) {
|
package/esm/plugin/timezone.mjs
CHANGED
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;
|