-
Notifications
You must be signed in to change notification settings - Fork 152
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
Fix order of operations in subtract
and direction in since
#1123
Conversation
This was the first time prettier was run on this file, so many format and whitespace changes. No content changes.
Other specs aren't updated yet, but this change was trivial. Changes for `since` are still TBD here and in other specs.
This commit contains changes to remove Calendar's dateSubtract and timeSubtract methods, as well as the DateSubtract abstract operation. No changes in this checkin actually change any logic, so it should be quicker to review than the other commits in this PR.
This commit updates the ISO calendar's `dateAdd` to work with negative durations, and removes dateSubtract & timeSubtract methods from the implementation.
Updates `ES.DifferenceDate` to perform reversible, largest-units-first date arithmetic. I didn't spend a lot of time optimizing, so the algorithm can surely be improved later.
Now that order-of-operations works, these tests now pass.
This commit changes Date, DateTIme, YearMonth, and Time to: * Revise `subtract` to use largest-units-first order of operations * Fixes `since` to use largest-units-first order of operations and to always use `this` as the starting point for both arithmetic and rounding. * A few test changes to adjust to new results and to test the new OOO
Codecov Report
@@ Coverage Diff @@
## main #1123 +/- ##
==========================================
- Coverage 93.55% 90.17% -3.39%
==========================================
Files 19 17 -2
Lines 7961 8261 +300
Branches 1264 1202 -62
==========================================
+ Hits 7448 7449 +1
- Misses 506 801 +295
- Partials 7 11 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Test262 is still broken in CI, but I just pushed a 2-character commit that fixes Test262 when run locally. Now all tests pass. |
MERGE THIS PR BEFORE #1116. @ptomato will update that PR so its tests will work with the changes in this PR.
#1121 may also break this PR... not sure though. Ideally this PR could be merged first.This PR fixes #993 by:
subtract()
methods to use largest-units-first order of operationssince()
methods to use largest-units-first order of operations and to always usethis
as the starting point for both arithmetic and rounding.dateSubtract
&timeSubtract
from Calendar.*Subtract
abstract operationsI split this up into multiple commits to make it easier to review. Some of the commits are trivial changes (e.g. deleting stuff from specs and docs, or prettier changes) while others have logic that needs review.
If you're in a hurry, the most important commits to review are these:
DifferenceDate
abstract operationsubtract
andsince
in various Temporal typesFollow-ups needed:
since
and tests for DateTime and YearMonth.ES.DifferenceDate
,*.subtract
, or*.since