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

Large diffs display wrong hours #2565

Open
arrudaje opened this issue Jan 25, 2024 · 3 comments
Open

Large diffs display wrong hours #2565

arrudaje opened this issue Jan 25, 2024 · 3 comments

Comments

@arrudaje
Copy link

arrudaje commented Jan 25, 2024

Describe the bug
Due to this PR #2362, when we perform large diffs and construct a duration from it, the wrong number of hours is computed in the resulting duration. Example:

dayjs.duration(dayjs('2020-04-01 08:00:00').diff('2020-01-27 10:00:00')).format('HH:mm:ss') // displays '01:00:00'

Expected behavior

dayjs.duration(dayjs('2020-04-01 08:00:00').diff('2020-01-27 10:00:00')).format('HH:mm:ss') // should display '21:00:00'

Information

  • Day.js Version: [v1.11.10]
  • OS: [iOS]
  • Browser: [chrome 120.0.6099.234]
  • Time zone: [e.g. GMT+01:00 (Central European Standard Time)]
@arrudaje
Copy link
Author

arrudaje commented Jan 25, 2024

@sanjaynishad can you check this as you were the author of the PR?

@abemedia
Copy link

Just came to report the same...

const from = dayjs('2022-01-01 00:00:00');
const to = dayjs('2023-02-02 01:01:01');
const d = dayjs.duration(to.diff(from));
console.log(d.toISOString()); // prints "P1Y1M1DT15H1M1S" i.e. 15 hours, not 1

@buza-me
Copy link

buza-me commented Feb 3, 2024

@abemedia @arrudaje
#2571
#2572
I will not create any pull requests unless the repo owner will get interested. But you can use the code, if you didn't come up with your own solutions yet. Lmk if you spot some issues.

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

3 participants