-
Notifications
You must be signed in to change notification settings - Fork 157
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
Editorial: Simplify date/time range validation #2658
Conversation
ac60dfc
to
f6efff3
Compare
Codecov Report
@@ Coverage Diff @@
## main #2658 +/- ##
==========================================
+ Coverage 96.07% 96.10% +0.02%
==========================================
Files 20 20
Lines 11676 11697 +21
Branches 2203 2186 -17
==========================================
+ Hits 11218 11241 +23
+ Misses 394 392 -2
Partials 64 64
|
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.
I like inlining the offset arithmetic!
8caefac
to
f541879
Compare
@gibson042 - I think all your review comments are addressed, want to take another look? Thanks! |
146f909
to
4f79012
Compare
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.
Looks good, I just had a few stylistic nits to pick. Thanks!
Removes `!` from calls of IsValidEpochNanoseconds, because that AO is infallible.
4f79012
to
911cf9f
Compare
This commit refactors several operations related to range validation of Temporal.PlainDateTime and Temporal.Instant. * Adds optional _offsetNanoseconds_ parameter to GetUTCEpochNanoseconds, and uses it in call sites of GetUTCEpochNanoseconds where an offset was previously applied to its result. * Makes polyfill GetUTCEpochNanoseconds infallible, like in the spec. * Simplifies the polyfill's GetNamedTimeZoneOffsetNanoseconds by using the now-infallible GetUTCEpochNanoseconds. * Simplifies the polyfill's PlainDateTime range validation in RejectDateTimeRange. * Clarifies the PlainDateTime docs about that type's valid range. * Removes non-parsing logic from ParseTemporalInstantString, aligning Instant parsing with the parsing pattern used in other Temporal types where parsing AOs contain only parsing without interpretation. * Inlines the single-caller ParseTemporalInstant into ToTemporalInstant, matching the pattern used by ToTemporalYearMonth, ToTemporalTime, etc. * Marks ParseDateTimeUTCOffset as infallible after parsing instant strings, because ParseTemporalInstantString guarantees that the offset is valid. Fixes tc39#2637. * Aligns polyfill more closely to spec for Instant parsing.
911cf9f
to
a1f2a9f
Compare
This PR refactors several operations related to range validation of Temporal.PlainDateTime and Temporal.Instant.
commit 1: remove the
!
from existing calls to IsValidEpochNanoseconds which is infallible.commit 2:
year % 400
trick to avoid overflows._offsetNanoseconds_
parameter to GetUTCEpochNanoseconds, and uses it in call sites of GetUTCEpochNanoseconds where an offset was previously applied to its result.