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

Inconsistent diff #5841

Open
risentveber opened this issue Mar 9, 2021 · 1 comment
Open

Inconsistent diff #5841

risentveber opened this issue Mar 9, 2021 · 1 comment

Comments

@risentveber
Copy link

risentveber commented Mar 9, 2021

Describe the bug
Inconsistent diff behaviour if timezones are different.

To Reproduce

n = moment()
moment("2021-03-14T16:20:43.308Z").diff(n, 'days', true) // 5.0297781
moment("2021-03-14T16:20:43.308Z").diff(n, 'seconds', true) / 3600 / 24 // 4.98811152

Expected behavior
Bad precision it's about 1%

Moment version 2.29.1
Browser version Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36

@risentveber
Copy link
Author

I think the problem is in zoneDelta

output = (this - that) / 1e3;
vs
output = (this - that - zoneDelta) / 864e5;
(edited)

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

Successfully merging a pull request may close this issue.

1 participant