UNPKG

61.2 kBMarkdownView Raw
1# Change Log
2
3All notable changes to this project will be documented in this file.
4This project adheres to [Semantic Versioning].
5
6This change log follows the format documented in [Keep a CHANGELOG].
7
8[semantic versioning]: http://semver.org/
9[keep a changelog]: http://keepachangelog.com/
10
11## [2.1.0] - 2019-09-06
12
13Thanks to date-fns contributors: [@ManadayM](https://github.com/ManadayM), [@illuminist](https://github.com/illuminist), [@visualfanatic](https://github.com/visualfanatic), [@vsaarinen](https://github.com/vsaarinen) and at least but not least [@leshakoss](https://github.com/leshakoss)!
14
15### Fixed
16
17- [Set start of the week to the Sunday for Thai locale](https://github.com/date-fns/date-fns/pull/1402).
18- [Fixed month matching in Polish locale](https://github.com/date-fns/date-fns/pull/1404).
19- [Fixed `eachWeekendOfInterval` skipping the first date in the supplied interval](https://github.com/date-fns/date-fns/pull/1407).
20
21### Added
22
23- [Added Gujarati locale](https://github.com/date-fns/date-fns/pull/1400).
24
25## [2.0.1] - 2019-08-23
26
27### Fixed
28
29- [Fix](https://github.com/date-fns/date-fns/pull/1046) `getWeekOfMonth` with `options.weekStartsOn` set to 1 [not working for Sundays](https://github.com/date-fns/date-fns/issues/1040). Kudos to [@waseemahmad31](https://github.com/waseemahmad31)!
30
31## [2.0.0] - 2019-08-20
32
33If you're upgrading from v2 alpha or beta, [see the pre-release changelog](https://gist.github.com/kossnocorp/a307a464760b405bb78ef5020a4ab136).
34
35### Fixed
36
37- Fix the `toDate` bug occurring when parsing ISO-8601 style dates (but not valid ISO format)
38 with a trailing Z (e.g `2012-01Z`), it returned Invalid Date for FireFox/IE11 [#510](https://github.com/date-fns/date-fns/issue/510)
39
40- Fix `differenceIn...` functions returning negative zero in some cases:
41 [#692](https://github.com/date-fns/date-fns/issues/692)
42
43- `isDate` now works properly with dates passed across iframes [#754](https://github.com/date-fns/date-fns/pull/754).
44
45- Fix a few bugs that appear in timezones with offsets that include seconds (e.g. GMT+00:57:44).
46 See PR [#789](https://github.com/date-fns/date-fns/pull/789).
47
48- [Fixed DST issue](https://github.com/date-fns/date-fns/pull/1003). See [#972](https://github.com/date-fns/date-fns/issues/972) and [#992](https://github.com/date-fns/date-fns/issues/992) for more details.
49
50- Fixed DST issue in `eachDayOfInterval` that caused time in the days
51 after DST change to have the shift as well.
52
53- Fix bug in Galician locale caused by incorrect usage of `getHours`
54 instead of `getUTCHours`.
55
56### Changed
57
58- **BREAKING**: now functions don't accept string arguments, but only
59 numbers or dates. When a string is passed, it will result in
60 an unexpected result (`Invalid Date`, `NaN`, etc).
61
62 From now on a string should be parsed using `parseISO` (ISO 8601)
63 or `parse`.
64
65 In v1 we've used `new Date()` to parse strings, but it resulted in many
66 hard-to-track bugs caused by inconsistencies in different browsers.
67 To address that we've implemented our ISO 8601 parser but that made
68 library to significantly grow in size. To prevent inevitable bugs
69 and keep the library tiny, we made this trade-off.
70
71 See [this post](https://blog.date-fns.org/post/we-cut-date-fns-v2-minimal-build-size-down-to-300-bytes-and-now-its-the-smallest-date-library-18f2nvh2z0yal) for more details.
72
73 ```javascript
74 // Before v2.0.0
75 addDays('2016-01-01', 1)
76
77 // v2.0.0 onward
78 addDays(parseISO('2016-01-01'), 1)
79 ```
80
81- **BREAKING**: new format string API for `format` function
82 which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
83 See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
84
85 | Unit | Pattern | Result examples |
86 | ------------------------------- | -------- | --------------------------------- |
87 | Era | G..GGG | AD, BC |
88 | | GGGG | Anno Domini, Before Christ |
89 | | GGGGG | A, B |
90 | Calendar year | y | 44, 1, 1900, 2017 |
91 | | yo | 44th, 1st, 0th, 17th |
92 | | yy | 44, 01, 00, 17 |
93 | | yyy | 044, 001, 1900, 2017 |
94 | | yyyy | 0044, 0001, 1900, 2017 |
95 | | yyyyy | ... |
96 | Local week-numbering year | Y | 44, 1, 1900, 2017 |
97 | | Yo | 44th, 1st, 1900th, 2017th |
98 | | YY | 44, 01, 00, 17 |
99 | | YYY | 044, 001, 1900, 2017 |
100 | | YYYY | 0044, 0001, 1900, 2017 |
101 | | YYYYY | ... |
102 | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 |
103 | | RR | -43, 00, 01, 1900, 2017 |
104 | | RRR | -043, 000, 001, 1900, 2017 |
105 | | RRRR | -0043, 0000, 0001, 1900, 2017 |
106 | | RRRRR | ... |
107 | Extended year | u | -43, 0, 1, 1900, 2017 |
108 | | uu | -43, 01, 1900, 2017 |
109 | | uuu | -043, 001, 1900, 2017 |
110 | | uuuu | -0043, 0001, 1900, 2017 |
111 | | uuuuu | ... |
112 | Quarter (formatting) | Q | 1, 2, 3, 4 |
113 | | Qo | 1st, 2nd, 3rd, 4th |
114 | | QQ | 01, 02, 03, 04 |
115 | | QQQ | Q1, Q2, Q3, Q4 |
116 | | QQQQ | 1st quarter, 2nd quarter, ... |
117 | | QQQQQ | 1, 2, 3, 4 |
118 | Quarter (stand-alone) | q | 1, 2, 3, 4 |
119 | | qo | 1st, 2nd, 3rd, 4th |
120 | | qq | 01, 02, 03, 04 |
121 | | qqq | Q1, Q2, Q3, Q4 |
122 | | qqqq | 1st quarter, 2nd quarter, ... |
123 | | qqqqq | 1, 2, 3, 4 |
124 | Month (formatting) | M | 1, 2, ..., 12 |
125 | | Mo | 1st, 2nd, ..., 12th |
126 | | MM | 01, 02, ..., 12 |
127 | | MMM | Jan, Feb, ..., Dec |
128 | | MMMM | January, February, ..., December |
129 | | MMMMM | J, F, ..., D |
130 | Month (stand-alone) | L | 1, 2, ..., 12 |
131 | | Lo | 1st, 2nd, ..., 12th |
132 | | LL | 01, 02, ..., 12 |
133 | | LLL | Jan, Feb, ..., Dec |
134 | | LLLL | January, February, ..., December |
135 | | LLLLL | J, F, ..., D |
136 | Local week of year | w | 1, 2, ..., 53 |
137 | | wo | 1st, 2nd, ..., 53th |
138 | | ww | 01, 02, ..., 53 |
139 | ISO week of year | I | 1, 2, ..., 53 |
140 | | Io | 1st, 2nd, ..., 53th |
141 | | II | 01, 02, ..., 53 |
142 | Day of month | d | 1, 2, ..., 31 |
143 | | do | 1st, 2nd, ..., 31st |
144 | | dd | 01, 02, ..., 31 |
145 | Day of year | D | 1, 2, ..., 365, 366 |
146 | | Do | 1st, 2nd, ..., 365th, 366th |
147 | | DD | 01, 02, ..., 365, 366 |
148 | | DDD | 001, 002, ..., 365, 366 |
149 | | DDDD | ... |
150 | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Su |
151 | | EEEE | Monday, Tuesday, ..., Sunday |
152 | | EEEEE | M, T, W, T, F, S, S |
153 | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa |
154 | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 |
155 | | io | 1st, 2nd, ..., 7th |
156 | | ii | 01, 02, ..., 07 |
157 | | iii | Mon, Tue, Wed, ..., Su |
158 | | iiii | Monday, Tuesday, ..., Sunday |
159 | | iiiii | M, T, W, T, F, S, S |
160 | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa |
161 | Local day of week (formatting) | e | 2, 3, 4, ..., 1 |
162 | | eo | 2nd, 3rd, ..., 1st |
163 | | ee | 02, 03, ..., 01 |
164 | | eee | Mon, Tue, Wed, ..., Su |
165 | | eeee | Monday, Tuesday, ..., Sunday |
166 | | eeeee | M, T, W, T, F, S, S |
167 | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa |
168 | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 |
169 | | co | 2nd, 3rd, ..., 1st |
170 | | cc | 02, 03, ..., 01 |
171 | | ccc | Mon, Tue, Wed, ..., Su |
172 | | cccc | Monday, Tuesday, ..., Sunday |
173 | | ccccc | M, T, W, T, F, S, S |
174 | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa |
175 | AM, PM | a..aaa | AM, PM |
176 | | aaaa | a.m., p.m. |
177 | | aaaaa | a, p |
178 | AM, PM, noon, midnight | b..bbb | AM, PM, noon, midnight |
179 | | bbbb | a.m., p.m., noon, midnight |
180 | | bbbbb | a, p, n, mi |
181 | Flexible day period | B..BBB | at night, in the morning, ... |
182 | | BBBB | at night, in the morning, ... |
183 | | BBBBB | at night, in the morning, ... |
184 | Hour [1-12] | h | 1, 2, ..., 11, 12 |
185 | | ho | 1st, 2nd, ..., 11th, 12th |
186 | | hh | 01, 02, ..., 11, 12 |
187 | Hour [0-23] | H | 0, 1, 2, ..., 23 |
188 | | Ho | 0th, 1st, 2nd, ..., 23rd |
189 | | HH | 00, 01, 02, ..., 23 |
190 | Hour [0-11] | K | 1, 2, ..., 11, 0 |
191 | | Ko | 1st, 2nd, ..., 11th, 0th |
192 | | KK | 1, 2, ..., 11, 0 |
193 | Hour [1-24] | k | 24, 1, 2, ..., 23 |
194 | | ko | 24th, 1st, 2nd, ..., 23rd |
195 | | kk | 24, 01, 02, ..., 23 |
196 | Minute | m | 0, 1, ..., 59 |
197 | | mo | 0th, 1st, ..., 59th |
198 | | mm | 00, 01, ..., 59 |
199 | Second | s | 0, 1, ..., 59 |
200 | | so | 0th, 1st, ..., 59th |
201 | | ss | 00, 01, ..., 59 |
202 | Fraction of second | S | 0, 1, ..., 9 |
203 | | SS | 00, 01, ..., 99 |
204 | | SSS | 000, 0001, ..., 999 |
205 | | SSSS | ... |
206 | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z |
207 | | XX | -0800, +0530, Z |
208 | | XXX | -08:00, +05:30, Z |
209 | | XXXX | -0800, +0530, Z, +123456 |
210 | | XXXXX | -08:00, +05:30, Z, +12:34:56 |
211 | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 |
212 | | xx | -0800, +0530, +0000 |
213 | | xxx | -08:00, +05:30, +00:00 |
214 | | xxxx | -0800, +0530, +0000, +123456 |
215 | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 |
216 | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 |
217 | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 |
218 | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 |
219 | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 |
220 | Seconds timestamp | t | 512969520 |
221 | | tt | ... |
222 | Milliseconds timestamp | T | 512969520900 |
223 | | TT | ... |
224 | Long localized date | P | 5/29/53 |
225 | | PP | May 29, 1453 |
226 | | PPP | May 29th, 1453 |
227 | | PPPP | Sunday, May 29th, 1453 |
228 | Long localized time | p | 12:00 AM |
229 | | pp | 12:00:00 AM |
230 | | ppp | 12:00:00 AM GMT+2 |
231 | | pppp | 12:00:00 AM GMT+02:00 |
232 | Combination of date and time | Pp | 5/29/53, 12:00 AM |
233 | | PPpp | May 29, 1453, 12:00 AM |
234 | | PPPppp | May 29th, 1453 at ... |
235 | | PPPPpppp | Sunday, May 29th, 1453 at ... |
236
237 Characters are now escaped using single quote symbols (`'`) instead of square brackets.
238 `format` now throws RangeError if it encounters an unescaped latin character
239 that isn't a valid formatting token.
240
241 To use `YY` and `YYYY` tokens that represent week-numbering years,
242 you should set `useAdditionalWeekYearTokens` option:
243
244 ```javascript
245 format(Date.now(), 'YY', { useAdditionalWeekYearTokens: true })
246 //=> '86'
247 ```
248
249 To use `D` and `DD` tokens which represent days of the year,
250 set `useAdditionalDayOfYearTokens` option:
251
252 ```javascript
253 format(Date.now(), 'D', { useAdditionalDayOfYearTokens: true })
254 //=> '364'
255 ```
256
257- **BREAKING**: function submodules now use camelCase naming schema:
258
259 ```javascript
260 // Before v2.0.0
261 import differenceInCalendarISOYears from 'date-fns/difference_in_calendar_iso_years'
262
263 // v2.0.0 onward
264 import differenceInCalendarISOYears from 'date-fns/differenceInCalendarISOYears'
265 ```
266
267- **BREAKING**: min and max functions now accept an array of dates
268 rather than spread arguments.
269
270 ```javascript
271 // Before v2.0.0
272 var date1 = new Date(1989, 6 /* Jul */, 10)
273 var date2 = new Date(1987, 1 /* Feb */, 11)
274
275 var minDate = min(date1, date2)
276 var maxDate = max(date1, date2)
277
278 // v2.0.0 onward:
279 var dates = [new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11)]
280
281 var minDate = min(dates)
282 var maxDate = max(dates)
283 ```
284
285- **BREAKING**: make the second argument of `format` required for the sake of explicitness.
286
287 ```javascript
288 // Before v2.0.0
289 format(new Date(2016, 0, 1))
290
291 // v2.0.0 onward
292 format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
293 ```
294
295- **BREAKING** renamed ISO week-numbering year helpers:
296
297 - `addISOYears` → `addISOWeekYears`
298 - `differenceInCalendarISOYears` → `differenceInCalendarISOWeekYears`
299 - `differenceInISOYears` → `differenceInISOWeekYears`
300 - `endOfISOYear` → `endOfISOWeekYear`
301 - `getISOYear` → `getISOWeekYear`
302 - `isSameISOYear` → `isSameISOWeekYear`
303 - `lastDayOfISOYear` → `lastDayOfISOWeekYear`
304 - `setISOYear` → `setISOWeekYear`
305 - `subISOYears` → `subISOWeekYears`
306
307 i.e. "ISO year" renamed to "ISO week year", which is short for
308 [ISO week-numbering year](https://en.wikipedia.org/wiki/ISO_week_date).
309 It makes them consistent with locale-dependent week-numbering year helpers,
310 e.g., `startOfWeekYear`.
311
312- **BREAKING**: functions renamed:
313
314 - `areRangesOverlapping` → `areIntervalsOverlapping`
315 - `eachDay` → `eachDayOfInterval`
316 - `getOverlappingDaysInRanges` → `getOverlappingDaysInIntervals`
317 - `isWithinRange` → `isWithinInterval`
318
319 This change was made to mirror the use of the word "interval" in standard ISO 8601:2004 terminology:
320
321 ```
322 2.1.3
323 time interval
324 part of the time axis limited by two instants
325 ```
326
327 Also these functions now accept an object with `start` and `end` properties
328 instead of two arguments as an interval. All these functions
329 throw `RangeError` if the start of the interval is after its end
330 or if any date in the interval is `Invalid Date`.
331
332 ```javascript
333 // Before v2.0.0
334
335 areRangesOverlapping(
336 new Date(2014, 0, 10),
337 new Date(2014, 0, 20),
338 new Date(2014, 0, 17),
339 new Date(2014, 0, 21)
340 )
341
342 eachDay(new Date(2014, 0, 10), new Date(2014, 0, 20))
343
344 getOverlappingDaysInRanges(
345 new Date(2014, 0, 10),
346 new Date(2014, 0, 20),
347 new Date(2014, 0, 17),
348 new Date(2014, 0, 21)
349 )
350
351 isWithinRange(
352 new Date(2014, 0, 3),
353 new Date(2014, 0, 1),
354 new Date(2014, 0, 7)
355 )
356
357 // v2.0.0 onward
358
359 areIntervalsOverlapping(
360 { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) },
361 { start: new Date(2014, 0, 17), end: new Date(2014, 0, 21) }
362 )
363
364 eachDayOfInterval({
365 start: new Date(2014, 0, 10),
366 end: new Date(2014, 0, 20)
367 })
368
369 getOverlappingDaysInIntervals(
370 { start: new Date(2014, 0, 10), end: new Date(2014, 0, 20) },
371 { start: new Date(2014, 0, 17), end: new Date(2014, 0, 21) }
372 )
373
374 isWithinInterval(new Date(2014, 0, 3), {
375 start: new Date(2014, 0, 1),
376 end: new Date(2014, 0, 7)
377 })
378 ```
379
380- **BREAKING**: functions renamed:
381
382 - `distanceInWords` → `formatDistance`
383 - `distanceInWordsStrict` → `formatDistanceStrict`
384 - `distanceInWordsToNow` → `formatDistanceToNow`
385
386 to make them consistent with `format` and `formatRelative`.
387
388- **BREAKING**: The order of arguments of `distanceInWords` and `distanceInWordsStrict`
389 is swapped to make them consistent with `differenceIn...` functions.
390
391 ```javascript
392 // Before v2.0.0
393
394 distanceInWords(
395 new Date(1986, 3, 4, 10, 32, 0),
396 new Date(1986, 3, 4, 11, 32, 0),
397 { addSuffix: true }
398 ) //=> 'in about 1 hour'
399
400 // v2.0.0 onward
401
402 formatDistance(
403 new Date(1986, 3, 4, 11, 32, 0),
404 new Date(1986, 3, 4, 10, 32, 0),
405 { addSuffix: true }
406 ) //=> 'in about 1 hour'
407 ```
408
409- **BREAKING**: `partialMethod` option in `formatDistanceStrict` is renamed to `roundingMethod`.
410
411 ```javascript
412 // Before v2.0.0
413
414 distanceInWordsStrict(
415 new Date(1986, 3, 4, 10, 32, 0),
416 new Date(1986, 3, 4, 10, 33, 1),
417 { partialMethod: 'ceil' }
418 ) //=> '2 minutes'
419
420 // v2.0.0 onward
421
422 formatDistanceStrict(
423 new Date(1986, 3, 4, 10, 33, 1),
424 new Date(1986, 3, 4, 10, 32, 0),
425 { roundingMethod: 'ceil' }
426 ) //=> '2 minutes'
427 ```
428
429- **BREAKING**: in `formatDistanceStrict`, if `roundingMethod` is not specified,
430 it now defaults to `round` instead of `floor`.
431
432- **BREAKING**: `unit` option in `formatDistanceStrict` now accepts one of the strings:
433 'second', 'minute', 'hour', 'day', 'month' or 'year' instead of 's', 'm', 'h', 'd', 'M' or 'Y'
434
435 ```javascript
436 // Before v2.0.0
437
438 distanceInWordsStrict(
439 new Date(1986, 3, 4, 10, 32, 0),
440 new Date(1986, 3, 4, 10, 33, 1),
441 { unit: 'm' }
442 )
443
444 // v2.0.0 onward
445
446 formatDistanceStrict(
447 new Date(1986, 3, 4, 10, 33, 1),
448 new Date(1986, 3, 4, 10, 32, 0),
449 { unit: 'minute' }
450 )
451 ```
452
453- **BREAKING**: `parse` that previously used to convert strings and
454 numbers to dates now parse only strings in an arbitrary format
455 specified as an argument. Use `toDate` to coerce numbers and `parseISO`
456 to parse ISO 8601 strings.
457
458 ```javascript
459 // Before v2.0.0
460 parse('2016-01-01')
461 parse(1547005581366)
462 parse(new Date()) // Clone the date
463
464 // v2.0.0 onward
465 parse('2016-01-01', 'yyyy-MM-dd', new Date())
466 parseISO('2016-01-01')
467 toDate(1547005581366)
468 toDate(new Date()) // Clone the date
469 ```
470
471- **BREAKING**: `toDate` (previously `parse`) now doesn't accept string
472 arguments but only numbers and dates. `toDate` called with an invalid
473 argument will return `Invalid Date`.
474
475- **BREAKING**: new locale format.
476 See [docs/Locale](https://date-fns.org/docs/Locale).
477 Locales renamed:
478
479 - `en` → `en-US`
480 - `zh_cn` → `zh-CN`
481 - `zh_tw` → `zh-TW`
482
483 ```javascript
484 // Before v2.0.0
485 import locale from 'date-fns/locale/zh_cn'
486
487 // v2.0.0 onward
488 import locale from 'date-fns/locale/zh-CN'
489 ```
490
491- **BREAKING**: now `closestTo` and `closestIndexTo` don't throw an exception
492 when the second argument is not an array, and return Invalid Date instead.
493
494- **BREAKING**: now `isValid` doesn't throw an exception
495 if the first argument is not an instance of Date.
496 Instead, argument is converted beforehand using `toDate`.
497
498 Examples:
499
500 | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
501 | ------------------------- | ------------- | ------------- |
502 | `new Date()` | `true` | `true` |
503 | `new Date('2016-01-01')` | `true` | `true` |
504 | `new Date('')` | `false` | `false` |
505 | `new Date(1488370835081)` | `true` | `true` |
506 | `new Date(NaN)` | `false` | `false` |
507 | `'2016-01-01'` | `TypeError` | `false` |
508 | `''` | `TypeError` | `false` |
509 | `1488370835081` | `TypeError` | `true` |
510 | `NaN` | `TypeError` | `false` |
511
512 We introduce this change to make _date-fns_ consistent with ECMAScript behavior
513 that try to coerce arguments to the expected type
514 (which is also the case with other _date-fns_ functions).
515
516- **BREAKING**: functions now throw `RangeError` if optional values passed to `options`
517 are not `undefined` or have expected values.
518 This change is introduced for consistency with ECMAScript standard library which does the same.
519
520- **BREAKING**: `format`, `formatDistance` (previously `distanceInWords`) and
521 `formatDistanceStrict` (previously `distanceInWordsStrict`) now throw
522 `RangeError` if one the passed arguments is invalid. It reflects behavior of
523 `toISOString` and Intl API. See [#1032](https://github.com/date-fns/date-fns/pull/1032).
524
525- **BREAKING**: all functions now implicitly convert arguments by following rules:
526
527 | | date | number | string | boolean |
528 | --------- | ------------ | ------ | ----------- | ------- |
529 | 0 | new Date(0) | 0 | '0' | false |
530 | '0' | Invalid Date | 0 | '0' | false |
531 | 1 | new Date(1) | 1 | '1' | true |
532 | '1' | Invalid Date | 1 | '1' | true |
533 | true | Invalid Date | NaN | 'true' | true |
534 | false | Invalid Date | NaN | 'false' | false |
535 | null | Invalid Date | NaN | 'null' | false |
536 | undefined | Invalid Date | NaN | 'undefined' | false |
537 | NaN | Invalid Date | NaN | 'NaN' | false |
538
539 Notes:
540
541 - as before, arguments expected to be `Date` are converted to `Date` using _date-fns'_ `toDate` function;
542 - arguments expected to be numbers are converted to integer numbers using our custom `toInteger` implementation
543 (see [#765](https://github.com/date-fns/date-fns/pull/765));
544 - arguments expected to be strings are converted to strings using JavaScript's `String` function;
545 - arguments expected to be booleans are converted to boolean using JavaScript's `Boolean` function.
546
547 `null` and `undefined` passed to optional arguments (i.e. properties of `options` argument)
548 are ignored as if no argument was passed.
549
550 If any resulting argument is invalid (i.e. `NaN` for numbers and `Invalid Date` for dates),
551 an invalid value will be returned:
552
553 - `false` for functions that return booleans (expect `isValid`);
554 - `Invalid Date` for functions that return dates;
555 - and `NaN` for functions that return numbers.
556
557 See tests and PRs [#460](https://github.com/date-fns/date-fns/pull/460) and
558 [#765](https://github.com/date-fns/date-fns/pull/765) for exact behavior.
559
560- **BREAKING**: all functions now check if the passed number of arguments is less
561 than the number of required arguments and throw `TypeError` exception if so.
562
563- **BREAKING**: The Bower & UMD/CDN package versions are no longer supported.
564
565- **BREAKING**: `null` now is not a valid date. `isValid(null)` returns `false`;
566 `toDate(null)` returns an invalid date. Since `toDate` is used internally
567 by all the functions, operations over `null` will also return an invalid date.
568 [See #537](https://github.com/date-fns/date-fns/issues/537) for the reasoning.
569
570- `toDate` (previously `parse`) and `isValid` functions now accept `any` type
571 as the first argument.
572
573- [Exclude `docs.json` from the npm package](https://github.com/date-fns/date-fns/pull/837). Kudos to [@hawkrives](https://github.com/hawkrives).
574
575### Added
576
577- FP functions like those in [lodash](https://github.com/lodash/lodash/wiki/FP-Guide),
578 that support [currying](https://en.wikipedia.org/wiki/Currying), and, as a consequence,
579 functional-style [function composing](https://medium.com/making-internets/why-using-chain-is-a-mistake-9bc1f80d51ba).
580
581 Functions with options (`format`, `parse`, etc.) have two FP counterparts:
582 one that has the options object as its first argument and one that hasn't.
583 The name of the former has `WithOptions` added to the end of its name.
584
585 In FP functions, the order of arguments is reversed.
586
587 See [FP Guide](docs/fp) for more information.
588
589 ```javascript
590 import addYears from 'date-fns/fp/addYears'
591 import formatWithOptions from 'date-fns/fp/formatWithOptions'
592 import eo from 'date-fns/locale/eo'
593
594 // If FP function has not received enough arguments, it returns another function
595 const addFiveYears = addYears(5)
596
597 // Several arguments can be curried at once
598 const dateToString = formatWithOptions({ locale: eo }, 'd MMMM yyyy')
599
600 const dates = [
601 new Date(2017, 0 /* Jan */, 1),
602 new Date(2017, 1 /* Feb */, 11),
603 new Date(2017, 6 /* Jul */, 2)
604 ]
605
606 const formattedDates = dates.map(date => dateToString(addFiveYears(date)))
607 //=> ['1 januaro 2022', '11 februaro 2022', '2 julio 2022']
608 ```
609
610- Added support for [ECMAScript Modules](http://www.ecma-international.org/ecma-262/6.0/#sec-modules).
611
612 It allows usage with bundlers that support tree-shaking,
613 like [rollup.js](http://rollupjs.org) and [webpack](https://webpack.js.org):
614
615 ```javascript
616 // Without tree-shaking:
617 import format from 'date-fns/format'
618 import parse from 'date-fns/parse'
619
620 // With tree-shaking:
621 import { format, parse } from 'date-fns'
622 ```
623
624 Also, ESM functions provide default export, they can be used with TypeScript
625 to import functions in more idiomatic way:
626
627 ```typescript
628 // Before
629 import * as format from 'date-fns/format'
630
631 // Now
632 import format from 'date-fns/format'
633 ```
634
635- `formatRelative` function. See [formatRelative](https://date-fns.org/docs/formatRelative)
636
637- Flow typings for `index.js`, `fp/index.js`, `locale/index.js`, and their ESM equivalents.
638 See PR [#558](https://github.com/date-fns/date-fns/pull/558)
639
640- New locale-dependent week-numbering year helpers:
641
642 - `getWeek`
643
644 - `getWeekYear`
645
646 - `setWeek`
647
648 - `setWeekYear`
649
650 - `startOfWeekYear`
651
652- Added `eachWeekOfInterval`, the weekly equivalent of `eachDayOfInterval`
653
654- [Added `getUnixTime` function](https://github.com/date-fns/date-fns/pull/870). Kudos to [@Kingwl](https://github.com/Kingwl).
655
656- [New decade helpers](https://github.com/date-fns/date-fns/pull/839). Thanks to [@y-nk](https://github.com/y-nk)!
657
658 - `getDecade`
659
660 - `startOfDecade`
661
662 - `endOfDecade`
663
664 - `lastDayOfDecade`
665
666- [New `roundToNearestMinutes` function](https://github.com/date-fns/date-fns/pull/928). Kudos to [@xkizer](https://github.com/xkizer).
667
668- Added new function `fromUnixTime`. Thansk to [@xkizer](https://github.com/xkizer).
669
670- New interval, month, and year helpers to fetch a list of all Saturdays and Sundays (weekends) for a given date interval. `eachWeekendOfInterval` is the handler function while the other two are wrapper functions. Kudos to [@laekettavong](https://github.com/laekettavong)!
671
672 - `eachWeekendOfInterval`
673
674 - `eachWeekendOfMonth`
675
676 - `eachWeekendOfYear`
677
678- Build-efficient `lightFormat` that only supports the popular subset of tokens. See [#1050](https://github.com/date-fns/date-fns/pull/1015).
679
680- `parseISO` function that parses ISO 8601 strings. See [#1023](https://github.com/date-fns/date-fns/pull/1023).
681
682- Add constants that can be imported directly from `date-fns` or the submodule `date-fns/constants`:
683
684 - `maxTime`
685
686 - `minTime`
687
688- New locales:
689
690 - [Norwegian Nynorsk locale (nn)](https://github.com/date-fns/date-fns/pull/1172)
691 by [@draperunner](https://github.com/draperunner).
692
693 - [Ukrainian locale (ua)](https://github.com/date-fns/date-fns/pull/532)
694 by [@korzhyk](https://github.com/korzhyk).
695
696 - [Vietnamese locale (vi)](https://github.com/date-fns/date-fns/pull/546)
697 by [@trongthanh](https://github.com/trongthanh).
698
699 - [Persian locale (fa-IR)](https://github.com/date-fns/date-fns/pull/1113)
700 by [@mort3za](https://github.com/mort3za).
701
702 - [Latvian locale (lv)](https://github.com/date-fns/date-fns/pull/1175)
703 by [@prudolfs](https://github.com/prudolfs).
704
705 - [Bengali locale (bb)](https://github.com/date-fns/date-fns/pull/845)
706 by [@nutboltu](https://github.com/nutboltu) and [@touhidrahman](https://github.com/touhidrahman).
707
708 - [Hungarian (hu) and Lithuanian (lt) locales](https://github.com/date-fns/date-fns/pull/864)
709 by [@izifortune](https://github.com/izifortune) and [pardoeryanair](https://github.com/pardoeryanair).
710
711 - [Canadian English locale (en-CA)](https://github.com/date-fns/date-fns/pull/688)
712 by [@markowsiak](https://github.com/markowsiak).
713
714 - [Great Britain English locale (en-GB)](https://github.com/date-fns/date-fns/pull/563)
715 by [@glintik](https://github.com/glintik).
716
717 - [Uighur locale (ug)](https://github.com/date-fns/date-fns/pull/1080)
718 by [@abduwaly](https://github.com/abduwaly).
719
720- [Add new function `differenceInBusinessDays`](https://github.com/date-fns/date-fns/pull/1194)
721 which calculates the difference in business days. Kudos to [@ThorrStevens](https://github.com/ThorrStevens)!
722
723- [Add new function `addBusinessDays`](https://github.com/date-fns/date-fns/pull/1154),
724 similar to `addDays` but ignoring weekends. Thanks to [@ThorrStevens](https://github.com/ThorrStevens)!
725
726## [1.30.1] - 2018-12-10
727
728### Fixed
729
730- [Fixed DST issue](https://github.com/date-fns/date-fns/pull/1005). See [#972](https://github.com/date-fns/date-fns/issues/972) and [#992](https://github.com/date-fns/date-fns/issues/992) for more details. This fix was backported from v2.
731
732- Fix a few bugs that appear in timezones with offsets that include seconds (e.g. GMT+00:57:44). See PR [#789](https://github.com/date-fns/date-fns/issues/789). This fix was backported from v2.
733
734- [Fix misspelled January in the Thai locale](https://github.com/date-fns/date-fns/pull/913). Thanks to [@ratchapol-an](https://github.com/ratchapol-an)!
735
736### Added
737
738- [Added Serbian locale](https://github.com/date-fns/date-fns/pull/717). Kudos to [@mawi12345](https://github.com/mawi12345)!
739
740- [Added Belarusian locale](https://github.com/date-fns/date-fns/pull/716). Kudos to [@mawi12345](https://github.com/mawi12345) again!
741
742### Changed
743
744- [Improve ja translation of distanceInWords](https://github.com/date-fns/date-fns/pull/880). Thanks to [@kudohamu](https://github.com/kudohamu)!
745
746## [1.30.0] - 2018-12-10
747
748⚠️ The release got failed.
749
750## [1.29.0] - 2017-10-11
751
752### Fixed
753
754- Fix Italian translations for `formatDistance`. ([see the issue: #550](https://github.com/date-fns/date-fns/issues/550); [see the PR: #552](https://github.com/date-fns/date-fns/pull/552))
755 Thanks to [@giofilo](https://github.com/giofilo)!
756
757### Added
758
759- [Hungarian locale (hu)](https://github.com/date-fns/date-fns/pull/503)
760 (thanks to László Horváth [@horvathlg](https://github.com/horvathlg))
761
762- [Slovenian locale (sl)](https://github.com/date-fns/date-fns/pull/505)
763 (thanks to Adam Stradovnik [@Neoglyph](https://github.com/Neoglyph))
764
765- Add `step` to `eachDay` function. Thanks to [@BDav24](https://github.com/BDav24).
766 See PR [#487](https://github.com/date-fns/date-fns/pull/487).
767
768## [1.28.5] - 2017-05-19
769
770### Fixed
771
772- Fix a.m./p.m. formatters in Chinese Simplified locale.
773 Thanks to [@fnlctrl](https://github.com/fnlctrl).
774 See PR [#486](https://github.com/date-fns/date-fns/pull/486)
775
776## [1.28.4] - 2017-04-26
777
778### Fixed
779
780- Fix accents on weekdays in the Italian locale.
781 See PR [#481](https://github.com/date-fns/date-fns/pull/481).
782 Thanks to [@albertorestifo](https://github.com/albertorestifo)
783
784- Fix typo in `ddd` format token in Spanish language locale.
785 Kudos to [@fjaguero](https://github.com/fjaguero).
786 See PR [#482](https://github.com/date-fns/date-fns/pull/482)
787
788## [1.28.3] - 2017-04-14
789
790### Fixed
791
792- Fix ordinal numbers for Danish language locale. Thanks to [@kgram](https://github.com/kgram).
793 See PR [#474](https://github.com/date-fns/date-fns/pull/474)
794
795## [1.28.2] - 2017-03-27
796
797### Fixed
798
799- Fix `dd` and `ddd` formatters in Polish language locale. Kudos to [@justrag](https://github.com/justrag).
800 See PR: [#467](https://github.com/date-fns/date-fns/pull/467)
801
802## [1.28.1] - 2017-03-19
803
804### Fixed
805
806- Fix DST border bug in `addMilliseconds`, `addSeconds`, `addMinutes`, `addHours`,
807 `subMilliseconds`, `subSeconds`, `subMinutes` and `subHours`.
808 See issue [#465](https://github.com/date-fns/date-fns/issues/465)
809
810- Minor fix for Indonesian locale. Thanks to [@bentinata](https://github.com/bentinata).
811 See PR: [#458](https://github.com/date-fns/date-fns/pull/458)
812
813## [1.28.0] - 2017-02-27
814
815### Added
816
817- [Romanian locale (ro)](https://github.com/date-fns/date-fns/pull/446)
818 (thanks to Sergiu Munteanu [@jsergiu](https://github.com/jsergiu))
819
820### Fixed
821
822- All functions now convert all their arguments to the respective types.
823 See PR: [#443](https://github.com/date-fns/date-fns/pull/443)
824
825- Fixes for ordinals (1er, 2, 3, …) in French locale.
826 Thanks to [@fbonzon](https://github.com/fbonzon).
827 See PR: [#449](https://github.com/date-fns/date-fns/pull/449)
828
829## [1.27.2] - 2017-02-01
830
831### Fixed
832
833- Various fixes for Dutch locale. See PR: [#416](https://github.com/date-fns/date-fns/pull/416).
834 Thanks to Ruben Stolk [@rubenstolk](https://github.com/rubenstolk)
835
836## [1.27.1] - 2017-01-20
837
838### Fixed
839
840- Added generation of TypeScript locale sub-modules, allowing import of locales in TypeScript.
841
842## [1.27.0] - 2017-01-19
843
844### Added
845
846- [Macedonian locale (mk)](https://github.com/date-fns/date-fns/pull/398)
847 (thanks to Petar Vlahu [@vlahupetar](https://github.com/vlahupetar))
848
849## [1.26.0] - 2017-01-15
850
851### Added
852
853- `getTime`
854
855### Fixed
856
857- Various fixes for Japanese locale. See PR: [395](https://github.com/date-fns/date-fns/pull/395).
858 Thanks to Yamagishi Kazutoshi [@ykzts](https://github.com/ykzts)
859
860## [1.25.0] - 2017-01-11
861
862### Added
863
864- [Bulgarian locale (bg)](https://github.com/date-fns/date-fns/pull/357)
865 (thanks to Nikolay Stoynov [@arvigeus](https://github.com/arvigeus))
866
867- [Czech locale (cs)](https://github.com/date-fns/date-fns/pull/386)
868 (thanks to David Rus [@davidrus](https://github.com/davidrus))
869
870## [1.24.0] - 2017-01-06
871
872### Added
873
874- [Modern Standard Arabic locale (ar)](https://github.com/date-fns/date-fns/pull/367)
875 (thanks to Abdallah Hassan [@AbdallahAHO](https://github.com/AbdallahAHO))
876
877## [1.23.0] - 2017-01-05
878
879### Added
880
881- Auto generate TypeScript and flow typings from documentation on release.
882 Thanks to [@mattlewis92](https://github.com/mattlewis92).
883 See related PRs: [#355](https://github.com/date-fns/date-fns/pull/355),
884 [#370](https://github.com/date-fns/date-fns/pull/370)
885
886- [Croatian locale (hr)](https://github.com/date-fns/date-fns/pull/365)
887 (thanks to Matija Marohnić [@silvenon](https://github.com/silvenon))
888
889- [Thai locale (th)](https://github.com/date-fns/date-fns/pull/362)
890 (thanks to Athiwat Hirunworawongkun [@athivvat](https://github.com/athivvat))
891
892- [Finnish locale (fi)](https://github.com/date-fns/date-fns/pull/361)
893 (thanks to Pyry-Samuli Lahti [@Pyppe](https://github.com/Pyppe))
894
895## [1.22.0] - 2016-12-28
896
897### Added
898
899- [Icelandic locale (is)](https://github.com/date-fns/date-fns/pull/356)
900 (thanks to Derek Blank [@derekblank](https://github.com/derekblank))
901
902## [1.21.1] - 2016-12-18
903
904### Fixed
905
906- Fix `isBefore` and `isAfter` documentation mistakes.
907
908## [1.21.0] - 2016-12-16
909
910### Added
911
912- [Filipino locale (fil)](https://github.com/date-fns/date-fns/pull/339)
913 (thanks to Ian De La Cruz [@RIanDeLaCruz](https://github.com/RIanDeLaCruz))
914
915- [Danish locale (da)](https://github.com/date-fns/date-fns/pull/343)
916 (kudos to Anders B. Hansen [@Andersbiha](https://github.com/Andersbiha))
917
918## [1.20.1] - 2016-12-14
919
920### Fixed
921
922- Fix documentation for `getOverlappingDaysInRanges`.
923
924## [1.20.0] - 2016-12-13
925
926### Added
927
928- `areRangesOverlapping` and `getOverlappingDaysInRanges`
929 Thanks to Joanna T [@asia-t](https://github.com/asia-t).
930 See PR: [#331](https://github.com/date-fns/date-fns/pull/331)
931
932## [1.19.0] - 2016-12-13
933
934### Added
935
936- [Greek locale (el)](https://github.com/date-fns/date-fns/pull/334)
937 (kudos to Theodoros Orfanidis [@teoulas](https://github.com/teoulas))
938
939- [Slovak locale (sk)](https://github.com/date-fns/date-fns/pull/336)
940 (kudos to Marek Suscak [@mareksuscak](https://github.com/mareksuscak))
941
942- Add yarn support.
943 Thanks to Uladzimir Havenchyk [@havenchyk](https://github.com/havenchyk).
944 See PR: [#288](https://github.com/date-fns/date-fns/pull/288)
945
946## [1.18.0] - 2016-12-12
947
948### Added
949
950- [Turkish locale (tr)](https://github.com/date-fns/date-fns/pull/329)
951 (kudos to Alpcan Aydın [@alpcanaydin](https://github.com/alpcanaydin))
952
953- [Korean locale (ko)](https://github.com/date-fns/date-fns/pull/327)
954 (thanks to Hong Chulju [@angdev](https://github.com/angdev))
955
956### Fixed
957
958- `SS` and `SSS` formats in `format` are now correctly displayed with leading zeros.
959 Thanks to Paul Dijou [@pauldijou](https://github.com/pauldijou).
960 See PR: [#330](https://github.com/date-fns/date-fns/pull/330)
961
962## [1.17.0] - 2016-12-10
963
964### Added
965
966- [Polish locale (pl)](https://github.com/date-fns/date-fns/pull/294)
967 (thanks to Mateusz Derks [@ertrzyiks](https://github.com/ertrzyiks))
968
969- [Portuguese locale (pt)](https://github.com/date-fns/date-fns/pull/316)
970 (thanks to Dário Freire [@dfreire](https://github.com/dfreire))
971
972- [Swedish locale (sv)](https://github.com/date-fns/date-fns/pull/311)
973 (thanks to Johannes Ulén [@ejulen](https://github.com/ejulen))
974
975- [French locale (fr)](https://github.com/date-fns/date-fns/pull/281)
976 (thanks to Jean Dupouy [@izeau](https://github.com/izeau))
977
978- Performance tests. See PR: [#289](https://github.com/date-fns/date-fns/pull/289)
979
980### Fixed
981
982- Fix TypeScript and flow typings for `isValid`.
983 See PR: [#310](https://github.com/date-fns/date-fns/pull/310)
984
985- Fix incorrect locale tests that could potentially lead to `format` bugs.
986 Kudos to Mateusz Derks [@ertrzyiks](https://github.com/ertrzyiks).
987 See related PRs: [#312](https://github.com/date-fns/date-fns/pull/312),
988 [#320](https://github.com/date-fns/date-fns/pull/320)
989
990- Minor language fixes in the documentation.
991 Thanks to Vedad Šoše [@vedadsose](https://github.com/vedadsose) ([#314](https://github.com/date-fns/date-fns/pull/314))
992 and Asia [@asia-t](https://github.com/asia-t) ([#318](https://github.com/date-fns/date-fns/pull/318))
993
994### Changed
995
996- `format` now returns `String('Invalid Date')` if the passed date is invalid.
997 See PR: [#323](https://github.com/date-fns/date-fns/pull/323)
998
999- `distanceInWords`, `distanceInWordsToNow`, `distanceInWordsStrict` and `format` functions now
1000 check if the passed locale is valid, and fallback to English locale otherwise.
1001 See PR: [#321](https://github.com/date-fns/date-fns/pull/321)
1002
1003- _Internal_: use a loop instead of `Object.keys` in `buildFormattingTokensRegExp`
1004 to improve compatibility with older browsers.
1005 See PR: [#322](https://github.com/date-fns/date-fns/pull/322)
1006
1007## [1.16.0] - 2016-12-08
1008
1009### Added
1010
1011- [Italian locale (it)](https://github.com/date-fns/date-fns/pull/298)
1012 (thanks to Alberto Restifo [@albertorestifo](https://github.com/albertorestifo))
1013
1014- For German `buildDistanceInWordsLocale`, add nominative case translations (for distances without a suffix).
1015 Kudos to Asia [@asia-t](https://github.com/asia-t).
1016 See related PR: [#295](https://github.com/date-fns/date-fns/pull/295)
1017
1018## [1.15.1] - 2016-12-07
1019
1020### Fixed
1021
1022- Fixed TypeScript imports from individual modules.
1023 Thanks to [@mattlewis92](https://github.com/mattlewis92).
1024 See related PR: [#287](https://github.com/date-fns/date-fns/pull/287)
1025
1026## [1.15.0] - 2016-12-07
1027
1028### Added
1029
1030- [Indonesian locale (id)](https://github.com/date-fns/date-fns/pull/299)
1031 (thanks to Rahmat Budiharso [@rbudiharso](https://github.com/rbudiharso))
1032
1033- [Catalan locale (ca)](https://github.com/date-fns/date-fns/pull/300)
1034 (thanks to Guillermo Grau [@guigrpa](https://github.com/guigrpa))
1035
1036### Fixed
1037
1038- Fix some inaccuracies in Spanish locale.
1039 Kudos to [@guigrpa](https://github.com/guigrpa).
1040 See related PR: [#302](https://github.com/date-fns/date-fns/pull/302)
1041
1042## [1.14.1] - 2016-12-06
1043
1044### Fixed
1045
1046- Fixed broken test for Norwegian Bokmål locale.
1047
1048## [1.14.0] - 2016-12-06
1049
1050### Added
1051
1052- [Norwegian Bokmål locale (nb)](https://github.com/date-fns/date-fns/pull/291)
1053 (thanks to Hans-Kristian Koren [@Hanse](https://github.com/Hanse))
1054
1055## [1.13.0] - 2016-12-06
1056
1057### Added
1058
1059- [Chinese Traditional locale (zh_tw)](https://github.com/date-fns/date-fns/pull/283)
1060 (thanks to tonypai [@tpai](https://github.com/tpai)).
1061
1062- [Dutch language locale (nl)](https://github.com/date-fns/date-fns/pull/278)
1063 (kudos to Jorik Tangelder [@jtangelder](https://github.com/jtangelder))
1064
1065## [1.12.1] - 2016-12-05
1066
1067### Fixed
1068
1069- Added `distanceInWordsStrict` to the list of supported functions in I18n doc.
1070
1071## [1.12.0] - 2016-12-05
1072
1073### Added
1074
1075- [Spanish language locale (es)](https://github.com/date-fns/date-fns/pull/269)
1076 (thanks to Juan Angosto [@juanangosto](https://github.com/juanangosto)).
1077
1078### Fixed
1079
1080- Fix flow typings for some of the functions.
1081 See PR: [#273](https://github.com/date-fns/date-fns/pull/273)
1082
1083## [1.11.2] - 2016-11-28
1084
1085### Fixed
1086
1087- Bug in `parse` when it sometimes parses ISO week-numbering dates incorrectly.
1088 See PR: [#262](https://github.com/date-fns/date-fns/pull/262)
1089
1090- Bug in some functions which caused them to handle dates earlier than 100 AD incorrectly.
1091 See PR: [#263](https://github.com/date-fns/date-fns/pull/263)
1092
1093## [1.11.1] - 2016-11-24
1094
1095### Fixed
1096
1097- Include TypeScript typings with npm package.
1098
1099## [1.11.0] - 2016-11-23
1100
1101### Added
1102
1103- `distanceInWordsStrict`.
1104 Kudos to [@STRML](https://github.com/STRML).
1105 See related PR: [#254](https://github.com/date-fns/date-fns/pull/254)
1106
1107- [TypeScript](https://www.typescriptlang.org/) typings for all functions.
1108 Kudos to [@mattlewis92](https://github.com/mattlewis92).
1109 See related PR: [#255](https://github.com/date-fns/date-fns/pull/255)
1110
1111## [1.10.0] - 2016-11-01
1112
1113### Added
1114
1115- `parse` now can parse dates that are ISO 8601 centuries (e.g., `19` and `+0019`).
1116
1117 ```javascript
1118 var result = parse('19')
1119 //=> Mon Jan 01 1900 00:00:00
1120 ```
1121
1122- In `parse`, added ability to specify the number of additional digits
1123 for extended year or century format (possible values are 0, 1 or 2; default is 2).
1124
1125 ```javascript
1126 parse('+002016-11-01')
1127 parse('+02016-11-01', { additionalDigits: 1 })
1128 parse('+2016-11-01', { additionalDigits: 0 })
1129 ```
1130
1131## [1.9.0] - 2016-10-25
1132
1133### Added
1134
1135- Got index.js imports to work with SystemJS.
1136
1137## [1.8.1] - 2016-10-24
1138
1139### Fixed
1140
1141- Added Japanese and German language locales to the list in I18n doc.
1142
1143## [1.8.0] - 2016-10-23
1144
1145### Added
1146
1147- [Japanese language locale (ja)](https://github.com/date-fns/date-fns/pull/241)
1148 (thanks to Thomas Eilmsteiner [@DeMuu](https://github.com/DeMuu) again!)
1149
1150- `getISODay`
1151
1152- `setISODay`
1153
1154## [1.7.0] - 2016-10-20
1155
1156### Added
1157
1158- [German language locale (de)](https://github.com/date-fns/date-fns/pull/237)
1159 (thanks to Thomas Eilmsteiner [@DeMuu](https://github.com/DeMuu)).
1160
1161## [1.6.0] - 2016-10-16
1162
1163### Added
1164
1165- [Chinese Simplified locale (zh_cn)](https://github.com/date-fns/date-fns/pull/235)
1166 (kudos to Changyu [@KingMario](https://github.com/KingMario) Geng).
1167
1168## [1.5.2] - 2016-10-13
1169
1170### Fixed
1171
1172- Incorrectly generated docs for `format`.
1173
1174- Fixed typo in I18n doc.
1175
1176## [1.5.1] - 2016-10-12
1177
1178### Fixed
1179
1180- A change log entry for [1.5.0] is added.
1181
1182## [1.5.0] - 2016-10-12
1183
1184### Added
1185
1186- [The initial I18n support](https://date-fns.org/docs/I18n)
1187
1188## [1.4.0] - 2016-10-09
1189
1190### Added
1191
1192- Basic [SystemJS](https://github.com/systemjs/systemjs) support.
1193
1194### Fixed
1195
1196- Fix incorrect behaviour of `YYYY` and `YY` for years prior to 1000:
1197 now `format(new Date('0001-01-01'), 'YYYY-MM-DD')` returns `0001-01-01`
1198 instead of `1-01-01`.
1199
1200## [1.3.0] - 2016-05-26
1201
1202### Added
1203
1204- `closestIndexTo`
1205
1206## [1.2.0] - 2016-05-23
1207
1208### Added
1209
1210- Add an ability to pass negative numbers to `setDay`.
1211
1212## [1.1.1] - 2016-05-19
1213
1214### Fixed
1215
1216- Fix [Flow](http://flowtype.org/) declarations for some of the functions.
1217
1218## [1.1.0] - 2016-05-19
1219
1220### Added
1221
1222- [Flow](http://flowtype.org/) declarations for each function
1223 in [the ".js.flow" style](http://flowtype.org/docs/declarations.html#declaration-files).
1224 Kudos to [@JohnyDays](https://github.com/JohnyDays). See related PRs:
1225
1226 - [#205](https://github.com/date-fns/date-fns/pull/205)
1227
1228 - [#207](https://github.com/date-fns/date-fns/pull/207)
1229
1230## [1.0.0] - 2016-05-18
1231
1232### Fixed
1233
1234- `format` now returns the correct result for key `E`.
1235
1236- Prevent `startOf...`, `endOf...` and `lastDayOf...` functions
1237 to return dates with an incorrect time when the date is modifying
1238 into another time zone.
1239
1240- `parse` now parses years from 1 AD to 99 AD correctly.
1241
1242- Fix a bug in `getISOWeek` appearing because of a changing time zone
1243 (e.g., when the given date is in DST and the start of the ISO year is not).
1244
1245### Changed
1246
1247- **BREAKING**: all functions are moved to the root of the library, so they
1248 are now accessible with `require('date-fns/name_of_function')` or
1249 `import nameOfFunction from 'date-fns/name_of_function'`.
1250
1251 ```javascript
1252 // Before v1.0.0
1253 var addMonths = require('date-fns/src/add_months')
1254
1255 // v1.0.0 onward
1256 var addMonths = require('date-fns/add_months')
1257 ```
1258
1259- **BREAKING**: functions that had the last optional argument `weekStartsAt`
1260 (i.e. `endOfWeek`, `isSameWeek`, `lastDayOfWeek`, `setDay`, `startOfWeek`)
1261 now instead receive the object `options` with the property `options.weekStartsOn`
1262 as the last argument.
1263
1264 ```javascript
1265 // Before v1.0.0
1266 var result = endOfWeek(new Date(2014, 8, 2), 1)
1267
1268 // v1.0.0 onward
1269 var result = endOfWeek(new Date(2014, 8, 2), { weekStartsOn: 1 })
1270 ```
1271
1272- **BREAKING**: remove the function `getTimeSinceMidnight` that was used inside
1273 the other functions.
1274
1275- **BREAKING**: `differenceInDays` now returns the number of full days instead
1276 of calendar days.
1277
1278- **BREAKING**: `eachDay` and `isWithinRange` now throw an exception
1279 when the given range boundaries are invalid.
1280
1281- Faster `isLeapYear`.
1282
1283- _Internal_: make the documentation more verbose.
1284
1285- _Internal_: convert the tests from Chai to power-assert allowing them
1286 to run against IE8.
1287
1288### Added
1289
1290- `addISOYears`
1291
1292- `closestTo`
1293
1294- `differenceInCalendarDays`
1295
1296- `differenceInCalendarISOWeeks`
1297
1298- `differenceInCalendarISOYears`
1299
1300- `differenceInCalendarMonths`
1301
1302- `differenceInCalendarQuarters`
1303
1304- `differenceInCalendarWeeks`
1305
1306- `differenceInCalendarYears`
1307
1308- `differenceInHours`
1309
1310- `differenceInISOYears`
1311
1312- `differenceInMilliseconds`
1313
1314- `differenceInMinutes`
1315
1316- `differenceInMonths`
1317
1318- `differenceInQuarters`
1319
1320- `differenceInSeconds`
1321
1322- `differenceInWeeks`
1323
1324- `differenceInYears`
1325
1326- `distanceInWords`
1327
1328- `distanceInWordsToNow`
1329
1330- `endOfISOWeek`
1331
1332- `endOfISOYear`
1333
1334- `endOfToday`
1335
1336- `endOfTomorrow`
1337
1338- `endOfYesterday`
1339
1340- `getDaysInYear`
1341
1342- `isDate`
1343
1344- `isFriday`
1345
1346- `isMonday`
1347
1348- `isSameISOWeek`
1349
1350- `isSameISOYear`
1351
1352- `isSaturday`
1353
1354- `isSunday`
1355
1356- `isThisHour`
1357
1358- `isThisISOWeek`
1359
1360- `isThisISOYear`
1361
1362- `isThisMinute`
1363
1364- `isThisMonth`
1365
1366- `isThisQuarter`
1367
1368- `isThisSecond`
1369
1370- `isThisWeek`
1371
1372- `isThisYear`
1373
1374- `isThursday`
1375
1376- `isTomorrow`
1377
1378- `isTuesday`
1379
1380- `isValid`
1381
1382- `isWednesday`
1383
1384- `isYesterday`
1385
1386- `lastDayOfISOWeek`
1387
1388- `lastDayOfISOYear`
1389
1390- `startOfISOWeek`
1391
1392- `startOfToday`
1393
1394- `startOfTomorrow`
1395
1396- `startOfYesterday`
1397
1398- `subISOYears`
1399
1400- Add `Qo`, `W`, `Wo`, `WW`, `GG`, `GGGG`, `Z`, `ZZ`, `X`, `x` keys to `format`.
1401
1402## [0.17.0] - 2015-09-29
1403
1404### Fixed
1405
1406- Fix a lot of bugs appearing when date is modifying into other time zone
1407 (e.g., when adding months and original date is in DST but new date is not).
1408
1409- Prevent instances of Date to lose milliseconds value when passed to.
1410 `parse` in IE10.
1411
1412### Changed
1413
1414- `setISOWeek` now keeps time from original date.
1415
1416- _Internal_: reuse `getDaysInMonth` inside of `addMonths`.
1417
1418### Added
1419
1420- `differenceInDays`
1421
1422- `getTimeSinceMidnight`
1423
1424- `format` now has new format key `aa`, which returns `a.m.`/`p.m.`
1425 as opposed to `a` that returns `am`/`pm`.
1426
1427- Complete UMD package (for Bower and CDN).
1428
1429## [0.16.0] - 2015-09-01
1430
1431### Changed
1432
1433- Use `parse` to clean date arguments in all functions.
1434
1435- `parse` now fallbacks to `new Date` when the argument
1436 is not an ISO formatted date.
1437
1438- _Internal_: reuse `getDaysInMonth` inside of `setMonth`.
1439
1440### Added
1441
1442- `addQuarters`
1443
1444- `addWeeks`
1445
1446- `endOfQuarter`
1447
1448- `getDate`
1449
1450- `getDay`
1451
1452- `getDaysInMonth`
1453
1454- `getHours`
1455
1456- `getISOWeeksInYear`
1457
1458- `getMilliseconds`
1459
1460- `getMinutes`
1461
1462- `getMonth`
1463
1464- `getSeconds`
1465
1466- `getYear`
1467
1468- `isLeapYear`
1469
1470- `isSameHour`
1471
1472- `isSameMinute`
1473
1474- `isSameQuarter`
1475
1476- `isSameSecond`
1477
1478- `lastDayOfQuarter`
1479
1480- `lastDayOfWeek`
1481
1482- `max`
1483
1484- `min`
1485
1486- `setDate`
1487
1488- `setDay`
1489
1490- `setHours`
1491
1492- `setMilliseconds`
1493
1494- `setMinutes`
1495
1496- `setSeconds`
1497
1498- `startOfQuarter`
1499
1500- `subQuarters`
1501
1502- `subWeeks`
1503
1504## [0.15.0] - 2015-08-26
1505
1506### Changed
1507
1508- `format` now returns `a.m.`/`p.m.` instead of `am`/`pm`.
1509
1510- `setMonth` now sets last day of month if original date was last day
1511 of longer month.
1512
1513- _Internal_: Fix code style according to ESLint.
1514
1515- _Internal_: Make tests run through all time zones.
1516
1517### Added
1518
1519- `getQuarter`
1520
1521- `setQuarter`
1522
1523- `getDayOfYear`
1524
1525- `setDayOfYear`
1526
1527- `isPast`
1528
1529- `addSeconds`
1530
1531- `subSeconds`
1532
1533- `startOfSecond`
1534
1535- `endOfSecond`
1536
1537- `startOfMinute`
1538
1539- `endOfMinute`
1540
1541- `addMilliseconds`
1542
1543- `subMilliseconds`
1544
1545- `endOfYear`
1546
1547- `addYears`
1548
1549- `subYears`
1550
1551- `lastDayOfYear`
1552
1553- `lastDayOfMonth`
1554
1555## [0.14.11] - 2015-08-21
1556
1557### Fixed
1558
1559- `format` now uses `parse` to avoid time zone bugs.
1560
1561### Changed
1562
1563- `setIsoWeek` now sets time to the start of the day.
1564
1565## [0.14.10] - 2015-07-29
1566
1567### Fixed
1568
1569- `format` now behaves correctly with 12:00 am.
1570
1571- `format` now behaves correctly with ordinal numbers.
1572
1573### Added
1574
1575- `compareAsc`
1576
1577- `compareDesc`
1578
1579- `addHours`
1580
1581- `subHours`
1582
1583- `isSameDay`
1584
1585- `parse`
1586
1587- `getISOYear`
1588
1589- `setISOYear`
1590
1591- `startOfISOYear`
1592
1593- `getISOWeek`
1594
1595- `setISOWeek`
1596
1597## [0.14.9] - 2015-01-14
1598
1599### Fixed
1600
1601- `addMonths` now correctly behaves with February
1602 (see [#18](https://github.com/js-fns/date-fns/pull/18)).
1603
1604## [0.14.8] - 2014-12-25
1605
1606### Fixed
1607
1608- `format` function now behaves correctly with `pm`/`am`.
1609
1610## [0.14.6] - 2014-12-04
1611
1612### Fixed
1613
1614- Fix broken Bower support.
1615
1616## [0.14.0] - 2014-11-05
1617
1618### Added
1619
1620- Bower package.
1621
1622## [0.13.0] - 2014-10-22
1623
1624### Added
1625
1626- `addMinutes`
1627
1628- `subMinutes`
1629
1630- `isEqual`
1631
1632- `isBefore`
1633
1634- `isAfter`
1635
1636## [0.12.1] - 2014-10-19
1637
1638### Fixed
1639
1640- Incorrect rounding in `DDD` formatter.
1641
1642## [0.12.0] - 2014-10-15
1643
1644### Added
1645
1646- `isSameYear`
1647
1648## [0.11.0] - 2014-10-15
1649
1650### Added
1651
1652- `isWithinRange`
1653
1654## [0.10.0] - 2014-10-13
1655
1656### Added
1657
1658- `format`
1659
1660- `startOfYear`
1661
1662## [0.9.0] - 2014-10-10
1663
1664### Changed
1665
1666- _Internal_: simplify `isWeekend`
1667
1668### Added
1669
1670- `isFuture`
1671
1672## [0.8.0] - 2014-10-09
1673
1674### Changed
1675
1676- _Internal_: reuse `addDays` inside of `subDays`.
1677
1678### Added
1679
1680- `addMonths`
1681
1682- `subMonths`
1683
1684- `setMonth`
1685
1686- `setYear`
1687
1688## [0.7.0] - 2014-10-08
1689
1690### Added
1691
1692- `isSameWeek`
1693
1694## [0.6.0] - 2014-10-07
1695
1696### Fixed
1697
1698- Inconsistent behavior of `endOfMonth`.
1699
1700### Added
1701
1702- `isFirstDayOfMonth`
1703
1704- `isLastDayOfMonth`
1705
1706- `isSameMonth`
1707
1708## [0.5.0] - 2014-10-07
1709
1710### Added
1711
1712- `addDays`
1713
1714- `subDays`
1715
1716## [0.4.0] - 2014-10-07
1717
1718### Added
1719
1720- `startOfWeek`
1721
1722- `endOfWeek`
1723
1724- `eachDay`
1725
1726## [0.3.0] - 2014-10-06
1727
1728### Changed
1729
1730- `startOfDay` now sets milliseconds as well.
1731
1732### Added
1733
1734- `endOfDay`
1735
1736- `startOfMonth`
1737
1738- `endOfMonth`
1739
1740## [0.2.0] - 2014-10-06
1741
1742### Added
1743
1744- `isToday`
1745
1746- `isWeekend`
1747
1748## 0.1.0 - 2014-10-06
1749
1750### Added
1751
1752- `startOfDay`
1753
1754[unreleased]: https://github.com/date-fns/date-fns/compare/v2.0.1...HEAD
1755[2.0.1]: https://github.com/date-fns/date-fns/compare/v2.0.0...v2.0.1
1756[2.0.0]: https://github.com/date-fns/date-fns/compare/v1.28.5...v2.0.0
1757[1.28.5]: https://github.com/date-fns/date-fns/compare/v1.28.4...v1.28.5
1758[1.28.4]: https://github.com/date-fns/date-fns/compare/v1.28.3...v1.28.4
1759[1.28.3]: https://github.com/date-fns/date-fns/compare/v1.28.2...v1.28.3
1760[1.28.2]: https://github.com/date-fns/date-fns/compare/v1.28.1...v1.28.2
1761[1.28.1]: https://github.com/date-fns/date-fns/compare/v1.28.0...v1.28.1
1762[1.28.0]: https://github.com/date-fns/date-fns/compare/v1.27.2...v1.28.0
1763[1.27.2]: https://github.com/date-fns/date-fns/compare/v1.27.1...v1.27.2
1764[1.27.1]: https://github.com/date-fns/date-fns/compare/v1.27.0...v1.27.1
1765[1.27.0]: https://github.com/date-fns/date-fns/compare/v1.26.0...v1.27.0
1766[1.26.0]: https://github.com/date-fns/date-fns/compare/v1.25.0...v1.26.0
1767[1.25.0]: https://github.com/date-fns/date-fns/compare/v1.24.0...v1.25.0
1768[1.24.0]: https://github.com/date-fns/date-fns/compare/v1.23.0...v1.24.0
1769[1.23.0]: https://github.com/date-fns/date-fns/compare/v1.22.0...v1.23.0
1770[1.22.0]: https://github.com/date-fns/date-fns/compare/v1.21.1...v1.22.0
1771[1.21.1]: https://github.com/date-fns/date-fns/compare/v1.21.0...v1.21.1
1772[1.21.0]: https://github.com/date-fns/date-fns/compare/v1.20.1...v1.21.0
1773[1.20.1]: https://github.com/date-fns/date-fns/compare/v1.20.0...v1.20.1
1774[1.20.0]: https://github.com/date-fns/date-fns/compare/v1.19.0...v1.20.0
1775[1.19.0]: https://github.com/date-fns/date-fns/compare/v1.18.0...v1.19.0
1776[1.18.0]: https://github.com/date-fns/date-fns/compare/v1.17.0...v1.18.0
1777[1.17.0]: https://github.com/date-fns/date-fns/compare/v1.16.0...v1.17.0
1778[1.16.0]: https://github.com/date-fns/date-fns/compare/v1.15.1...v1.16.0
1779[1.15.1]: https://github.com/date-fns/date-fns/compare/v1.15.0...v1.15.1
1780[1.15.0]: https://github.com/date-fns/date-fns/compare/v1.14.1...v1.15.0
1781[1.14.1]: https://github.com/date-fns/date-fns/compare/v1.14.0...v1.14.1
1782[1.14.0]: https://github.com/date-fns/date-fns/compare/v1.13.0...v1.14.0
1783[1.13.0]: https://github.com/date-fns/date-fns/compare/v1.12.1...v1.13.0
1784[1.12.1]: https://github.com/date-fns/date-fns/compare/v1.12.0...v1.12.1
1785[1.12.0]: https://github.com/date-fns/date-fns/compare/v1.11.2...v1.12.0
1786[1.11.2]: https://github.com/date-fns/date-fns/compare/v1.11.1...v1.11.2
1787[1.11.1]: https://github.com/date-fns/date-fns/compare/v1.11.0...v1.11.1
1788[1.11.0]: https://github.com/date-fns/date-fns/compare/v1.10.0...v1.11.0
1789[1.10.0]: https://github.com/date-fns/date-fns/compare/v1.9.0...v1.10.0
1790[1.9.0]: https://github.com/date-fns/date-fns/compare/v1.8.1...v1.9.0
1791[1.8.1]: https://github.com/date-fns/date-fns/compare/v1.8.0...v1.8.1
1792[1.8.0]: https://github.com/date-fns/date-fns/compare/v1.7.0...v1.8.0
1793[1.7.0]: https://github.com/date-fns/date-fns/compare/v1.6.0...v1.7.0
1794[1.6.0]: https://github.com/date-fns/date-fns/compare/v1.5.2...v1.6.0
1795[1.5.2]: https://github.com/date-fns/date-fns/compare/v1.5.1...v1.5.2
1796[1.5.1]: https://github.com/date-fns/date-fns/compare/v1.5.0...v1.5.1
1797[1.5.0]: https://github.com/date-fns/date-fns/compare/v1.4.0...v1.5.0
1798[1.4.0]: https://github.com/date-fns/date-fns/compare/v1.3.0...v1.4.0
1799[1.3.0]: https://github.com/date-fns/date-fns/compare/v1.2.0...v1.3.0
1800[1.2.0]: https://github.com/date-fns/date-fns/compare/v1.1.1...v1.2.0
1801[1.1.1]: https://github.com/date-fns/date-fns/compare/v1.1.0...v1.1.1
1802[1.1.0]: https://github.com/date-fns/date-fns/compare/v1.0.0...v1.1.0
1803[1.0.0]: https://github.com/date-fns/date-fns/compare/v0.17.0...v1.0.0
1804[0.17.0]: https://github.com/date-fns/date-fns/compare/v0.16.0...v0.17.0
1805[0.16.0]: https://github.com/date-fns/date-fns/compare/v0.15.0...v0.16.0
1806[0.15.0]: https://github.com/date-fns/date-fns/compare/v0.14.11...v0.15.0
1807[0.14.11]: https://github.com/date-fns/date-fns/compare/v0.14.10...v0.14.11
1808[0.14.10]: https://github.com/date-fns/date-fns/compare/v0.14.9...v0.14.10
1809[0.14.9]: https://github.com/date-fns/date-fns/compare/v0.14.8...v0.14.9
1810[0.14.8]: https://github.com/date-fns/date-fns/compare/v0.14.6...v0.14.8
1811[0.14.6]: https://github.com/date-fns/date-fns/compare/v0.14.0...v0.14.6
1812[0.14.0]: https://github.com/date-fns/date-fns/compare/v0.13.0...v0.14.0
1813[0.13.0]: https://github.com/date-fns/date-fns/compare/v0.12.1...v0.13.0
1814[0.12.1]: https://github.com/date-fns/date-fns/compare/v0.12.0...v0.12.1
1815[0.12.0]: https://github.com/date-fns/date-fns/compare/v0.11.0...v0.12.0
1816[0.11.0]: https://github.com/date-fns/date-fns/compare/v0.10.0...v0.11.0
1817[0.10.0]: https://github.com/date-fns/date-fns/compare/v0.9.0...v0.10.0
1818[0.9.0]: https://github.com/date-fns/date-fns/compare/v0.8.0...v0.9.0
1819[0.8.0]: https://github.com/date-fns/date-fns/compare/v0.7.0...v0.8.0
1820[0.7.0]: https://github.com/date-fns/date-fns/compare/v0.6.0...v0.7.0
1821[0.6.0]: https://github.com/date-fns/date-fns/compare/v0.5.0...v0.6.0
1822[0.5.0]: https://github.com/date-fns/date-fns/compare/v0.4.0...v0.5.0
1823[0.4.0]: https://github.com/date-fns/date-fns/compare/v0.3.0...v0.4.0
1824[0.3.0]: https://github.com/date-fns/date-fns/compare/v0.2.0...v0.3.0
1825[0.2.0]: https://github.com/date-fns/date-fns/compare/v0.1.0...v0.2.0
1826
\No newline at end of file