When I first wrote this component, moment.js was the only good library to work with Date objects – but being its size so big I preferred to keep this package without depending on it (one of the reasons I made this component was that the available date picker were always requiring moment.js). But working with Date objects in javascript is not easy at all, and maintaining my own Dates manipulation library requires some effort.
Now we have date-fns: it is modular like lodash so I expect it that adopting it would not increase so much the size of this module. Adopting date-fns would have many benefits:
Similar discussion: https://github.com/airbnb/react-dates/issues/208
@gpbl can you make this time library agnositic, we migrated away from moment to js-joda.github.io and it has splendid support for all the date/time functions you will ever need. If somehow react-day-picker can be modular to support any time library, we would appreciate it.
@r-tock thanks for your feedback.
date-fns seems modular enough so it shouldn't add much weight to the final bundle. I'll do my tests to see how it works first, but it seems i can just replace the original utils with some of theirs.
So far there are two missing pieces from date-fns:
parse function in v2 will work with different locales as well.@gpbl hello, thank you for trying date-fns :-)
parse would work with different locales — as long as the locale is adjusted for parse and v2.We will release an alpha very soon. Stable version will be released after all locales are converted for v2.
Is there something I can do to help your library adopt date-fns?
@leshakoss thanks from dropping by and share the positive news. Eager to try the alpha version and see how it works with the component.
Another thing is that we may want to support UTC and date-fns still doesn't work with them. So, the initial idea to fix timezone issues with date-fns may not be right until that issue is closed as well.
Guys, your collaboration is pretty awesome 🔥
I'd love to see this happen.
Luxon is working great with UTC! Browser support is a bit iffy, depending on your needs.
An update. We are not going to use date-fns anymore, as the dependency from moment has been removed and users can adopt their own library to parse and format dates. Still I'd love to add an example to the docs :)
Most helpful comment
An update. We are not going to use
date-fnsanymore, as the dependency from moment has been removed and users can adopt their own library to parse and format dates. Still I'd love to add an example to the docs :)