-
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
Decide whether ISO string with bracketed time zone name but no offset is valid #933
Comments
@ptomato would you mind giving some context of why this is of interest? |
Sure! My personal opinion is that it is not well-formed, but I think @pipobscure was in favour of it - can you provide more context? |
Note there is a bug in the polyfill either way. > Temporal.DateTime.from('2020-09-18T14:26[America/New_York]')
Temporal.DateTime <2020-09-18T14:00> Either this should throw or the |
Meeting 2020-10-08 (plus some more notes I added afterwards):
s = '2020-09-18T14:26[America/New_York]';
Temporal.DateTime.from(s).toZonedDateTime(s);
|
Good catch on the inconsistency. We do indeed intend to throw on invalid strings (or valid strings with unknown junk after them.) |
Meeting 2020-10-09: We weren't able to resolve this discussion without @pipobscure in the meeting. We'll discuss it next time. |
We did have a tentative conclusion though! Which was, that we'd in any case write a different cookbook example since the above one wouldn't work. |
Oh sorry I didn't remember that! We're still going to talk about this with Philipp next week, right? |
I just re-read the notes and think it's worth chatting with Philipp about this because I think he was pretty adamant that the solution to this was parsing the full string. I'd like to understand more about how he was thinking this should work. |
So I don’t by the premise. |
Meeting 2020-10-15:
|
In more detail, the status quo is that irrelevant "parts" of an ISO string are ignored by from() functions. So, an ISO string with a date part and time part passed to What changes: previously a time zone part consisted of an offset and an optional time zone name annotation. So a time zone name annotation by itself was not a valid part. After this change, we consider offset parts and time zone name parts to be separate, so |
Previously we considered a "time zone part" to be an offset plus an optional bracketed name. Now an ISO string may have either of an "offset part" and "time zone name part", independently of each other. Closes: #933
Previously we considered a "time zone part" to be an offset plus an optional bracketed name. Now an ISO string may have either of an "offset part" and "time zone name part", independently of each other. Closes: #933
I think it's okay for Temporal to allow strings with brackets but no offsets, but I want to point out why that is quirky behavior as it relates to RFC 3339 and the calendar annotation (#293). The calendar annotation is a projection: the data model remains expressed in the ISO calendar, but it should be interpreted in the context of the calendar system. I see the IANA time zone in the same way: it projects an instant into a time zone. In both cases, you can drop the annotation while still retaining the meaning of the core ISO-8601 string. If you have a ZonedDateTime string with offset and time zone annotation, you can drop the time zone annotation, and the instant remains the same. If you have a ZonedDateTime or Plain[Date][Time] string with a calendar annotation, you can drop the calendar annotation, and the civil date[time] remains the same. However, if you have a string with a bracketed time zone but no offset, this invariant doesn't hold. If you drop the time zone annotation from such a string, you downgrade from a ZonedDateTime to a PlainDateTime, losing the instant. |
Is the Instant really the core meaning of the ISO string? Or is it the unqualified time that is there and should still be projected into the given timezone? |
Yep. A similar case is |
I think the rule for ZDT.from should be that we'll allow parsing of a date+timzeone, a date+time+timezone, or a date+timezone+offset+timezone. |
Ok except for date+timezone because what time would you pick. In ZonedDateTime I think you have to have a datetime to start with. |
If you're using an object property bag for |
"2020-09-18T14:26[America/New_York]" is a ZonedDateTime, which is defined as an instant that happened in a place. A time zone database is required in order to figure out what the instant is, which is not good for interop. Furthermore, dropping the time zone completely changes the meaning of the string (from an instant-with-annotation to a civil time). |
The interop problem already exists because of iCalendar's data model is DateTime+TimeZone. I think the general question for the industry (not just Temporal) is how should iCalendar-compliant apps serialize a DateTime+TimeZone into a single string? IMHO it's better to have a single, standardized string representation for this data model instead of individual developers making one up.
I would state it differently: "2020-09-18T14:26[America/New_York]" can be parsed into a ZonedDateTime, with the caveat that this particular string format is not canonical (which is why the default |
I opened #1082 to track the questions in the last few comments above. |
The champions group is not all agreed on whether the string
'2020-09-18T14:26[America/New_York]'
is well-formed.Various notes:
[America/New_York]
part is not standard according to ISO either way. We are trying to standardize it. We would want to avoid accepting something that might not be standardized.The text was updated successfully, but these errors were encountered: