-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Support Parsing Named Timezones #423
Comments
I have not checked for the nuances of the format, but it appears to be roughly similar to RFC2822. If this is sufficient for your use case, it's already implemented and will be included in the next release. In terms of actually supporting time zone names, this is unlikely. While GMT is unambiguous to my knowledge, other names are not. What does "CST" refer to? US central time, Mexico central time, or China standard time? Just to name a few — there's probably others as well. Even then this would require tzdb integration, which is tracked in #193. |
I'll take a look at that RFC. Hopefully the implementation of this will cover parsing the
Yes, you're absolutely right. I wish the format would be more like ISO-8601 and use either an explicit hours/minutes offset or
Yes, saw that issue, that would be very helpful as an addition I think. Hopefully for static builds it would also be possible to bundle the timezone file into the binary to make sure there are no system dependencies at runtime. |
@jhpratt I have added a pull request to improve documentation at time-rs/book#2. |
Closing for the reason of ambiguity as stated above. |
I'm building a simple demo application which maintains a list of X509 certificates obtained from www.googleapis.com/oauth2/v1/certs. These certificates are used in Google's OAuth flow, these certificates sign and can be used to verify the returned JWT tokens. As part of my demo, I'm writing a service to wrap my certificate store which runs at an interval to refresh the certificates, based on the value of the
expires
HTTP header.I'm using
time
because of thelocaltime_r
security issue inchrono
. I know it's fairly rare, but I like to have my code passcargo audit
.Essentially this boils down to a loop:
I was able to figure out how to parse datetimes using the
format_description!
macro; it wasn't easy but I was able to compile a description:The format of the
expires
header looks like this:This is a well-known and widely used format described in RFC 7231.
I've written a test case:
This unfortunately fails at runtime:
The only way I can get this to work is:
Thu, 06 Jan 2022 02:53:35 00:00
, replacingGMT
with the hours/minutes UTC offset.[offset_hour padding:zero]:[offset_minute padding:zero]
to the format description.In the format description documentation, I don't see a way to specify a timezone by name, which makes parsing this HTTP date string impossible.
I can probably work around this issue by using regular expressions and another crate to replace the timezone name with the hours/minutes offset, but if this crate is going to be the default choice for the Rust community for datetime formatting/parsing/etc. we should probably support parsing timezones by name.
Is there any way that I can help with a fix?
The text was updated successfully, but these errors were encountered: