chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Parsing Bug

Open alirezabeygi803 opened this issue 1 year ago • 1 comments

I am trying to run the following Code on a Windows 11 machine, latest chrono version, latest Rust version, but it fails with the error mentioned below:

let date = "Thu Feb 21 23:30:39 2012";
    let date = DateTime::parse_from_str(date, "%a %b %d %H:%M:%S %Y");

    if let Ok(x) = date {
        dbg!(&x);
    } else if let Err(x) = date {
        dbg!(&x);
    }
[src/main.rs:179:9] &x = ParseError(
    Invalid,
)

Am I doing something wrong or is this a bug?

alirezabeygi803 avatar Aug 10 '24 12:08 alirezabeygi803

A DateTime must include a timezone. Your formatting string does not include any timezone formatter. Perhaps you want to parse a NaiveDateTime instead and supply the timezone separately?

djc avatar Aug 19 '24 09:08 djc