iamkun / iamkun/dayjs

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

Open
#1,997 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**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)]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.