cozy-banks icon indicating copy to clipboard operation
cozy-banks copied to clipboard

deps: Upgrade date-fns to v2.29.3

Open taratatach opened this issue 2 years ago • 2 comments

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() and parse() 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 becomes yyyyD becomes dDD becomes ddddd becomes EEE → the escape character is now ' (single quote) instead of [
  • all date-fns functions now require arguments to be Date objects or numbers and do not accept strings anymore. Therefore, all date strings are now parsed before being passed as date-fns function arguments and all test data mocks have been updated to use only ISO formatted date strings
  • isWithinRange becomes isWithinInterval which is inclusive (i.e. isWithinRange(3, 1, 3) === false vs isWithinInterval(3, { start: 1, end: 3 }) === true)
### ✨ Features

*

### 🐛 Bug Fixes

*

### 🔧 Tech

* Upgrade `date-fns` to v2.29.3 and accommodate API changes.

taratatach avatar Oct 11 '22 10:10 taratatach

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.

taratatach avatar Oct 11 '22 12:10 taratatach

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/.

PolariTOON avatar Dec 08 '22 14:12 PolariTOON