You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #2826 lands, consider introducing a relativeTo Record in the spec, to show implementations how relativeTo can be handled in a more statically-typed way.
There might be an opportunity to give a formal shape to "relativeTo". Kevin Ness brought this up in the last meeting regarding difficulty in statically typed languages.
typeRelativeTo={plainDateTime: Temporal.PlainDateTimetimeZone: Temporal.TimeZone// or null if UTC?}functionnormalizeRelativeTo(input): RelativeTo{if(inputinstanceofTemporal.ZonedDateTime){return{plainDateTime: input.toPlainDateTime(),timeZone: input.getTimeZone(),}}elseif(inputinstanceofTemporal.PlainDate){return{plainDateTime: input.toPlainDateTime(),// gives 00:00:00timeZone: newTemporal.TimeZone('UTC')}}}/*Adds a Duration to the relativeTo and returns an epoch nanosecondsThis function is only ever called with time units zeroed out!(It's just the way our nudging/bubbling system works during relative-rounding)Thus, we don't need to worry about the intricacies of *when* time units areadded in PlainDateTime vs ZonedDateTime.A utility function is nice because we don't need to call GetUTCEpochNanoseconds andGetInstantFor conditionally each time.*/functionaddToRelativeTo(relativeTo: RelativeTo,duration): bigint{returnrelativeTo.timeZone.getInstantFor(relativeTo.plainDateTime.add(duration)).epochNanoseconds}
After #2826 lands, consider introducing a relativeTo Record in the spec, to show implementations how relativeTo can be handled in a more statically-typed way.
Originally posted by @arshaw in #2758 (review)
The text was updated successfully, but these errors were encountered: