-
Notifications
You must be signed in to change notification settings - Fork 156
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
Normative: Fix date difference for end-of-month edge cases #2759
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2759 +/- ##
==========================================
- Coverage 96.59% 96.57% -0.02%
==========================================
Files 23 23
Lines 12218 12242 +24
Branches 2263 2268 +5
==========================================
+ Hits 11802 11823 +21
- Misses 356 358 +2
- Partials 60 61 +1 ☔ View full report in Codecov by Sentry. |
pipobscure
approved these changes
Jan 27, 2024
ptomato
force-pushed
the
2535-end-of-month-edge-cases
branch
2 times, most recently
from
January 31, 2024 00:45
1c015c4
to
4350921
Compare
This was referenced Jan 31, 2024
This adjusts the difference algorithm for Gregorian-year dates so that when an intermediate date occurs past the end of a month, it is not shifted to the end of that month. Previously, in some edge cases where taking the difference in months or years would return a number of months and zero days, we now return one month less and 28, 29, or 30 days instead. Example: 1970-01-29 until 1971-02-28, largestUnit years Old result: 1 year, 1 month New result: 1 year, 30 days Note that largestUnit weeks and largestUnit days, the latter of which is the default, are not affected. Closes: #2535
ptomato
added a commit
to ptomato/test262
that referenced
this pull request
Feb 7, 2024
This adds tests specifically for every kind of case that changes due to the tweak to the date difference algorithm: differences from a longer month to a shorter month, when the months are adjacent, in the same year but not adjacent, and in different years. Also adds tests for a case that does *not* change, but would trip on an incorrectly implemented algorithm: when the intermediate months value falls at the end of February. There was incidental coverage of the change to the date difference algorithm in other tests. Those are adjusted, as well. Normative change: tc39/proposal-temporal#2759 Consensus in February 2024
ptomato
added a commit
to ptomato/test262
that referenced
this pull request
Feb 9, 2024
This adds tests specifically for every kind of case that changes due to the tweak to the date difference algorithm: differences from a longer month to a shorter month, when the months are adjacent, in the same year but not adjacent, and in different years. Also adds tests for a case that does *not* change, but would trip on an incorrectly implemented algorithm: when the intermediate months value falls at the end of February. There was incidental coverage of the change to the date difference algorithm in other tests. Those are adjusted, as well. Normative change: tc39/proposal-temporal#2759 Consensus in February 2024
ptomato
added a commit
to tc39/test262
that referenced
this pull request
Feb 10, 2024
This adds tests specifically for every kind of case that changes due to the tweak to the date difference algorithm: differences from a longer month to a shorter month, when the months are adjacent, in the same year but not adjacent, and in different years. Also adds tests for a case that does *not* change, but would trip on an incorrectly implemented algorithm: when the intermediate months value falls at the end of February. There was incidental coverage of the change to the date difference algorithm in other tests. Those are adjusted, as well. Normative change: tc39/proposal-temporal#2759 Consensus in February 2024
This change gained consensus at TC39 on 2024-02-06. |
ptomato
force-pushed
the
2535-end-of-month-edge-cases
branch
from
February 10, 2024 00:13
4350921
to
74f3dbb
Compare
moz-v2v-gh
pushed a commit
to mozilla/gecko-dev
that referenced
this pull request
Dec 3, 2024
…udet Implement the changes from: - tc39/proposal-temporal#2762 - tc39/proposal-temporal#2759 Differential Revision: https://phabricator.services.mozilla.com/D228037
i3roly
pushed a commit
to i3roly/firefox-dynasty
that referenced
this pull request
Dec 6, 2024
…udet Implement the changes from: - tc39/proposal-temporal#2762 - tc39/proposal-temporal#2759 Differential Revision: https://phabricator.services.mozilla.com/D228037
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adjusts the difference algorithm for Gregorian-year dates so that when an intermediate date occurs past the end of a month, it is not shifted to the end of that month.
Previously, in some edge cases where taking the difference in months or years would return a number of months and zero days, we now return one month less and 28, 29, or 30 days instead.
Example: 1970-01-29 until 1971-02-28, largestUnit years
Old result: 1 year, 1 month
New result: 1 year, 30 days
Note that largestUnit weeks and largestUnit days, the latter of which is the default, are not affected.
(Note: Stacked on top of an editorial change which I will eventually make a separate PR for.)Closes: #2535