Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDate comparsion bug #896
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
claudepache
Apr 17, 2017
Contributor
This is correct.
a == bis false, becauseaandbare not the same Date object. It does not test whether they represent the same moment.- On the other side, relational operators like
<convert their operand to primitives before comparison. The primitive value of a Date object is the number of milliseconds since the epoch; so that they compare correctly the moments they represent.
The root issue is that == has different meanings according to the type of its operands (compares references for objects, compares values for primitives). This is unfixable. Use something more explicit than ==, e.g. a.valueOf() == b.valueOf().
|
This is correct.
The root issue is that |
michaelficarra
closed this
Apr 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vadjs commentedApr 17, 2017
This must be very strange mechanics.