stevedonovan / chrono-english

Converting informal English dates (like `date` command) to chrono DateTime in Rust
MIT License
57 stars 14 forks source link

[regression] support "YYYY-MM-DD HH:MM:SS" #2

Closed vincentdephily closed 5 years ago

vincentdephily commented 5 years ago
println!("{:?}", parse_date_string("2018-04-03 00:00:00 +00:00", Local::now(), Dialect::Uk));

This prints Ok(2018-04-03T00:00:00+01:00) with chrono-english 0.1.2 but Err(DateError { details: "iden expected, got Char(\'+\')" }) with chrono-english 0.1.3.

Even adding a T in the input string (making it strictly iso86010-compliant)... I know this crate's purpose is to parse weird dates, but it should also be able to parse standard ones ;)

This happens with my system configured with LC_TIME=en_DK.UTF-8 as well as LC_TIME=en_US.utf8.

For what it's worth, I caught this with the unit test at https://github.com/vincentdephily/emlop/blob/master/src/main.rs#L302

vincentdephily commented 5 years ago

Actually, testing further shows that 0.1.2 didn't support 2018-04-03T00:00:00 either (it can't make sense of the T, but parses a space correctly) and ignored the +00:00 (it assumes the local timezone). Parsing T and the timezone are desirable features, but not a regression (should a separate issue be opened ?).

vincentdephily commented 5 years ago

Ok there's arguably no regression in the support of YYYY-MM-DD HH:MM:SS: it's just the timezone part that used to be ignored but now raises an error. I'd say 0.1.3 has the correct behaviour, because we don't want the user to think that the tz has been parsed when it hasn't. I'll close this and open different issues for parsing T and +HH:MM.