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
differenceInYears() returns -0 when comparing the same date #692
Comments
I think we should have a positve 0 (as proposed by the PR of armenavetisyan), but keep the sign for the non-zero results. thi can be used to know if we are before/after an other date. |
I think this is not only an issue with differenceInYears but some other differenceIn* functions as well. {
differenceInCalendarDays: 0,
differenceInCalendarISOWeeks: 0,
differenceInCalendarISOYears: 0,
differenceInCalendarMonths: 0,
differenceInCalendarQuarters: 0,
differenceInCalendarWeeks: 0,
differenceInCalendarYears: 0,
differenceInDays: -0,
differenceInHours: 0,
differenceInISOYears: -0,
differenceInMilliseconds: 0,
differenceInMinutes: 0,
differenceInMonths: -0,
differenceInQuarters: -0,
differenceInSeconds: 0,
differenceInWeeks: -0,
differenceInYears: -0,
} I think -0 should never be returned by any of the functions. It would be nice if @ArmenAvetisyan could also take the other functions in his PR into account. Thanks. |
Hm, on one hand, that's an annoying inconsistency, but on another hand -0 and 0 for JS are the same thing: 0 == -0
//=> true
0 === -0
//=> true
JSON.stringify(-0)
//=> "0" I think that it doesn't make sense to add @leshakoss WDYT? |
@leshakoss figured out that the problem is in |
It was not |
@leshakoss nice try |
Shouldn't the same year always be returned as a "positive" zero value?
Solvable by using
Math.abs(value)
if the value is 0. Perhaps a bigger discussion if all values should be returned as positive numbers.The text was updated successfully, but these errors were encountered: