-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normative: Fix date difference for end-of-month edge cases
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. TODO: Make the algorithm in the reference code faster, to help show how it could be implemented. Closes: #2535
- Loading branch information
Showing
2 changed files
with
47 additions
and
83 deletions.
There are no files selected for viewing
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
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