Skip to content
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

Adopt date-fns to format and manipulate dates #342

Closed
gpbl opened this issue May 12, 2017 · 10 comments · Fixed by #687
Closed

Adopt date-fns to format and manipulate dates #342

gpbl opened this issue May 12, 2017 · 10 comments · Fixed by #687
Assignees

Comments

@gpbl
Copy link
Owner

gpbl commented May 12, 2017

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:

  • finally fix long standing issues with timezones for some edge cases (need UTC functions date-fns/date-fns#376 closed)
  • we won't need to change the date to 12AM to workaround such issues (need UTC functions date-fns/date-fns#376 closed)
  • react-day-picker would have built-in support for i18n (wait for date-fns v2)
  • we can remove the required moment.js support from the input component
  • we would push js community away from moment.js and adopt this better date library

Similar discussion: react-dates/react-dates#208

@robin-anil
Copy link

robin-anil commented May 18, 2017

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

@gpbl
Copy link
Owner Author

gpbl commented May 19, 2017

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

@gpbl
Copy link
Owner Author

gpbl commented May 24, 2017

So far there are two missing pieces from date-fns:

@leshakoss
Copy link

@gpbl hello, thank you for trying date-fns :-)

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?

@gpbl
Copy link
Owner Author

gpbl commented May 24, 2017

@leshakoss thanks from dropping by and share the positive news. Eager to try the alpha version and see how it works with the component.

@gpbl
Copy link
Owner Author

gpbl commented Jun 10, 2017

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.

@imevro
Copy link
Contributor

imevro commented Jun 21, 2017

Guys, your collaboration is pretty awesome 🔥

Repository owner deleted a comment Oct 12, 2017
@gpbl gpbl self-assigned this Oct 14, 2017
@marshallford
Copy link

I'd love to see this happen.

@pushred
Copy link

pushred commented Jan 18, 2018

Luxon is working great with UTC! Browser support is a bit iffy, depending on your needs.

https://moment.github.io/luxon/

@gpbl
Copy link
Owner Author

gpbl commented Mar 5, 2018

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants