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

diff(date, unit) returns wrong value when the unit is 'year' and the difference is 1 #967

Closed
dnacu opened this issue Jul 24, 2020 · 0 comments

Comments

@dnacu
Copy link

dnacu commented Jul 24, 2020

Describe the bug
day.js

const now = dayjs('2020-07-24')
const past = dayjs('2019-12-12')
const pastPast = dayjs('2018-06-24')

console.log(
  now.year(),
  past.year(),
  past.diff(now, 'year'),
  now.diff(past, 'year')
)

console.log(
  now.year(),
  pastPast.year(),
  pastPast.diff(now, 'year'),
  now.diff(pastPast, 'year')
)

console.log

2020 2019 0 0 // expected 1
2020 2018 -2 2

Expected behavior
expected result value 1 when get diffrence between 2020 and 2019

Information

  • Day.js Version: 1.8.30
  • OS: macOS (Catalina)
  • Browser chrome 84
  • Time zone: GMT+09:00
@dnacu dnacu closed this as completed Jul 24, 2020
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

1 participant