-
Notifications
You must be signed in to change notification settings - Fork 156
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
Differentiate From Ambiguous and Missing Dates For Timezone Conversion #840
Comments
Thanks for leaving the feedback! Can you say more about what is missing from Unfortunately we cannot have an option to take the "standard" or "daylight" time, because those concepts don't exist in many time zones. In some, "standard" and "daylight" are the same, and there is a separate "winter" time. And in others, there are shifts in the UTC offset for other reasons than daylight saving. The rationale for including |
BTW, in addition to being the default for legacy From https://tools.ietf.org/html/rfc5545:
|
You're right, you could just check the length of
Interesting, I was curious if shifts could happen for reasons other than daylight savings.
That makes sense, thanks for the explanation! |
To clarify some reasoning for the current naming and behaviour...
Out of interest, did you happen to see the Ambiguity page in the documentation? It goes into a little more detail about this behaviour. If you didn't see it, that means we have a discoverability problem with the documentation. 😃 @ptomato @justingrant It might be worth making a "key concepts" page for the documentation and adding it prominently on the index page. That page could also contain a "which Temporal type should I use?" decision tree (which I swear I've seen here but can't find the issue — Edit: it's #655). |
@gilmoreorless I agree that when adding 1 hour to const dateTime = Temporal.DateTime.from("2020-03-08T02:45:00");
Temporal.TimeZone
.from("America/New_York")
.getAbsoluteFor(dateTime) // Temporal.Absolute <2020-03-08T07:45Z>
Temporal.TimeZone
.from("America/New_York")
.getAbsoluteFor(dateTime.add({hours: 1})) // Temporal.Absolute <2020-03-08T07:45Z> In elixir, the behavior when adding 1 hour to a DateTime.from_naive!(~N[2020-03-08T01:45:00], "America/New_York")
|> DateTime.add(60 * 60, :second) # DateTime<2020-03-08 03:45:00-04:00 EDT America/New_York> I think the problem is when you receive a date time such as I don't think giving more context when converting a
I did see it but I wasn't really satisfied with the solution which is why I created this issue. It could perhaps be more discoverable though. |
The Ambiguity and Balancing pages were already on the front page, but sort of buried in the Temporal.TimeZone and Temporal.Duration paragraphs respectively. See #848 for adding these to their own section. |
@gilmoreorless By the way: #655 is the flowchart issue you're looking for 😄 |
Thanks @ptomato, I've edited my comment to link to it. Damn GitHub search — I looked for both "flow" and "chart" separately but "flowchart" didn't turn up. 😆 |
@daniel-nagy That's a fair point about addition and context. But I still think that it's incorrect for Elixir to return possible options that don't match any UTC offset used by the zone in question. |
I think we have clarified things in the documentation, so I'll close this issue, thanks for bringing it up! |
It's not accurate to say that 2020-03-08T02:30:00 in America/Los_Angeles is ambiguous. It is actually nonexistent. I believe the two should be differentiated from. The API should provide enough context to know that the date was missing opposed to being ambiguous.
Let's look at some examples
These are all very unexpected results and as a developer I don't have enough context to make sense of it. A better alternative would be to be explicit about what should happen
IMO the
compatible
option fordisambiguation
is confusing and not very useful. I think it might also make sense to have the option to take, or round to, standard time or daylight time.A lower lever API can be added to explicitly get access to this information so the developer can make the best choice. This would essentially replace
getPossibelAbsoluteFor
Note that
choices
is in chronological order. This API is inspired by theDateTime
type in Elixir https://hexdocs.pm/elixir/DateTime.html#from_naive/3.The text was updated successfully, but these errors were encountered: