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
From #2758 reviews. This can likely be drastically simplified after #2826 lands and can maybe even be done as part of that issue.
This plainDateTimeOrRelativeToWillBeUsed is a little hard to reason about. Here's how you can make it clearer. Feel free to queue this up as an Editorial task for later if the goal here is keep the diff as small as possible.
You can determine whether nanosecond-rounding is possible at the beginning of the function and it makes things clearer. Pseudocode:
constneedRelativeRounding=zonedRelativeTo||// if zoned date time// OR, if plain date and there's a unit >DAYES.IsCalendarUnit(largestUnit)||calendarUnitsPresentif(!needRelativeRounding){// do nanosecond-based rounding (BalanceTimeDuration)// return the result here, short circuiting}if(!zonedRelativeTo||!plainRelativeTo){thrownewRangeError('need a relativeTo')}constcalendarRec=CalendarMethodRecord.CreateFromRelativeTo(plainRelativeTo,zonedRelativeTo,['dateAdd','dateUntil']);if(zonedRelativeTo){constprecalculatedPlainDateTime=// ...// proceed with DifferenceZonedDateTimeWithRounding...}elseif(plainRelativeTo){// proceed with DifferencePlainDateTimeWithRounding...}
From #2758 reviews. This can likely be drastically simplified after #2826 lands and can maybe even be done as part of that issue.
Originally posted by @arshaw in #2758 (comment)
The text was updated successfully, but these errors were encountered: