-
Notifications
You must be signed in to change notification settings - Fork 241
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
get_date() seems to look for lowercase timezone information #1209
Comments
Ahh, no, we're actually making all text lowercase before comparison. Then I'm not sure why my tests seemed wrong. Line 629 in 77eb67d
|
My main reference here is ISO/WD 8601-1 2016-02-16 which, while not technically the current standard, is reasonably close and recent. §§4.1–4.3 are most relevant to the broader issue at-hand, i.e., fixing #1202 and the like. A note in §3.4.1 states that "[i]n date and time representations lower case characters may be used when upper case characters are not available", but I'll admit that seems like a rare condition these days and I can't say that I've seen it in actual practice. So I would adopt the standard robustness principle here: Accept
Trying to parse timestamps with single-character zone designations from the "military timezone table" included above is not really compatible with the modern standard. Only the character More broadly, in fact, we discourage trying to infer any UTC offsets from any abbreviations in general. From https://data.iana.org/time-zones/data/theory.html#abbreviations:
In short, "the mapping doesn't go that way", nor is it really intended to. That hasn't stopped folks from trying, though, as evidenced by the "timezone table" listed here: Lines 487 to 540 in 77eb67d
This seems to attempt to define UTC offsets for several standard and non-standard abbreviations, but even beyond the normal question of ambiguity it has further serious problems. Constructions like I would suggest that, in general, these existing tables may do more harm than good. In the broader solution to these time issues, they could likely be replaced with a simpler check on inputs:
Combined with "assume 23:59:59 if no time is specified", that could go a long way. |
@timparenti Thanks for your thorough response! Hmmmm, I checked, and there's exactly one caller of
This caller wants a date without a time, and thus we want UTC (because local dates without times are a mess, as we've seen). I guess we can remove all the code calculating time. And then we can remove all code for timezones. So that get_time() is reformed to only accept dates, and always treat them as UTC. |
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones was quite bad. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones is quite bad, for today's standards. Link: <shadow-maint#1202> Link: <shadow-maint#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There is exactly one caller of this function, and it wants a date, not a time. It is useless to be able to parse local dates, because we ultimately store a UTC date. To avoid confusion, unconditionally use UTC. Since this code had important bugs regarding offset, we can safely assume that no existing users rely on being able to use their local date (this never worked correctly). Also, the code parsing time zones is quite bad, for today's standards. Link: <#1202> Link: <#1209> Reported-by: Chris Hofstaedtler <[email protected]> Reported-by: Tim Parenti <[email protected]> Reported-by: Lee Garrett <[email protected]> Cc: Gus Kenion <https://github.com/kenion> Cc: Michael Vetter <[email protected]> Cc: Paul Eggert <[email protected]> Cc: Iker Pedrosa <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Brian Inglis <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
shadow/lib/getdate.y
Line 487 in 77eb67d
shadow/lib/getdate.y
Line 673 in 77eb67d
shadow/lib/getdate.y
Lines 542 to 570 in 77eb67d
shadow/lib/getdate.y
Lines 711 to 720 in 77eb67d
@timparenti , do you know if time zones should be uppercase or lowercase? I was testing passing a date with a trailing
Z
and it wasn't being interpreted correctly, and now I realize that it wants lowercase letters, but that seems weird. What do standards say about this?Cc: @zeha
The text was updated successfully, but these errors were encountered: