cozy-banks
cozy-banks copied to clipboard
deps: Upgrade date-fns to v2.29.3
We want to use the add
and sub
functions that are not available
in v1.30.1.
Since there's a large gap between the two versions, we have a lot of modifications to accommodate API changes:
- imports of functions whose names are made of multiple words have changed from a snake case format to a camel case one
- locales are not exposed as separate modules anymore; they need to be
imported from
date-fns/locales
- the format used by
format()
andparse()
is now based on Unicode Technical Standard n°35 (see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table) with a few additions (see https://date-fns.org/v2.29.3/docs/format) →YYYY
becomesyyyy
→D
becomesd
→DD
becomesdd
→ddd
becomesEEE
→ the escape character is now'
(single quote) instead of[
- all
date-fns
functions now require arguments to beDate
objects or numbers and do not accept strings anymore. Therefore, all date strings are now parsed before being passed asdate-fns
function arguments and all test data mocks have been updated to use only ISO formatted date strings -
isWithinRange
becomesisWithinInterval
which is inclusive (i.e.isWithinRange(3, 1, 3) === false
vsisWithinInterval(3, { start: 1, end: 3 }) === true
)
### ✨ Features
*
### 🐛 Bug Fixes
*
### 🔧 Tech
* Upgrade `date-fns` to v2.29.3 and accommodate API changes.
This PR is waiting for other libraries to upgrade date-fns
(e.g. cozy-ui) as we deduplicate libs and the new version of date-fns
is incompatible with the old one used in our own libs.
We have a webpack config in this app that defines a ContextReplacementPlugin
for date-fns
locales. The regexp should likely be changed from /(en|fr|es)\/index\.js/
to /(en-US|fr|es)\/index\.js/
.