Hello and thanks for this excellent library!
I'm trying to port a project from moment to date-fns and the only thing I'm missing is the calendar method, which works somewhat like distanceInWords but produce a different result.
I think that one of the biggest problem would be to update all the locales because more translated strings will be needed, do you think is something that could be implemented in the future? Thank you.
I have implemented this on a branch https://github.com/date-fns/date-fns/compare/master...orangemug:feature/calendar-fn, it needs a tidy and the tests don't pass via the runner (I can't get them to work they do pass manually via mocha). This implementation requires formats to always be passed into the function. Also note that date-fns currently doesn't implement the format token LT which is used in the default formats object in moment (see issue #390).
If the maintainers want this format function in the core then I'll get the tests passing via the main runner and submit a PR, else I'll just create a new repo. Just let me know
I think this would be a great addition to the library. I'm also looking for this functionality right now.
The function is available in v2 (currently in alpha) as formatRelative.
See docs: https://date-fns.org/v2.0.0-alpha.6/docs/formatRelative
Give it a try: npm install date-fns@next
Most helpful comment
The function is available in v2 (currently in alpha) as
formatRelative.See docs: https://date-fns.org/v2.0.0-alpha.6/docs/formatRelative
Give it a try:
npm install date-fns@next