chrono icon indicating copy to clipboard operation
chrono copied to clipboard

0.4.42 inconsistent NaiveDateTime parsing behavior

Open thill opened this issue 3 months ago • 3 comments

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)

thill avatar Sep 11 '25 14:09 thill

So just use %.f instead?

djc avatar Sep 11 '25 14:09 djc

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.

thill avatar Sep 11 '25 14:09 thill

Just FYI: Broke my CI, too. Yet %.f fixed it.

pacman82 avatar Sep 11 '25 20:09 pacman82