-
Notifications
You must be signed in to change notification settings - Fork 154
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: Change overflow behaviour of PYM/PMD.toPlainDate #2718
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2718 +/- ##
=======================================
Coverage 96.38% 96.38%
=======================================
Files 21 21
Lines 12444 12444
Branches 2250 2250
=======================================
Hits 11994 11994
Misses 395 395
Partials 55 55 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 If we must do a (hopefully final!) normative PR, it's nice that this one is so simple. Thanks for all your're doing to get Temporal over the finish line!
bb1af83
to
1d7b724
Compare
Tests are in tc39/test262#3954. |
This changes PlainMonthDay.p.toPlainDate and PlainYearMonth.p.toPlainDate to constrain nonexistent resulting dates instead of throwing. For example, birthdaysThisYear = listOfBirthdays.map((pmd) => pmd.toPlainDate({ year: 2023 }) The above should not throw if one of the birthdays is February 29th. That would go against Temporal's design principle of avoiding data-driven exceptions. (If you still want the throwing behaviour, you can get it using the more verbose way, see below.) Temporal.PlainDate.from({ year: 2023, monthCode: pmd.monthCode, pmd.day }, { overflow: 'reject' }) Closes: #2706
1d7b724
to
724dfb6
Compare
This change got consensus at the November 2023 TC39 meeting. |
This changes PlainMonthDay.p.toPlainDate and PlainYearMonth.p.toPlainDate to constrain nonexistent resulting dates instead of throwing.
For example,
The above should not throw if one of the birthdays is February 29th. That would go against Temporal's design principle of avoiding data-driven exceptions.
(If you still want the throwing behaviour, you can get it using the more verbose way, see below.)
Closes: #2706