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

Can't parse datetime from another timezone #255

Open
achntrl opened this Issue Jun 20, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@achntrl
Copy link

achntrl commented Jun 20, 2018

I noticed that I can't parse a date with another offset than mine.

I'm in the +0200 timezone:

extern crate chrono;

use chrono::{Local, TimeZone};

fn main() {
    let working_input_string = "05/Jun/2018:20:55:45 +0200";
    match Local.datetime_from_str(working_input_string,"%d/%b/%Y:%T %z") {
        Ok(d) => println!("{:?}", d),  
        Err(err) => println!("{}", err),
    }  // This will Ok and print the date: 2018-06-05T20:55:45+02:00

    let failing_input_string = "05/Jun/2018:20:55:45 +0300";
    match Local.datetime_from_str(failing_input_string,"%d/%b/%Y:%T %z") {
        Ok(d) => println!("{:?}", d),
        Err(err) => println!("{}", err), 
    }  // This will Err and print "no possible date and time matching input"
}

I would have expected failing_input_string to be parsed as 2018-06-05T19:55:45+02:00. Is that something that we shouldn't do or is this a missing feature / a bug ?

There is the same issue with Utc: in that case I can parse "05/Jun/2018:20:55:45 +0000" but not any other offset

@achntrl achntrl changed the title Can't parse from another timezone Can't parse datetime from another timezone Jun 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment