-
Notifications
You must be signed in to change notification settings - Fork 155
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
Date comparisons should not include the calendar #1431
Comments
From the developer's point of view, |
I'm OK with this change (I don't have a strong opinion either way) but wanted to point out a quirk of this change as related to future extension of comparison methods. First, some background: in V1, Temporal has However, we've received feedback for more ergonomic support for those comparisons. We're not including this support in V1, but may consider for a future Temporal proposal. See js-temporal/proposal-temporal-v2#6. Also, if comparison operator overloading becomes part of ECMAScript, then presumably we'd want Temporal objects to participate. If we do end up extending comparison support in the future, then the "less than" and "greater than" operations would presumably take calendar and time zone into account, because otherwise there'd be cases where Is this a problem? I assume it's NOT a problem (for the same reasons why |
This commit changes different compare methods on types that include calendars to not take them into account. With this, two instances that have different calendars attached but map to the same points in the ISO calendar are compared to be "equal". Fixes: tc39#1431
This commit updates the polyfill to reflect the spec changes made for addressing tc39#1431.
I'd object to
There's nothing obviously wrong with that; it just means Temporal instances would be partially ordered rather than totally ordered. (Which I'd argue is exactly appropriate: 2021-03-08 in the Gregorian calendar is neither before nor after 2021-03-08 in the iso8601 calendar, and yet is also not the same thing.) |
This commit updates the polyfill to reflect the spec changes made for addressing tc39#1431.
This commit changes different compare methods on types that include calendars to not take them into account. With this, two instances that have different calendars attached but map to the same points in the ISO calendar are compared to be "equal". Fixes: tc39#1431
This commit updates the polyfill to reflect the spec changes made for addressing tc39#1431.
This commit updates the polyfill to reflect the spec changes made for addressing tc39#1431.
This commit changes different compare methods on types that include calendars to not take them into account. With this, two instances that have different calendars attached but map to the same points in the ISO calendar are compared to be "equal". Fixes: #1431
This commit updates the polyfill to reflect the spec changes made for addressing #1431.
This commit updates the polyfill to reflect the spec changes made for addressing tc39/proposal-temporal#1431.
Moving discussion from here: I'd like to revisit the conclusion from #588 and #625. It sounds like it was based on the assumption that two unequal objects must not compare as
0
, but that's just not true. Indeed, that's the whole reason we made Array.prototype.sort stable; stability is a property which is useful only when you have conceptually unequal things which compare as0
.Contrary to the discussion there, there is nothing in the definition of a consistent comparison function which requires it, and it's not a strong precedent in other languages: for example, Java's Comparable does not require this property. In fact it violates it for some of its own built-ins, like BigDecimal, for a very similar reason as we should do so here: two things can be represent the same point in the sort order in question but carry extra data which prevents them from being conceptually equal.
And it is important to omit the calendar for comparisons of dates: 2021-03-08 in the Gregorian calendar does not come before 2021-03-08 in the iso8601 calendar and should not be sorted as such.
(Note that I'm only talking about
compare
here. I'm fine with including calendars inequals
.)The text was updated successfully, but these errors were encountered: