-
Notifications
You must be signed in to change notification settings - Fork 153
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: Introduce Record for relativeTo #2837
Comments
Also use this to eliminate UnbalanceDateDurationRelative as suggested in that review. |
@arshaw I might need some input from you on this. What do you do in the fullcalendar polyfill if the ZonedDateTime passed as relativeTo has an ambiguous wall-clock time? You can convert it to the PlainDateTime in the RelativeTo struct, but then you couldn't convert it back. |
Hi @ptomato, I devised this during the Duration rounding refactor, but I haven't actually implemented this RelativeTo record stuff in the fullcalendar polyfill yet. I can do that and report back. Will be sometime in Oct probably. I'm not quite sure what you mean though. I'm sort-of converting it back (to an epochNanoseconds) in the |
@arshaw But if the original ZonedDateTime was, say, |
Oh! Does it not matter because you never need the original ZonedDateTime back? You only add or subtract date duration units, and so if you land on an ambiguous wall clock time you actually want the |
@ptomato yes exactly |
I've written up a draft of this refactor in https://github.com/tc39/proposal-temporal/compare/main...2837-relativeto-record?expand=1 It turns out we do need the original ZonedDateTime in only one place: the check at the start of DifferenceZonedDateTimeWithRounding where we return difference-of-instants if It's also slightly annoying, but doable, that you have to compute the sign separately and pass it in to DifferenceZonedDateTimeWithRounding. Other than those, I think this works pretty well. |
Hey @ptomato, that's a great start, though if we can't figure out those two issues, it probably creates more problems than it solves. I want to take a more in-depth look at all this, and potentially devise a way to avoid passing a |
If we decide to do this, we should do it before the TC39 meeting October 8. Ideally we wouldn't make any big refactors after that. |
Hi @ptomato, I looked this over and really couldn't find a way to solve those issues. |
Is there still a way to remove |
@arshaw Thanks for investigating! Much appreciated. As for UnbalanceDateDurationRelative, I think at a minimum we should rename it if we do #2953. We could probably do a smaller version of this refactor only in Duration.compare and get rid of UnbalanceDateDurationRelative that way. I'll check if that's feasible. |
I tried refactoring only Duration.compare. By itself, it isn't really an improvement over the simplicity/readability of the status quo. So I think we should just go with renaming UnbalanceDateDurationRelative in #2953. |
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: