-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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() with .format() output #1362
Comments
please pass true as the second argument of |
console.log('with true')
console.log(`Now <diff> daysjs date: ${now.diff(futureDayjs, 'day', true)}`); // -49.00000002314815
console.log(`Now <diff> string date: ${now.diff(futureString, 'day', true)}`); // -48.99999065972222 So, while this does highlight the rounding issue, it still seems inconsistent that This can be very important for some edge cases as I discovered this during unit testing. |
this is because you just drop the millisecond in this line
|
Yeah that makes sense now that I think about it. I should be able to write tests that simply do not take MS into account then. Thanks! |
It seems that that
dayjs
operation for.format()
is not reversible via parsing its output withdayjs(dayjs().format()), not regards to the
diff()` function at least.To demonstrate, I experimented with the following snippet.
And getting the output
Which is not what I'd expect. Is there some timezone or other attribute that I'm missing that could be causing this or is this a bug?
The text was updated successfully, but these errors were encountered: