-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: Upgrade date-fns to v2.29.3 #2522
base: master
Are you sure you want to change the base?
Conversation
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 accomodate 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 #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 `yyyy` → `D` becomes `d` → `DD` becomes `dd` → `ddd` 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`)
This PR is waiting for other libraries to upgrade |
import frLocale from 'date-fns/locale/fr' | ||
import enLocale from 'date-fns/locale/en' | ||
import esLocale from 'date-fns/locale/es' | ||
import { fr as frLocale, en as enLocale, es as esLocale } from 'date-fns/locale' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version of date-fns
does not export any en
locale anymore. You likely want enUS
instead.
We have a webpack config in this app that defines a |
We want to use the
add
andsub
functions that are not availablein v1.30.1.
Since there's a large gap between the two versions, we have a lot of
modifications to accommodate API changes:
changed from a snake case format to a camel case one
imported from
date-fns/locales
format()
andparse()
is now based on UnicodeTechnical 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[
date-fns
functions now require arguments to beDate
objectsor 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
becomesisWithinInterval
which is inclusive(i.e.
isWithinRange(3, 1, 3) === false
vsisWithinInterval(3, { start: 1, end: 3 }) === true
)