chronotope / chrono

Date and time library for Rust
Other
3.35k stars 536 forks source link

Parsing Bug #1608

Open alirezabeygi803 opened 3 months ago

alirezabeygi803 commented 3 months ago

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?

djc commented 3 months ago

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?