The following runs fine:
use chrono::{DateTime};
fn main() {
let parse_from_str = DateTime::parse_from_str;
let ts = "2000-01-01T01:23+01:00";
let fmt = "%Y-%m-%dT%H:%M%z";
let parsed = parse_from_str(ts, fmt);
println!("{:?}", parsed);
}
runs fine and returns
Ok(2000-01-01T01:23:00+01:00)
However, if I instead put
let ts = "2000-01-01T01:23Z";
then it fails:
Err(ParseError(Invalid))
By contrast, in Python, I can parse that string using this format:
In [1]: import datetime as dt
In [2]: dt.datetime.strptime("2000-01-01T01:23Z", "%Y-%m-%dT%H:%M%z")
Out[2]: datetime.datetime(2000, 1, 1, 1, 23, 0, tzinfo=datetime.timezone.utc)
Which one is right?
NOTE: I'm aware that I could get this one to parse using let fmt = "%+";
. I'm just asking if there's a way to parse it by specifying the full format string explicitly