-
Notifications
You must be signed in to change notification settings - Fork 149
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
Suggestion: split option name into disambiguation
(for DST) vs. overflow
(for ranges)
#607
Comments
I wouldn't be opposed to changing the options keyword to (When these were originally separate arguments as opposed to options keys, it wasn't so important what they were called since you could call them whatever you wanted in your code.) |
disambiguation
optiondisambiguation
option name into to disambiguation
(for DST) vs. overflow
(for ranges)
disambiguation
option name into to disambiguation
(for DST) vs. overflow
(for ranges)disambiguation
(for DST) vs. overflow
(for ranges)
I'm personally in favor of |
Yep, after thinking this over I think the biggest issue with the current naming is potential for future conflict. The particular use case I'm concerned about is a method that converts a This method would need to have an option to control overflow when converting the If those two options had different names then it'd be easy to combine both options into a single bag, e.g. The best I've been able to come up with are Even if Temporal opts not to offer a |
I was considering something like: function f(dateTimeLike, timeZone, options = {}) {
const dateTime = DateTime.from(dateTimeLike, options.overflow);
const absolute = dateTime.inTimeZone(timeZone, options.timeZone);
...
} |
Yep, that's an OK workaround for userland libraries' internal use, but if options are exposed to users (either in a future Temporal type or in a userland library) then it's still a lot more ergonomic to use different property names. For example, using different property names is over 70% more typing:
Seems unwise to restrict Temporal to the +70% syntax for any future additions that may require multiple options, or to force userland libraries to choose between ergonomics vs. matching Temporal's options syntax. Also, the philosophy of Temporal is to use strong typing to avoid ambiguity, so it's unexpected that we're not following the same strong-typed path with options types. Finally, now that For these reasons, I still encourage renaming this option to |
I think now that we have decided to add LocalDateTime, this becomes necessary? |
Using |
In 2020-08-13 meeting, this change was approved. Specifically:
@ptomato - this will be a straightforward to PR but massive: ~100 files, 1500+ replacements. I'm happy to PR it but it will probably have many merge conflicts with your Negative Durations PR #811. Should we wait to PR this overflow change until your PR is merged, or is it better to make this overflow change first and adapt #811 to use the new |
I don't mind rebasing #811, but I would hope that the it's close enough to merging now anyway that it wouldn't be an issue. |
@justingrant #811 is merged now, so this can start. Happy to leave the PR to you, or I can take this one if you're busy. |
@ptomato - If you could take this one that'd be great. My kids just started school and my free time is looking like it's going to be limited over the next few weeks between tech support, homework support, and emotional support for the joy that's remote schooling. ;-) Also this will give me more bandwidth to wrap up remaining LocalDateTime issues (esp. the algorithm testing with the JSCalendar folks). Thanks! Here's some minor help: the TS declaration from #700 for the new option. I assume we'll want a separate DurationOverflowOptions too.
|
"Overflow" is how to deal with out-of-range values for a particular unit (for example, minute 61, or day 0 of the month.) "Disambiguation" is how to deal with skipped or double wall clock times during time zone transitions. Previously, they were both called "disambiguation". This split is necessary, because for the zoned type being added, we will need to provide both options to the same function call. Closes: #607
"Overflow" is how to deal with out-of-range values for a particular unit (for example, minute 61, or day 0 of the month.) "Disambiguation" is how to deal with skipped or double wall clock times during time zone transitions. Previously, they were both called "disambiguation". This split is necessary, because for the zoned type being added, we will need to provide both options to the same function call. Closes: #607
"Overflow" is how to deal with out-of-range values for a particular unit (for example, minute 61, or day 0 of the month.) "Disambiguation" is how to deal with skipped or double wall clock times during time zone transitions. Previously, they were both called "disambiguation". This split is necessary, because for the zoned type being added, we will need to provide both options to the same function call. Closes: #607
Of all the concepts in Temporal, the one that confused me most was the
disambiguation
option.I finally understood today why this confused me so much: there are two somewhat-unrelated questions mapped to one name.
{minute: 66}
? Choices are:'constrain' | 'balance' | 'reject'
(or sometimes just'constrain' | 'reject'
)'earlier' | 'later' | 'reject'
.Did I get this correct? If yes, to remove "disambiguation ambiguity" 😃 my suggestion would be to rename the former usage to
overflow
which is easier to type and spell and would more clearly explain what the option is doing.An additional benefit would be avoiding potential future conflict. For example, if we build
ZonedAbsolute
, then itswith
method would probably need to offer both overflow and DST-ambiguity handling. Even if we don't want to add such a type now, it's probably unwise to preclude it in the future.The text was updated successfully, but these errors were encountered: