chrono
chrono copied to clipboard
0.4.42 inconsistent NaiveDateTime parsing behavior
The following test passes on 0.4.41 and earlier, but not 0.4.42:
#[test]
fn test() {
let result = NaiveDateTime::parse_from_str("20230315-18:32:39.948667", "%Y%m%d-%H:%M:%S%.9f");
assert!(result.is_ok());
}
0.4.42 fails with TooShort, however it was parsed fine with earlier versions. This is pretty useful behavior as some systems will trim trailing 000s in timestamp sub-seconds.
(Target platform: 64-bit ubuntu linux)
So just use %.f instead?
Sure, but reporting this as it was a patch-level change and it has the ability to break CIs, as it did ours. Granted this lib is < 1.0.0. Thankfully we had tests for it.
Just FYI: Broke my CI, too. Yet %.f fixed it.