Skip to content

Interval equals in case of timezones #1349

Answered by icambron
dmitrijs-balcers asked this question in Q&A
Discussion options

You must be logged in to vote

An interval is equal to another interval if both their starts and ends are equal, and two datetimes are equal if they represent the same time in the same zone. So that nets out to your intervals not being equal.

I think this is the right behavior for intervals to have, because the two intervals will have different results for the same methods As a simple example, consider the methods that format intervals to strings. It would be weird if two objects that considered themselves equal had divergent behavior.

I would support adding a separate equality operator that only compared the epoch millis of the start and end. We don't have one for datetimes because it's easy enough to do +d1 == +d2 bu…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dmitrijs-balcers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants