date-and-time 4.0.2 → 4.0.3

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
@@ -46,1278 +46,15 @@ Version `4.x` has been completely rewritten in TypeScript and some features from
46
46
  - Tree shaking is now supported
47
47
  - Supports `ES2021` and no longer supports older browsers
48
48
 
49
- For details, please refer to [MIGRATION.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/MIGRATION.md).
49
+ For details, please refer to [migration.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/migration.md).
50
50
 
51
51
  ## API
52
52
 
53
- ### format(dateObj, arg[, options])
53
+ For comprehensive documentation and examples, visit: **[GitHub Pages](https://knowledgecode.github.io/date-and-time/)**
54
54
 
55
- <details>
56
- <summary>Formats a Date object according to the specified format string.</summary>
55
+ ## License
57
56
 
58
- - dateObj
59
- - type: `Date`
60
- - The Date object to format
61
- - arg
62
- - type: `string | CompiledObject`
63
- - The format string or compiled object to match against the Date object
64
- - [options]
65
- - type: `FormatterOptions`
66
- - Optional formatter options for customization
67
-
68
- ```typescript
69
- import { format } from 'date-and-time';
70
- import Tokyo from 'date-and-time/timezones/Asia/Tokyo';
71
- import ja from 'date-and-time/locales/ja';
72
-
73
- const now = new Date();
74
-
75
- format(now, 'YYYY/MM/DD HH:mm:ss');
76
- // => 2015/01/01 23:14:05
77
-
78
- format(now, 'ddd, MMM DD YYYY');
79
- // => Thu, Jan 01 2015
80
-
81
- format(now, 'ddd, MMM DD YYYY hh:mm A [GMT]Z', { timeZone: 'UTC' });
82
- // => Fri, Jan 02 2015 07:14 AM GMT+0000
83
-
84
- format(now, 'YYYY年MMMM月D日dddd Ah:mm:ss [GMT]Z', { timeZone: Tokyo, locale: ja });
85
- // => 2015年1月2日金曜日 午後4:14:05 GMT+0900
86
- ```
87
-
88
- The tokens available for use in the format string specified as the second argument and their meanings are as follows:
89
-
90
- | Token | Meaning | Output Examples |
91
- |:---------|:--------------------------------------------|:----------------------|
92
- | YYYY | 4-digit year | 0999, 2015 |
93
- | YY | 2-digit year | 99, 01, 15 |
94
- | Y | Year without zero padding | 2, 44, 888, 2015 |
95
- | MMMM | Full month name | January, December |
96
- | MMM | Short month name | Jan, Dec |
97
- | MM | Month | 01, 12 |
98
- | M | Month without zero padding | 1, 12 |
99
- | DD | Day | 02, 31 |
100
- | D | Day without zero padding | 2, 31 |
101
- | dddd | Full day name | Friday, Sunday |
102
- | ddd | Short day name | Fri, Sun |
103
- | dd | Very short day name | Fr, Su |
104
- | HH | Hour in 24-hour format | 23, 08 |
105
- | H | Hour in 24-hour format without zero padding | 23, 8 |
106
- | hh | Hour in 12-hour format | 11, 08 |
107
- | h | Hour in 12-hour format without zero padding | 11, 8 |
108
- | A | Uppercase AM/PM | AM, PM |
109
- | AA | Uppercase AM/PM (with periods) | A.M., P.M. |
110
- | a | Lowercase AM/PM | am, pm |
111
- | aa | Lowercase AM/PM (with periods) | a.m., p.m. |
112
- | mm | Minutes | 14, 07 |
113
- | m | Minutes without zero padding | 14, 7 |
114
- | ss | Seconds | 05, 10 |
115
- | s | Seconds without zero padding | 5, 10 |
116
- | SSS | 3-digit milliseconds | 753, 022 |
117
- | SS | 2-digit milliseconds | 75, 02 |
118
- | S | 1-digit milliseconds | 7, 0 |
119
- | Z | Timezone offset | +0100, -0800 |
120
- | ZZ | Timezone offset with colon | +01:00, -08:00 |
121
-
122
- Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/PLUGINS.md).
123
-
124
- | Token | Meaning | Output Examples |
125
- |:---------|:--------------------------------------------|:----------------------|
126
- | DDD | Ordinal representation of day | 1st, 2nd, 3rd |
127
- | z | Short timezone name | PST, EST |
128
- | zz | Long timezone name | Pacific Standard Time |
129
-
130
- The breakdown of `FormatterOptions` that can be specified as the third argument is as follows:
131
-
132
- <details>
133
- <summary><strong>hour12</strong></summary>
134
-
135
- - type: `h11 | h12`
136
- - default: `h12`
137
- - The hour format to use for formatting. This is used when the hour is in 12-hour format. It can be `h11` for 11-hour format or `h12` for 12-hour format.
138
-
139
- ```typescript
140
- format(now, 'dddd, MMMM D, YYYY [at] h:mm:ss.SSS A [GMT]ZZ', { hour12: 'h11' });
141
- // Wednesday, July 23, 2025 at 0:12:54.814 AM GMT-07:00
142
- ```
143
-
144
- </details>
145
-
146
- <details>
147
- <summary><strong>hour24</strong></summary>
148
-
149
- - type: `h23 | h24`
150
- - default: `h23`
151
- - The hour format to use for formatting. This is used when the hour is in 24-hour format. It can be `h23` for 23-hour format or `h24` for 24-hour format.
152
-
153
- ```typescript
154
- format(now, 'dddd, MMMM D, YYYY [at] H:mm:ss.SSS [GMT]ZZ', { hour24: 'h24' });
155
- // => Wednesday, July 23, 2025 at 24:12:54.814 GMT-07:00
156
- ```
157
-
158
- </details>
159
-
160
- <details>
161
- <summary><strong>numeral</strong></summary>
162
-
163
- - type: `Numeral`
164
- - default: `latn`
165
- - The numeral system to use for formatting numbers. This is an object that provides methods to encode and decode numbers in the specified numeral system.
166
-
167
- ```typescript
168
- import arab from 'date-and-time/numerals/arab';
169
-
170
- format(now, 'DD/MM/YYYY', { numeral: arab });
171
- // => ٠٨/٠٧/٢٠٢٥
172
- ```
173
-
174
- Currently, the following numeral systems are supported:
175
-
176
- - `arab`
177
- - `arabext`
178
- - `beng`
179
- - `latn`
180
- - `mymr`
181
-
182
- </details>
183
-
184
- <details>
185
- <summary><strong>calendar</strong></summary>
186
-
187
- - type: `buddhist | gregory`
188
- - default: `gregory`
189
- - The calendar system to use for formatting dates. This can be `buddhist` for Buddhist calendar or `gregory` for Gregorian calendar.
190
-
191
- ```typescript
192
- format(now, 'dddd, MMMM D, YYYY', { calendar: 'buddhist' });
193
- // => Wednesday, July 23, 2568
194
- ```
195
-
196
- </details>
197
-
198
- <details>
199
- <summary><strong>timeZone</strong></summary>
200
-
201
- - type: `TimeZone | UTC`
202
- - default: `undefined`
203
- - The time zone to use for formatting dates and times. This can be a specific time zone object or `UTC` to use Coordinated Universal Time. If not specified, it defaults to undefined, which means the local time zone will be used.
204
-
205
- ```typescript
206
- import New_York from 'date-and-time/timezones/America/New_York';
207
-
208
- format(now, 'dddd, MMMM D, YYYY [at] H:mm:ss.SSS [GMT]ZZ', { timeZone: New_York });
209
- // => Wednesday, July 23, 2025 at 3:28:27.443 GMT-04:00
210
- ```
211
-
212
- </details>
213
-
214
- <details>
215
- <summary><strong>locale</strong></summary>
216
-
217
- - type: `Locale`
218
- - default: `en`
219
- - The locale to use for formatting dates and times. This is an object that provides methods to get localized month names, day names, and meridiems.
220
-
221
- ```typescript
222
- import es from 'date-and-time/locales/es';
223
-
224
- format(now, 'dddd, D [de] MMMM [de] YYYY, h:mm:ss.SSS aa [GMT]ZZ', { locale: es });
225
- // => miércoles, 23 de julio de 2025, 12:38:08,533 a.m. GMT-07:00
226
- ```
227
-
228
- <details>
229
- <summary>Currently, the following locales are supported:</summary>
230
-
231
- - `ar` (Arabic)
232
- - `az` (Azerbaijani)
233
- - `bn` (Bengali)
234
- - `cs` (Czech)
235
- - `da` (Danish)
236
- - `de` (German)
237
- - `el` (Greek)
238
- - `en` (English)
239
- - `es` (Spanish)
240
- - `fa` (Persian)
241
- - `fi` (Finnish)
242
- - `fr` (French)
243
- - `he` (Hebrew)
244
- - `hi` (Hindi)
245
- - `hu` (Hungarian)
246
- - `id` (Indonesian)
247
- - `it` (Italian)
248
- - `ja` (Japanese)
249
- - `ko` (Korean)
250
- - `ms` (Malay)
251
- - `my` (Burmese)
252
- - `nl` (Dutch)
253
- - `no` (Norwegian)
254
- - `pl` (Polish)
255
- - `pt-BR` (Brazilian Portuguese)
256
- - `pt-PT` (European Portuguese)
257
- - `ro` (Romanian)
258
- - `ru` (Russian)
259
- - `rw` (Kinyarwanda)
260
- - `sr-Cyrl` (Serbian Cyrillic)
261
- - `sr-Latn` (Serbian Latin)
262
- - `sv` (Swedish)
263
- - `ta` (Tamil)
264
- - `th` (Thai)
265
- - `tr` (Turkish)
266
- - `uk` (Ukrainian)
267
- - `uz-Cyrl` (Uzbek Cyrillic)
268
- - `uz-Latn` (Uzbek Latin)
269
- - `vi` (Vietnamese)
270
- - `zh-Hans` (Simplified Chinese)
271
- - `zh-Hant` (Traditional Chinese)
272
-
273
- </details>
274
- </details>
275
-
276
- #### Notes
277
-
278
- <details open>
279
- <summary><strong>Comments</strong></summary>
280
-
281
- Parts of the format string enclosed in brackets are output as-is, regardless of whether they are valid tokens.
282
-
283
- ```typescript
284
- format(new Date(), 'DD-[MM]-YYYY'); // => '02-MM-2015'
285
- format(new Date(), '[DD-[MM]-YYYY]'); // => 'DD-[MM]-YYYY'
286
- ```
287
-
288
- </details>
289
-
290
- <details open>
291
- <summary><strong>Output as UTC timezone</strong></summary>
292
-
293
- To output date and time as UTC timezone, specify the string `UTC` in the `timeZone` property of `FormatterOptions`.
294
-
295
- ```typescript
296
- format(new Date(), 'hh:mm A [GMT]Z');
297
- // => '12:14 PM GMT-0700'
298
-
299
- format(new Date(), 'hh:mm A [GMT]Z', { timeZone: 'UTC' });
300
- // => '07:14 AM GMT+0000'
301
- ```
302
-
303
- </details>
304
- </details>
305
-
306
- ### parse(dateString, arg[, options])
307
-
308
- <details>
309
- <summary>Parses a date string according to the specified format.</summary>
310
-
311
- - dateString
312
- - type: `string`
313
- - The date string to parse
314
- - arg
315
- - type: `string | CompiledObject`
316
- - The format string or compiled object to match against the date string
317
- - [options]
318
- - type: `ParserOptions`
319
- - Optional parser options for customization
320
-
321
- ```typescript
322
- import { parse } from 'date-and-time';
323
- import Paris from 'date-and-time/timezones/Europe/Paris';
324
- import fr from 'date-and-time/locales/fr';
325
-
326
- parse('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss');
327
- // => Jan 02 2015 23:14:05 GMT-0800
328
-
329
- parse('02-01-2015', 'DD-MM-YYYY');
330
- // => Jan 02 2015 00:00:00 GMT-0800
331
-
332
- parse('11:14:05 PM', 'h:mm:ss A', { timeZone: 'UTC' });
333
- // => Jan 02 1970 23:14:05 GMT+0000
334
-
335
- parse(
336
- '02 janv. 2015, 11:14:05 PM', 'DD MMM YYYY, h:mm:ss A',
337
- { timeZone: Paris, locale: fr }
338
- );
339
- // => Jan 02 2015 23:14:05 GMT+0100
340
-
341
- parse('Jam 1 2017', 'MMM D YYYY');
342
- // => Invalid Date
343
- ```
344
-
345
- The tokens available for use in the format string specified as the second argument and their meanings are as follows:
346
-
347
- | Token | Meaning | Input Examples |
348
- |:----------|:--------------------------------------------|:--------------------|
349
- | YYYY | 4-digit year | 0999, 2015 |
350
- | Y | Year without zero padding | 2, 44, 88, 2015 |
351
- | MMMM | Full month name | January, December |
352
- | MMM | Short month name | Jan, Dec |
353
- | MM | Month | 01, 12 |
354
- | M | Month without zero padding | 1, 12 |
355
- | DD | Day | 02, 31 |
356
- | D | Day without zero padding | 2, 31 |
357
- | HH | Hour in 24-hour format | 23, 08 |
358
- | H | Hour in 24-hour format without zero padding | 23, 8 |
359
- | hh | Hour in 12-hour format | 11, 08 |
360
- | h | Hour in 12-hour format without zero padding | 11, 8 |
361
- | A | Uppercase AM/PM | AM, PM |
362
- | AA | Uppercase AM/PM (with periods) | A.M., P.M. |
363
- | a | Lowercase AM/PM | am, pm |
364
- | aa | Lowercase AM/PM (with periods) | a.m., p.m. |
365
- | mm | Minutes | 14, 07 |
366
- | m | Minutes without zero padding | 14, 7 |
367
- | ss | Seconds | 05, 10 |
368
- | s | Seconds without zero padding | 5, 10 |
369
- | SSS | 3-digit milliseconds | 753, 022 |
370
- | SS | 2-digit milliseconds | 75, 02 |
371
- | S | 1-digit milliseconds | 7, 0 |
372
- | Z | Timezone offset | +0100, -0800 |
373
- | ZZ | Timezone offset with colon | +01:00, -08:00 |
374
-
375
- Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/PLUGINS.md).
376
-
377
- | Token | Meaning | Input Examples |
378
- |:----------|:-------------------------------------------|:---------------------|
379
- | YY | 2-digit year | 90, 00, 08, 19 |
380
- | DDD | Ordinal representation of day | 1st, 2nd, 3rd |
381
- | dddd | Full day name | Friday, Sunday |
382
- | ddd | Short day name | Fri, Sun |
383
- | dd | Very short day name | Fr, Su |
384
- | SSSSSS | 6-digit milliseconds | 123456, 000001 |
385
- | SSSSS | 5-digit milliseconds | 12345, 00001 |
386
- | SSSS | 4-digit milliseconds | 1234, 0001 |
387
- | fff | 3-digit microseconds | 753, 022 |
388
- | ff | 2-digit microseconds | 75, 02 |
389
- | f | 1-digit microseconds | 7, 0 |
390
- | SSSSSSSSS | 9-digit milliseconds | 123456789, 000000001 |
391
- | SSSSSSSS | 8-digit milliseconds | 12345678, 00000001 |
392
- | SSSSSSS | 7-digit milliseconds | 1234567, 0000001 |
393
- | FFF | 3-digit nanoseconds | 753, 022 |
394
- | FF | 2-digit nanoseconds | 75, 02 |
395
- | F | 1-digit nanoseconds | 7, 0 |
396
-
397
- The breakdown of `ParserOptions` that can be specified as the third argument is as follows:
398
-
399
- <details>
400
- <summary><strong>hour12</strong></summary>
401
-
402
- - type: `h11 | h12`
403
- - default: `h12`
404
- - The hour format to use for parsing. This is used when the hour is in 12-hour format. It can be `h11` for 11-hour format (0 - 11) or `h12` for 12-hour format (1 - 12).
405
-
406
- ```typescript
407
- parse('0:12:54 PM', 'h:mm:ss A', { hour12: 'h11' });
408
- // => Jan 01 1970 12:12:54 GMT-0800
409
- ```
410
-
411
- </details>
412
-
413
- <details>
414
- <summary><strong>hour24</strong></summary>
415
-
416
- - type: `h23 | h24`
417
- - default: `h23`
418
- - The hour format to use for parsing. This is used when the hour is in 24-hour format. It can be `h23` for 23-hour format (0 - 23) or `h24` for 24-hour format (1 - 24).
419
-
420
- ```typescript
421
- parse('24:12:54', 'h:mm:ss', { hour24: 'h24' });
422
- // => Jan 01 1970 00:12:54 GMT-0800
423
- ```
424
-
425
- </details>
426
-
427
- <details>
428
- <summary><strong>numeral</strong></summary>
429
-
430
- - type: `Numeral`
431
- - default: `latn`
432
- - The numeral system to use for parsing numbers. This is an object that provides methods to encode and decode numbers in the specified numeral system.
433
-
434
- ```typescript
435
- import arab from 'date-and-time/numerals/arab';
436
-
437
- parse('٠٨/٠٧/٢٠٢٥', 'DD/MM/YYYY', { numeral: arab });
438
- // => July 09 2025 00:00:00 GMT-0700
439
- ```
440
-
441
- Currently, the following numeral systems are supported:
442
-
443
- - `arab`
444
- - `arabext`
445
- - `beng`
446
- - `latn`
447
- - `mymr`
448
-
449
- </details>
450
-
451
- <details>
452
- <summary><strong>calendar</strong></summary>
453
-
454
- - type: `buddhist | gregory`
455
- - default: `gregory`
456
- - The calendar system to use for parsing dates. This can be `buddhist` for Buddhist calendar or `gregory` for Gregorian calendar.
457
-
458
- ```typescript
459
- parse('July 09 2025', 'MMMM DD YYYY', { calendar: 'buddhist' });
460
- // => July 09 1482 00:00:00 GMT-0752
461
- // Note: Buddhist calendar is 543 years ahead of Gregorian calendar,
462
- // so 2025 BE (Buddhist Era) equals 1482 CE (Common Era)
463
- ```
464
-
465
- </details>
466
-
467
- <details>
468
- <summary><strong>ignoreCase</strong></summary>
469
-
470
- - type: `boolean`
471
- - default: `false`
472
- - Whether to ignore case when matching strings. This is useful for matching month names, day names, and meridiems in a case-insensitive manner. If true, the parser will convert both the input string and the strings in the locale to lowercase before matching.
473
-
474
- ```typescript
475
- parse('july 09 2025', 'MMMM DD YYYY', { ignoreCase: true });
476
- // => July 09 2025 00:00:00 GMT-0700
477
- ```
478
-
479
- </details>
480
-
481
- <details>
482
- <summary><strong>timeZone</strong></summary>
483
-
484
- - type: `TimeZone | UTC`
485
- - default: `undefined`
486
- - The time zone to use for parsing dates and times. This can be a specific time zone object or `UTC` to use Coordinated Universal Time. If not specified, it defaults to undefined, which means the local time zone will be used.
487
-
488
- ```typescript
489
- import New_York from 'date-and-time/timezones/America/New_York';
490
-
491
- parse('July 09 2025, 12:34:56', 'MMMM D YYYY, H:mm:ss', { timeZone: New_York });
492
- // => July 09 2025 09:34:56 GMT-0700 (July 09 2025 12:34:56 GMT-0400)
493
-
494
- parse('July 09 2025, 12:34:56', 'MMMM D YYYY, H:mm:ss', { timeZone: 'UTC' });
495
- // => July 09 2025 05:34:56 GMT-0700 (July 09 2025 12:34:56 GMT+0000)
496
- ```
497
-
498
- </details>
499
-
500
- <details>
501
- <summary><strong>locale</strong></summary>
502
-
503
- - type: `Locale`
504
- - default: `en`
505
- - The locale to use for parsing dates and times. This is an object that provides methods to get localized month names, day names, and meridiems.
506
-
507
- ```typescript
508
- import es from 'date-and-time/locales/es';
509
-
510
- parse(
511
- '23 de julio de 2025, 12:38:08,533 a.m. GMT-07:00',
512
- 'D [de] MMMM [de] YYYY, h:mm:ss,SSS aa [GMT]ZZ',
513
- { locale: es }
514
- );
515
- // => July 23 2025 12:38:08.533 GMT-0700
516
- ```
517
-
518
- <details>
519
- <summary>Currently, the following locales are supported:</summary>
520
-
521
- - `ar` (Arabic)
522
- - `az` (Azerbaijani)
523
- - `bn` (Bengali)
524
- - `cs` (Czech)
525
- - `da` (Danish)
526
- - `de` (German)
527
- - `el` (Greek)
528
- - `en` (English)
529
- - `es` (Spanish)
530
- - `fa` (Persian)
531
- - `fi` (Finnish)
532
- - `fr` (French)
533
- - `he` (Hebrew)
534
- - `hi` (Hindi)
535
- - `hu` (Hungarian)
536
- - `id` (Indonesian)
537
- - `it` (Italian)
538
- - `ja` (Japanese)
539
- - `ko` (Korean)
540
- - `ms` (Malay)
541
- - `my` (Burmese)
542
- - `nl` (Dutch)
543
- - `no` (Norwegian)
544
- - `pl` (Polish)
545
- - `pt-BR` (Brazilian Portuguese)
546
- - `pt-PT` (European Portuguese)
547
- - `ro` (Romanian)
548
- - `ru` (Russian)
549
- - `rw` (Kinyarwanda)
550
- - `sr-Cyrl` (Serbian Cyrillic)
551
- - `sr-Latn` (Serbian Latin)
552
- - `sv` (Swedish)
553
- - `ta` (Tamil)
554
- - `th` (Thai)
555
- - `tr` (Turkish)
556
- - `uk` (Ukrainian)
557
- - `uz-Cyrl` (Uzbek Cyrillic)
558
- - `uz-Latn` (Uzbek Latin)
559
- - `vi` (Vietnamese)
560
- - `zh-Hans` (Simplified Chinese)
561
- - `zh-Hant` (Traditional Chinese)
562
-
563
- </details>
564
- </details>
565
-
566
- #### Notes
567
-
568
- <details open>
569
- <summary><strong>When parsing fails</strong></summary>
570
-
571
- If this function fails to parse, it will return `Invalid Date`. Notice that the `Invalid Date` is a Date object, not `NaN` or `null`. You can tell whether the Date object is invalid as follows:
572
-
573
- ```typescript
574
- const today = parse('Jam 1 2017', 'MMM D YYYY');
575
-
576
- if (isNaN(today.getTime())) {
577
- console.error('Parsing failed');
578
- }
579
- ```
580
-
581
- </details>
582
-
583
- <details open>
584
- <summary><strong>Input as UTC timezone</strong></summary>
585
-
586
- If the `dateString` does not contain a timezone offset and the `timeZone` property of the third argument is not specified, this function considers the `dateString` to be in the local timezone. If you want to process a `dateString` without a timezone offset as UTC timezone, set the string `UTC` to the `timeZone` property in the third argument. Note that the timezone offset contained in the `dateString` takes precedence over the `timeZone` property of the third argument.
587
-
588
- ```typescript
589
- parse('11:14:05 PM', 'hh:mm:ss A');
590
- // => Jan 1 1970 23:14:05 GMT-0800
591
-
592
- parse('11:14:05 PM GMT+0000', 'hh:mm:ss A [GMT]Z');
593
- // => Jan 1 1970 23:14:05 GMT+0000
594
-
595
- parse('11:14:05 PM', 'hh:mm:ss A', { timeZone: 'UTC' });
596
- // => Jan 1 1970 23:14:05 GMT+0000
597
- ```
598
-
599
- </details>
600
-
601
- <details open>
602
- <summary><strong>Default Date Time</strong></summary>
603
-
604
- Default date is `January 1, 1970`, time is `00:00:00.000`. Any date/time components not specified in the input string will be filled with these default values.
605
-
606
- ```typescript
607
- parse('11:14:05 PM', 'hh:mm:ss A');
608
- // => Jan 1 1970 23:14:05 GMT-0800
609
-
610
- parse('Feb 2000', 'MMM YYYY');
611
- // => Feb 1 2000 00:00:00 GMT-0800
612
- ```
613
-
614
- </details>
615
-
616
- <details open>
617
- <summary><strong>Max Date / Min Date</strong></summary>
618
-
619
- The parsable maximum date is `December 31, 9999`, and the minimum date is `January 1, 0001`.
620
-
621
- ```typescript
622
- parse('Dec 31 9999', 'MMM D YYYY');
623
- // => Dec 31 9999 00:00:00 GMT-0800
624
-
625
- parse('Dec 31 10000', 'MMM D YYYY');
626
- // => Invalid Date
627
-
628
- parse('Jan 1 0001', 'MMM D YYYY');
629
- // => Jan 1 0001 00:00:00 GMT-0800
630
-
631
- parse('Jan 1 0000', 'MMM D YYYY');
632
- // => Invalid Date
633
- ```
634
-
635
- </details>
636
-
637
- <details open>
638
- <summary><strong>12-hour notation and Meridiem</strong></summary>
639
-
640
- If you use the `hh` or `h` (12-hour) token, use it together with the `A` (meridiem) token to get the correct value.
641
-
642
- ```typescript
643
- parse('11:14:05', 'hh:mm:ss');
644
- // => Jan 1 1970 11:14:05 GMT-0800
645
-
646
- parse('11:14:05 PM', 'hh:mm:ss A');
647
- // => Jan 1 1970 23:14:05 GMT-0800
648
- ```
649
-
650
- </details>
651
-
652
- <details open>
653
- <summary><strong>Token invalidation</strong></summary>
654
-
655
- Any part of the given format string that you do not want to be recognized as a token should be enclosed in square brackets. They are considered comments and will not be parsed.
656
-
657
- ```typescript
658
- parse('12 hours 34 minutes', 'HH hours mm minutes');
659
- // => Invalid Date
660
-
661
- parse('12 hours 34 minutes', 'HH [hours] mm [minutes]');
662
- // => Jan 1 1970 12:34:00 GMT-0800
663
- ```
664
-
665
- </details>
666
-
667
- <details open>
668
- <summary><strong>Wildcard</strong></summary>
669
-
670
- Whitespace acts as a wildcard token. This token will skip parsing the corresponding parts of the date and time strings. This behavior is similar to enclosing part of a format string in square brackets (Token invalidation), but with the flexibility that the contents do not have to match exactly - only the character count needs to match between the format string and input string.
671
-
672
- ```typescript
673
- // This will be an error.
674
- parse('2015/01/02 11:14:05', 'YYYY/MM/DD');
675
- // => Invalid Date
676
-
677
- parse('2015/01/02 11:14:05', 'YYYY/MM/DD ');
678
- // => Jan 2 2015 00:00:00 GMT-0800
679
- ```
680
-
681
- </details>
682
-
683
- <details open>
684
- <summary><strong>Ellipsis</strong></summary>
685
-
686
- `...` token ignores subsequent corresponding date and time strings. Use this token only at the end of a format string. The above example can also be written like this:
687
-
688
- ```typescript
689
- parse('2015/01/02 11:14:05', 'YYYY/MM/DD...');
690
- // => Jan 2 2015 00:00:00 GMT-0800
691
- ```
692
-
693
- </details>
694
- </details>
695
-
696
- ### compile(formatString)
697
-
698
- <details>
699
- <summary>Compiles a format string into a tokenized array for efficient parsing and formatting.</summary>
700
-
701
- - formatString
702
- - type: `string`
703
- - The format string to compile
704
-
705
- If you are going to execute the `format`, `parse`, or `isValid` functions many times with one string format, it is recommended to precompile and reuse it for performance.
706
-
707
- ```typescript
708
- import { compile, parse, format } from 'date-and-time';
709
-
710
- const pattern = compile('MMM D YYYY h:m:s A');
711
-
712
- parse('Mar 22 2019 2:54:21 PM', pattern);
713
- parse('Jul 27 2019 4:15:24 AM', pattern);
714
- parse('Dec 25 2019 3:51:11 AM', pattern);
715
-
716
- format(new Date(), pattern);
717
- // => Mar 16 2020 6:24:56 PM
718
- ```
719
-
720
- </details>
721
-
722
- ### preparse(dateString, arg[, options])
723
-
724
- <details>
725
- <summary>Preparses a date string according to the specified pattern.</summary>
726
-
727
- - dateString
728
- - type: `string`
729
- - The date string to preparse
730
- - arg
731
- - type: `string | CompiledObject`
732
- - The pattern string or compiled object to match against the date string
733
- - [options]
734
- - type: `ParserOptions`
735
- - Optional parser options
736
-
737
- ```typescript
738
- import { preparse } from 'date-and-time';
739
-
740
- preparse('Jan 2015 02 23:14:05 GMT-0800', 'MMM YYYY DD HH:mm:ss [GMT]Z');
741
-
742
- {
743
- Y: 2015, // Year
744
- M: 1, // Month
745
- D: 2, // Day
746
- H: 23, // Hour (24-hour)
747
- m: 14, // Minute
748
- s: 5, // Second
749
- Z: 480, // Timezone offset in minutes
750
- _index: 29, // Current parsing position
751
- _length: 29, // Total length of date string
752
- _match: 7 // Number of matched tokens
753
- }
754
- ```
755
-
756
- This date structure provides a parsing result. You will be able to tell from it how the date string was parsed (or why the parsing failed).
757
-
758
- </details>
759
-
760
- ### isValid(dateString, arg[, options])
761
-
762
- <details>
763
- <summary>Validates whether a date string is valid according to the specified format.</summary>
764
-
765
- - dateString
766
- - type: `string`
767
- - The date string to validate
768
- - arg
769
- - type: `string | CompiledObject`
770
- - The format string or compiled object
771
- - [options]
772
- - type: `ParserOptions`
773
- - Optional parser options
774
-
775
- ```typescript
776
- isValid('2015/01/02 23:14:05', 'YYYY/MM/DD HH:mm:ss'); // => true
777
- isValid('29-02-2015', 'DD-MM-YYYY'); // => false
778
- ```
779
-
780
- For details about `ParserOptions`, refer to the `parse` function section.
781
-
782
- </details>
783
-
784
- ### transform(dateString, arg1, arg2[, options1[, options2]])
785
-
786
- <details>
787
- <summary>Transforms a date string from one format to another.</summary>
788
-
789
- - dateString
790
- - type: `string`
791
- - The date string to transform
792
- - arg1
793
- - type: `string | CompiledObject`
794
- - The format string or compiled object for parsing
795
- - arg2
796
- - type: `string | CompiledObject`
797
- - The format string or compiled object for formatting
798
- - [options1]
799
- - type: `ParserOptions`
800
- - Optional parser options
801
- - [options2]
802
- - type: `FormatterOptions`
803
- - Optional formatter options
804
-
805
- This is a syntactic sugar for combining `parse` and `format` processing to convert date formats in a single function. It converts `dateString` to `arg2` format. Actually, it parses the `dateString` in `arg1` format and then formats it in `arg2` format.
806
-
807
- ```typescript
808
- import { transform } from 'date-and-time';
809
- import New_York from 'date-and-time/timezones/America/New_York';
810
- import Los_Angeles from 'date-and-time/timezones/America/Los_Angeles';
811
-
812
- // Swap the order of month and day
813
- transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
814
- // => 8/3/2020
815
-
816
- // Convert 24-hour format to 12-hour format
817
- transform('13:05', 'HH:mm', 'hh:mm A');
818
- // => 01:05 PM
819
-
820
- // Convert EST to PST
821
- transform(
822
- '3/8/2020 1:05 PM', 'D/M/YYYY h:mm A', 'D/M/YYYY h:mm A',
823
- { timeZone: New_York }, { timeZone: Los_Angeles }
824
- );
825
- // => 3/8/2020 10:05 AM
826
- ```
827
-
828
- For details about `ParserOptions`, refer to the `parse` function section. For details about `FormatterOptions`, refer to the `format` function section.
829
-
830
- </details>
831
-
832
- ### addYears(dateObj, years[, timeZone])
833
-
834
- <details>
835
- <summary>Adds the specified number of years to a Date object.</summary>
836
-
837
- - dateObj
838
- - type: `Date`
839
- - The Date object to modify
840
- - years
841
- - type: `number`
842
- - The number of years to add
843
- - [timeZone]
844
- - type: `TimeZone | UTC`
845
- - Optional time zone object or `UTC`
846
-
847
- ```typescript
848
- import { addYears } from 'date-and-time';
849
- import Los_Angeles from 'date-and-time/timezones/America/Los_Angeles';
850
-
851
- const now = new Date(2024, 2, 11, 1); // => Mar 11 2024 01:00:00 GMT-07:00
852
-
853
- addYears(now, 1, Los_Angeles); // => Mar 11 2025 01:00:00 GMT-07:00
854
- addYears(now, -1, Los_Angeles); // => Mar 11 2023 01:00:00 GMT-08:00
855
- ```
856
-
857
- Exceptional behavior of the calculation for the last day of the month:
858
-
859
- ```typescript
860
- const now = new Date(Date.UTC(2020, 1, 29)); // => Feb 29 2020
861
- const next = addYears(now, 1, 'UTC'); // => Feb 28 2021
862
- const back = addYears(next, -1, 'UTC'); // => Feb 28 2020 (not the original date)
863
- ```
864
-
865
- </details>
866
-
867
- ### addMonths(dateObj, months[, timeZone])
868
-
869
- <details>
870
- <summary>Adds the specified number of months to a Date object.</summary>
871
-
872
- - dateObj
873
- - type: `Date`
874
- - The Date object to modify
875
- - months
876
- - type: `number`
877
- - The number of months to add
878
- - [timeZone]
879
- - type: `TimeZone | UTC`
880
- - Optional time zone object or `UTC`
881
-
882
- ```typescript
883
- import { addMonths } from 'date-and-time';
884
- import Los_Angeles from 'date-and-time/timezones/America/Los_Angeles';
885
-
886
- const now = new Date(2024, 2, 11, 1); // => Mar 11 2024 01:00:00 GMT-07:00
887
-
888
- addMonths(now, 1, Los_Angeles); // => Apr 11 2024 01:00:00 GMT-07:00
889
- addMonths(now, -1, Los_Angeles); // => Feb 11 2024 01:00:00 GMT-08:00
890
- ```
891
-
892
- Exceptional behavior of the calculation for the last day of the month:
893
-
894
- ```typescript
895
- const now = new Date(Date.UTC(2023, 0, 31)); // => Jan 31 2023
896
- const apr = addMonths(now, 3, 'UTC'); // => Apr 30 2023
897
- const feb = addMonths(apr, -2, 'UTC'); // => Feb 28 2023
898
- ```
899
-
900
- </details>
901
-
902
- ### addDays(dateObj, days[, timeZone])
903
-
904
- <details>
905
- <summary>Adds the specified number of days to a Date object.</summary>
906
-
907
- - dateObj
908
- - type: `Date`
909
- - The Date object to modify
910
- - days
911
- - type: `number`
912
- - The number of days to add
913
- - [timeZone]
914
- - type: `TimeZone | UTC`
915
- - Optional time zone object or `UTC`
916
-
917
- ```typescript
918
- import { addDays } from 'date-and-time';
919
- import Los_Angeles from 'date-and-time/timezones/America/Los_Angeles';
920
-
921
- const now = new Date(2024, 2, 11, 1); // => Mar 11 2024 01:00:00 GMT-07:00
922
-
923
- addDays(now, 1, Los_Angeles); // => Mar 12 2024 01:00:00 GMT-07:00
924
- addDays(now, -1, Los_Angeles); // => Mar 10 2024 01:00:00 GMT-08:00
925
- ```
926
-
927
- </details>
928
-
929
- ### addHours(dateObj, hours)
930
-
931
- <details>
932
- <summary>Adds the specified number of hours to a Date object.</summary>
933
-
934
- - dateObj
935
- - type: `Date`
936
- - The Date object to modify
937
- - hours
938
- - type: `number`
939
- - The number of hours to add
940
-
941
- ```typescript
942
- import { addHours } from 'date-and-time';
943
-
944
- const now = new Date(2025, 6, 24); // => Jul 24 2025 00:00:00
945
-
946
- addHours(now, -1); // => Jul 23 2025 23:00:00
947
- ```
948
-
949
- </details>
950
-
951
- ### addMinutes(dateObj, minutes)
952
-
953
- <details>
954
- <summary>Adds the specified number of minutes to a Date object.</summary>
955
-
956
- - dateObj
957
- - type: `Date`
958
- - The Date object to modify
959
- - minutes
960
- - type: `number`
961
- - The number of minutes to add
962
-
963
- ```typescript
964
- import { addMinutes } from 'date-and-time';
965
-
966
- const now = new Date(2025, 6, 24); // => Jul 24 2025 00:00:00
967
-
968
- addMinutes(now, 2); // => Jul 24 2025 00:02:00
969
- ```
970
-
971
- </details>
972
-
973
- ### addSeconds(dateObj, seconds)
974
-
975
- <details>
976
- <summary>Adds the specified number of seconds to a Date object.</summary>
977
-
978
- - dateObj
979
- - type: `Date`
980
- - The Date object to modify
981
- - seconds
982
- - type: `number`
983
- - The number of seconds to add
984
-
985
- ```typescript
986
- import { addSeconds } from 'date-and-time';
987
-
988
- const now = new Date(2025, 6, 24); // => Jul 24 2025 00:00:00
989
-
990
- addSeconds(now, -3); // => Jul 23 2025 23:59:57
991
- ```
992
-
993
- </details>
994
-
995
- ### addMilliseconds(dateObj, milliseconds)
996
-
997
- <details>
998
- <summary>Adds the specified number of milliseconds to a Date object.</summary>
999
-
1000
- - dateObj
1001
- - type: `Date`
1002
- - The Date object to modify
1003
- - milliseconds
1004
- - type: `number`
1005
- - The number of milliseconds to add
1006
-
1007
- ```typescript
1008
- import { addMilliseconds } from 'date-and-time';
1009
-
1010
- const now = new Date(2025, 6, 24); // => Jul 24 2025 00:00:00.000
1011
-
1012
- addMilliseconds(now, 123); // => Jul 24 2025 00:00:00.123
1013
- ```
1014
-
1015
- </details>
1016
-
1017
- ### subtract(from, to)
1018
-
1019
- <details>
1020
- <summary>Calculates the difference between two dates.</summary>
1021
-
1022
- - from
1023
- - type: `Date`
1024
- - The first Date object
1025
- - to
1026
- - type: `Date`
1027
- - The second Date object
1028
-
1029
- Returns a `Duration` instance with methods to get the difference in various units.
1030
-
1031
- ```typescript
1032
- import { subtract } from 'date-and-time';
1033
-
1034
- const yesterday = new Date(2015, 0, 1);
1035
- const today = new Date(2015, 0, 2, 3, 4, 5, 6);
1036
-
1037
- const duration = subtract(yesterday, today);
1038
-
1039
- duration.toDays().value; // => 1.127835...
1040
- duration.toHours().value; // => 27.068057...
1041
- duration.toMinutes().value; // => 1624.083433...
1042
- duration.toSeconds().value; // => 97445.006
1043
- duration.toMilliseconds().value; // => 97445006
1044
- duration.toMicroseconds().value; // => 97445006000
1045
- duration.toNanoseconds().value; // => 97445006000000
1046
- ```
1047
-
1048
- #### Duration
1049
-
1050
- The `Duration` object can be directly created not only as a return value of the `subtract` function, but also by passing any numeric value (milliseconds) as a constructor argument.
1051
-
1052
- ```typescript
1053
- import { Duration } from 'date-and-time';
1054
-
1055
- const duration = new Duration(123);
1056
-
1057
- duration.toSeconds().value; // => 0.123
1058
- ```
1059
-
1060
- <details>
1061
- <summary><strong>toDays()</strong></summary>
1062
-
1063
- This method calculates the number of days in the duration and returns a descriptor that includes the value in days, a format method for custom formatting, and a toParts method that returns an object with the parts of the duration.
1064
-
1065
- ```typescript
1066
- duration.toDays().value;
1067
- // => 1.127835...
1068
-
1069
- duration.toDays().format('D[day], H:mm:ss.SSSfffFFF');
1070
- // => 1day, 3:04:05.006000000
1071
-
1072
- duration.toDays().toParts();
1073
- // => { days: 1, hours: 3, minutes: 4, seconds: 5, ... }
1074
- ```
1075
-
1076
- </details>
1077
-
1078
- <details>
1079
- <summary><strong>toHours()</strong></summary>
1080
-
1081
- This method calculates the number of hours in the duration and returns a descriptor that includes the value in hours, a format method for custom formatting, and a toParts method that returns an object with the parts of the duration.
1082
-
1083
- ```typescript
1084
- duration.toHours().value;
1085
- // => 27.068057...
1086
-
1087
- duration.toHours().format('H:mm:ss.SSSfffFFF');
1088
- // => 27:04:05.006000000
1089
-
1090
- duration.toHours().toParts();
1091
- // => { hours: 27, minutes: 4, seconds: 5, ... }
1092
- ```
1093
-
1094
- </details>
1095
-
1096
- <details>
1097
- <summary><strong>toMinutes()</strong></summary>
1098
-
1099
- This method calculates the number of minutes in the duration and returns a descriptor that includes the value in minutes, a format method for custom formatting, and a toParts method that returns an object with the parts of the duration.
1100
-
1101
- ```typescript
1102
- duration.toMinutes().value;
1103
- // => 1624.083433...
1104
-
1105
- duration.toMinutes().format('m[min] ss.SSSfffFFF');
1106
- // => 1624min 05.006000000
1107
-
1108
- duration.toMinutes().toParts();
1109
- // => { minutes: 1624, seconds: 5, milliseconds: 6, ... }
1110
- ```
1111
-
1112
- </details>
1113
-
1114
- <details>
1115
- <summary><strong>toSeconds()</strong></summary>
1116
-
1117
- This method calculates the number of seconds in the duration and returns a descriptor that includes the value in seconds, a format method for custom formatting, and a toParts method that returns an object with the parts of the duration.
1118
-
1119
- ```typescript
1120
- duration.toSeconds().value;
1121
- // => 97445.006
1122
-
1123
- duration.toSeconds().format('s[sec] SSSfffFFF');
1124
- // => 97445sec 006000000
1125
-
1126
- duration.toSeconds().toParts();
1127
- // => { seconds: 97445, milliseconds: 6, microseconds: 0, ... }
1128
- ```
1129
-
1130
- </details>
1131
-
1132
- <details>
1133
- <summary><strong>toMilliseconds()</strong></summary>
1134
-
1135
- This method calculates the number of milliseconds in the duration and returns a descriptor that includes the value in milliseconds, a format method for custom formatting, and a toParts method that returns an object with the parts of the duration.
1136
-
1137
- ```typescript
1138
- duration.toMilliseconds().value;
1139
- // => 97445006
1140
-
1141
- duration.toMilliseconds().format('S.fffFFF');
1142
- // => 97445006.000000
1143
-
1144
- duration.toMilliseconds().toParts();
1145
- // => { milliseconds: 97445006, microseconds: 0, nanoseconds: 0 }
1146
- ```
1147
-
1148
- </details>
1149
-
1150
- <details>
1151
- <summary><strong>toMicroseconds()</strong></summary>
1152
-
1153
- This method calculates the number of microseconds in the duration and returns a descriptor that includes the value in microseconds, a format method for custom formatting, and a toParts method that returns an object with the microseconds and nanoseconds parts.
1154
-
1155
- ```typescript
1156
- duration.toMicroseconds().value;
1157
- // => 97445006000
1158
-
1159
- duration.toMicroseconds().format('f.FFF');
1160
- // => 97445006000.000
1161
-
1162
- duration.toMicroseconds().toParts();
1163
- // => { microseconds: 97445006000, nanoseconds: 0 }
1164
- ```
1165
-
1166
- </details>
1167
-
1168
- <details>
1169
- <summary><strong>toNanoseconds()</strong></summary>
1170
-
1171
- This method calculates the number of nanoseconds in the duration and returns a descriptor that includes the value in nanoseconds, a format method for custom formatting, and a toParts method that returns an object with the nanoseconds part.
1172
-
1173
- ```typescript
1174
- duration.toNanoseconds().value;
1175
- // => 97445006000000
1176
-
1177
- duration.toNanoseconds().format('F[ns]');
1178
- // => 97445006000000ns
1179
-
1180
- duration.toNanoseconds().toParts();
1181
- // => { nanoseconds: 97445006000000 }
1182
- ```
1183
-
1184
- </details>
1185
-
1186
- #### DurationDescriptor
1187
-
1188
- ##### value
1189
-
1190
- The value of the duration in the respective unit.
1191
-
1192
- ##### format(formatString[, numeral])
1193
-
1194
- <details>
1195
- <summary>Formats the duration according to the provided format string.</summary>
1196
-
1197
- - formatString
1198
- - type: `string`
1199
- - The format string to use for formatting
1200
- - [numeral]
1201
- - type: `Numeral`
1202
- - default: `latn`
1203
- - Optional numeral object for number formatting
1204
-
1205
- The tokens available for use in the format string specified as the first argument and their meanings are as follows. However, tokens for units larger than the `DurationDescriptor` cannot be used. For example, in the case of a `DurationDescriptor` obtained by the `toHours` method, the `D` token representing days cannot be used. For a `DurationDescriptor` obtained by the `toNanoseconds` method, only the `F` token representing nanoseconds can be used.
1206
-
1207
- | Token | Meaning |
1208
- |:---------|:-----------------------------------|
1209
- | D | Days |
1210
- | H | Hours |
1211
- | m | Minutes |
1212
- | s | Seconds |
1213
- | S | Milliseconds |
1214
- | f | Microseconds |
1215
- | F | Nanoseconds |
1216
-
1217
- What makes the format string in `DurationDescriptor` different from others is that repeating the same token produces a zero-padding effect. For example, formatting `1 day` with `DDDD` results in an output of `0001`.
1218
-
1219
- </details>
1220
-
1221
- ##### toParts()
1222
-
1223
- <details>
1224
- <summary>Converts the duration to an object containing the parts of the duration in the respective unit.</summary>
1225
-
1226
- ```typescript
1227
- {
1228
- days: 1,
1229
- hours: 3,
1230
- minutes: 4,
1231
- seconds: 5,
1232
- milliseconds: 6,
1233
- microseconds: 0,
1234
- nanoseconds: 0
1235
- }
1236
- ```
1237
-
1238
- </details>
1239
-
1240
- #### Notes
1241
-
1242
- <details open>
1243
- <summary><strong>Negative Duration</strong></summary>
1244
-
1245
- When the `value` becomes negative, there are slight differences in the output results of the `format` method and the `toParts` method. In the `format` method, only the largest unit in the `DurationDescriptor`, for example, only the `D` token in the case of a `DurationDescriptor` obtained by the `toDays` method, gets a minus sign, while in the `toParts` method, all units get a minus sign.
1246
-
1247
- ```typescript
1248
- duration.toDays().value;
1249
- // => -1.127835...
1250
-
1251
- duration.toDays().format('D[day], H:mm:ss.SSSfffFFF');
1252
- // => -1day, 3:04:05.006000000
1253
-
1254
- duration.toDays().toParts();
1255
- // => { days: -1, hours: -3, minutes: -4, seconds: -5, ... }
1256
- ```
1257
-
1258
- </details>
1259
-
1260
- <details open>
1261
- <summary><strong>Negative Zero</strong></summary>
1262
-
1263
- The `format` method may output `-0`. For example, when the value of a `DurationDescriptor` obtained by the `toDays` method is a negative decimal less than 1, using the `D` token in the `format` method outputs `-0`.
1264
-
1265
- ```typescript
1266
- duration.toDays().value;
1267
- // => -0.127835...
1268
-
1269
- duration.toDays().format('D[day], H:mm:ss.SSSfffFFF');
1270
- // => -0day, 3:04:05.006000000
1271
-
1272
- duration.toDays().toParts();
1273
- // => { days: 0, hours: -3, minutes: -4, seconds: -5, ... }
1274
- ```
1275
-
1276
- </details>
1277
- </details>
1278
-
1279
- ### isLeapYear(year)
1280
-
1281
- <details>
1282
- <summary>Determines if the specified year is a leap year.</summary>
1283
-
1284
- - year
1285
- - type: `number`
1286
- - The year to check
1287
-
1288
- ```typescript
1289
- import { isLeapYear } from 'date-and-time';
1290
-
1291
- isLeapYear(2015); // => false
1292
- isLeapYear(2012); // => true
1293
- ```
1294
-
1295
- </details>
1296
-
1297
- ### isSameDay(date1, date2)
1298
-
1299
- <details>
1300
- <summary>Determines if two dates represent the same calendar day.</summary>
1301
-
1302
- - date1
1303
- - type: `Date`
1304
- - The first date to compare
1305
- - date2
1306
- - type: `Date`
1307
- - The second date to compare
1308
-
1309
- ```typescript
1310
- import { isSameDay } from 'date-and-time';
1311
-
1312
- const date1 = new Date(2017, 0, 2, 0); // Jan 2 2017 00:00:00
1313
- const date2 = new Date(2017, 0, 2, 23, 59); // Jan 2 2017 23:59:00
1314
- const date3 = new Date(2017, 0, 1, 23, 59); // Jan 1 2017 23:59:00
1315
-
1316
- isSameDay(date1, date2); // => true
1317
- isSameDay(date1, date3); // => false
1318
- ```
1319
-
1320
- </details>
57
+ MIT
1321
58
 
1322
59
  ## Contributing
1323
60