-
Notifications
You must be signed in to change notification settings - Fork 545
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
confusing deprecation notice for chrono::TimeZone::datetime_from_str
#1381
Comments
Can you use the
|
hum ... from the docs for
My input string does not have a timezone, but I know that it's a UTC timestamp. So should I use a NaiveDateTime? But |
Indeed, using |
You probably want to parse the input as a NaiveDateTime::parse_from_str(foo, "%Y-%m-%d %H:%M").unwrap().and_utc(); |
Yup, this works, thank you! Maybe the deprecation warning could mention both |
It does since 0.4.32, released two days ago (see #1342) 😄. |
Ah! Thank you. I probably did not notice because 0.4.32 failed to build on docs.rs. |
I'm regularly using something like
Utc.datetime_from_str(foo, "%Y-%m-%d %H:%M")
in my projects to parse timestamps into aDatetime<Utc>
, and I'm now getting deprecation warnings for that.I tried replacing those calls with
DateTime::parse_from_str
as it's documented in the deprecation warning - but that returns aDatetime<FixedOffset>
, and I do not see a way to convert aDatetime<FixedOffset>
into aDatetime<Utc>
(at least no obvious ones), so it is not a direct replacement. Reading the documentation, I'm also unsure whether it's even semantically equivalent.Changing the type of any parsed timestamps to
Datetime<FixedOffset>
everywhere would be a pretty tedious ... is there a way to convert aDatetime<FixedOffset>
to aDatetime<Utc>
to get back the previous return type?The text was updated successfully, but these errors were encountered: