-
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
Extend datemath tests to cover 'gregory' calendar #1768
Comments
Reproed. Thanks for catching this! Should be straightforward to expand the demitasse tests. I've only minimally touched the 262 tests but I'll take a look. I think I just found another bug while debugging this. Looks like weeks are being returned by non-ISO dateUntil, when AFAIK expected behavior is that either weeks or days is returned, but not both unless largestUnit is weeks and smallestUnit is days. Is this assumption correct? I remember we spent a long time on this algorithm last year but wanted to double-check I understand desired behavior correctly. |
One more question: does code outside Calendar guarantee that Calendar.p.dateUntil is always called with |
Adding calendars to datemath turned out to be pretty easy for the demitasse tests, and there was only one test failure (the repro you found) so I'll just include the the fix in #1761 as well as extending demitasse tests to use gregory too. Great idea to use gregory, BTW. I'll also fix the bug noted above where weeks were returned when largestUnit was I didn't know how to add gregory to the 262 tests so I'll skip that part for now, if that's OK. I'll open a new issue to cover the equivalent of this issue, but for Test262. |
Fixes tc39#1768 which was caused by assuming that `two` was always later than `one` when `largestUnit` was `'years'` or `'months'`. Also included `calendar: 'gregory'` in datemath demitasse tests.
Fixes to the repro above and demitasse tests are in #1761. Future gregory test coverage is now tracked by #1776. I answered my own questions from above, if you want to skip reading comments.
In the polyfill the answer is "no". I assume the same is true in the spec but haven't confirmed.
Yes. Weeks is only returned if |
Thanks! (The "When converting the tests to test262..." part was meant more as a note to myself, sorry didn't mean to try to put that task onto you.) I think we removed all of the |
Fixes #1768 which was caused by assuming that `two` was always later than `one` when `largestUnit` was `'years'` or `'months'`. Also included `calendar: 'gregory'` in datemath demitasse tests.
In order to avoid bugs like #1761 we should extend the tests in datemath.mjs to cover at least the
gregory
calendar (chosen because it's a non-ISO calendar but can be easily debugged because the results should be the same as the ISO calendar.)I've done this in a branch but there is at least one bug with dateUntil: https://github.com/tc39/proposal-temporal/tree/test-non-iso-datemath
This should return
P1M20D
(and does so if you omit the withCalendar) but it currently throws.When converting the tests to test262, we should ensure that the iso8601 tests are added to built-ins/Temporal/Calendar but the gregory tests are added to intl402/Temporal/Calendar in test262.
The text was updated successfully, but these errors were encountered: