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

formatDistanceStrict/formatDistanceToNowStrict returns '12 months' rather than '1 year' #2388

Closed
kingsonlo opened this issue Mar 30, 2021 · 4 comments · Fixed by #2391 or #2411
Closed
Assignees

Comments

@kingsonlo
Copy link

kingsonlo commented Mar 30, 2021

According to the documentation, formatDistanceStrict should not have the result of 12 months:
image

However, when I run the following example, I get 12 months. I would expect 1 year:

formatDistanceStrict(
  new Date(2015, 0, 2),
  new Date(2016, 0, 1),
); 

Same issue with formatDistanceToNowStrict

@kingsonlo kingsonlo changed the title formatDistanceStrict/formatDistanceToNowStrict returns '12 months' formatDistanceStrict/formatDistanceToNowStrict returns '12 months' rather than '1 year' Mar 30, 2021
@tan75 tan75 self-assigned this Mar 31, 2021
@tan75 tan75 linked a pull request Apr 1, 2021 that will close this issue
@tan75
Copy link
Contributor

tan75 commented Apr 2, 2021

hi @kingsonlo,

a PR has been raised to fix this - awaiting for a review from @kossnocorp

@kingsonlo
Copy link
Author

hi @kingsonlo,

a PR has been raised to fix this - awaiting for a review from @kossnocorp

awesome! thanks @tan75 !

kossnocorp pushed a commit that referenced this issue Apr 8, 2021
Fixed: Made `formatDistanceStrict` and `formatDistanceToNowStrict` always return `1 year` instead of `12 months`.
@bsime-gather
Copy link

bsime-gather commented Apr 13, 2021

For me, the previous behavior of this function is preferred when the unit is directly specified. Is there a way around that?

@tan75
Copy link
Contributor

tan75 commented Apr 13, 2021

hi @bsime-gather
I see your point and i have already created a PR for this
PR

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