waltzofpearls / dateparser

Parse dates in commonly used string formats with Rust.
MIT License
41 stars 8 forks source link

Parse with left-aligned milli/micro/nanoseconds #23

Closed gyfis closed 2 years ago

gyfis commented 2 years ago

Hi! I think it's reasonable to always parse times with left-aligned milliseconds - otherwise whatever is after the dot is parsed as nanoseconds, leading to (what I assume are) unexpected results.

Before the change:

println!("{:?}", parse_datetime("2022-08-16 19:37:03.123 UTC").unwrap()); 
// 2022-08-16T19:37:03.000000123Z

After:

println!("{:?}", parse_datetime("2022-08-16 19:37:03.123 UTC").unwrap()); 
// 2022-08-16T19:37:03.123Z
waltzofpearls commented 2 years ago

@gyfis, thanks for the PR! Make sense. I will merge this PR first, and then fix unit tests linter errors in a separate branch, before tagging another release.

gyfis commented 2 years ago

@waltzofpearls Thanks a lot for the swift merge! Apologies for not fixing the tests 🙈

waltzofpearls commented 2 years ago

@gyfis No worries :)

Thanks again for your contribution. Also your PR reminded me that I need to take a good care of this repo and the dateparser lib. Keep it updated.