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

The fromNow() method of the "relativeTime"plugin considers 11 months ago as a year #1997

Open
saguilarolmo opened this issue Jul 22, 2022 · 1 comment

Comments

@saguilarolmo
Copy link

saguilarolmo commented Jul 22, 2022

Describe the bug
When I print the difference between dates from 1 month to 12 with this code:
console.log("dayjs("2021-01-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-02-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-03-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-04-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-05-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-06-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-07-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-08-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-09-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log(" dayjs("2021-10-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-11-01T00:00:00+00:00").from(dayjs("2022-01-01")))
console.log("dayjs("2021-12-01T00:00:00+00:00").from(dayjs("2022-01-01")))

the result is:
a year ago
a year ago
10 months ago
9 months ago
8 months ago
7 months ago
6 months ago
5 months ago
4 months ago
3 months ago
2 months ago
a month ago

See: https://runkit.com/62da9163adca2e0009a4206c/62da91756e916c00084e970b

Expected behavior
The expected result is that it will also show 11 months ago as:
a year ago
**11 months ago**
10 months ago
9 months ago
8 months ago
7 months ago
6 months ago
5 months ago
4 months ago
3 months ago
2 months ago
a month ago

Information

  • Day.js Version [e.g. v1.11.4]
  • OS: [e.g. iOS]
  • Browser [e.g. chrome 62]
  • Time zone: [e.g. GMT-014:16 DST (CEST)]
@saguilarolmo saguilarolmo changed the title the fromNow() method of the "relativeTime"plugin considers 11 months ago as a year fromNow() method of the "relativeTime"plugin considers 11 months ago as a year Jul 22, 2022
@saguilarolmo saguilarolmo changed the title fromNow() method of the "relativeTime"plugin considers 11 months ago as a year The fromNow() method of the "relativeTime"plugin considers 11 months ago as a year Jul 22, 2022
@Bykiev
Copy link

Bykiev commented Jul 22, 2022

Hi, it's not a bug, according to the docs

46 days to 10 months MM 2 months ago ... 10 months ago
11 months to 17months y a year ago

You can create your own thresholds or patch existing according 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

No branches or pull requests

2 participants