Skip to content
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

Parsing Bug #1608

Open
alirezabeygi803 opened this issue Aug 10, 2024 · 1 comment
Open

Parsing Bug #1608

alirezabeygi803 opened this issue Aug 10, 2024 · 1 comment

Comments

@alirezabeygi803
Copy link

alirezabeygi803 commented Aug 10, 2024

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
Copy link
Member

djc commented Aug 19, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants