Closed JiveyGuy closed 6 months ago
What is missing is an offset. DateTime::parse_from_str
expects the input to have a date, time and offset from UTC.
Can you try parsing to a NaiveDateTime
instead, which doesn't have this requirement, and then convert to a DateTime
?
let parse_from_str_result = NaiveDateTime::parse_from_str(time_str, "%Y-%m-%dT%H:%M:%S%.3fZ").and_utc();
B.t.w. you may be better off using DateTime::parse_from_rfc3339
. That is the format of your input string, and the specialized parser is faster and spec compliant.
Thanks that was the issue. I thought the ending Z was what was needed for TZ.
Version:
chrono = "0.4.35"
Code:Output:
What am I doing wrong? Or rather, is Datetime::parse_from_str broken?