-
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
Max of 12 hours from Time.prototype.difference
is confusing
#597
Labels
Milestone
Comments
I agree. This seems strange as 0:00 is smaller than 23:59 and therefore the difference is larger. |
If we revert that change then you can still opt-in to the old behaviour using |
Closed
justingrant
added a commit
to justingrant/proposal-temporal
that referenced
this issue
Jun 12, 2020
Fixes tc39#663. Fixes tc39#597. Changes `difference()` to throw if `other`is larger than `this`. Goal: encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (tc39#558) Tests are updated to make it easy to choose any of the three options. Tests for option 1 are commented out in case we want to revert. The rest of test changes were reversing arguments so that choosing any of the options will break few tests.
justingrant
added a commit
to justingrant/proposal-temporal
that referenced
this issue
Jun 12, 2020
Fixes tc39#663. Changes `difference()` to throw if `other`is larger than `this`. Goal is encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (tc39#558) Tests are updated to make it easy to choose any of the three options. Tests for option 1 are commented out in case we want to revert. The rest of test changes were reversing arguments so that choosing any of the options will break few tests. Because `difference` is now unidirectional, it doesn't make sense to restrict `Time.prototype.difference` to 12 hours max. Fixes tc39#597.
justingrant
added a commit
to justingrant/proposal-temporal
that referenced
this issue
Jun 12, 2020
Fixes tc39#663. Changes `difference()` to throw if `other`is larger than `this`. Goal is encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (tc39#558) Tests are updated to make it easy to choose any of the three options. Tests for option 1 are commented out in case we want to revert. The rest of test changes were reversing arguments so that choosing any of the options will break few tests. Because `difference` is now unidirectional, it doesn't make sense to restrict `Time.prototype.difference` to 12 hours max. Fixes tc39#597.
justingrant
added a commit
to justingrant/proposal-temporal
that referenced
this issue
Jun 13, 2020
Fixes tc39#663. Changes `difference()` methods to throw if `other`is larger than `this`. Goal is encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (tc39#558) Tests are updated to make it easy to choose any of the three options. Only a few tests were functionally changed (e.g. to add throws() tests). The rest of test changes were reversing arguments so that choosing any of the options later will break relatively few tests. Because `difference` is now unidirectional, it doesn't make sense to restrict `Time.prototype.difference` to 12 hours max. Fixes tc39#597.
justingrant
added a commit
to justingrant/proposal-temporal
that referenced
this issue
Jun 13, 2020
Fixes tc39#663. Changes `difference()` methods to throw if `other`is larger than `this`. Goal is encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (tc39#558) Tests are updated to make it easy to choose any of the three options. Only a few tests were functionally changed (e.g. to add throws() tests). The rest of test changes were reversing arguments so that choosing any of the options later will break relatively few tests. Because `difference` is now unidirectional, it doesn't make sense to restrict `Time.prototype.difference` to 12 hours max. Fixes tc39#597.
ptomato
pushed a commit
that referenced
this issue
Jun 15, 2020
…pe.difference` to 12 hours (#667) * difference: throw out-of-order; zap Time 12h limit Fixes #663. Changes `difference()` methods to throw if `other`is larger than `this`. Goal is encourage feedback about long-term solution: option 1 - previous behavior: `difference()` returns an absolute value option 2 - behavior in this commit: throw if other is larger option 3 - negative durations (#558) Tests are updated to make it easy to choose any of the three options. Only a few tests were functionally changed (e.g. to add throws() tests). The rest of test changes were reversing arguments so that choosing any of the options later will break relatively few tests. Because `difference` is now unidirectional, it doesn't make sense to restrict `Time.prototype.difference` to 12 hours max. Fixes #597.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#330 proposed and #386 implemented a change to limit
Time.prototype.difference
to 12 hours.This makes it hard to correctly answer use-cases like the ones below using the
Time
type:I see several problems with the current behavior:
compare
anddifference
and using this pair in future calculations. Havingdifference
observe the wraparound behavior butcompare
not doing so will cause bugs if developers expect both to be consistent.Time
type, they're explicitly deciding to ignore times that are outside of a single solar day, so it seems like we should respect that choice.Time.prototype.difference
will return different results thanDate.prototype.difference
for the same times on the same date. This will not be expected in most use cases, especially given that Temporal makes it easy to split and join dates and times.I'd suggest reverting this change.
The text was updated successfully, but these errors were encountered: