prost icon indicating copy to clipboard operation
prost copied to clipboard

bug: From implementation (DateTime -> Timestamp)

Open binarynewts opened this issue 2 years ago • 2 comments

This implementation of the From trait may have some errors: https://github.com/tokio-rs/prost/blob/468c80cd343321d5d4b361febbeec832ab5228b6/prost-types/src/datetime.rs#L576

Examples of DateTimes unable to be converted to Timestamps were:

  1. panicked at 'attempt to subtract with overflow', https://github.com/tokio-rs/prost/blob/468c80cd343321d5d4b361febbeec832ab5228b6/prost-types/src/datetime.rs#L421 year: vec![178, 2, 0, 0, 0, 0, 0, 128] month: vec![2] day: vec![2] hour: vec![8] minute: vec![58] second: vec![8] nanos: vec![0, 0, 0, 50]

  2. panicked at 'attempt to subtract with overflow', https://github.com/tokio-rs/prost/blob/468c80cd343321d5d4b361febbeec832ab5228b6/prost-types/src/datetime.rs#L441 year: vec![132, 7, 0, 0, 0, 0, 0, 128] month: vec![2] day: vec![2] hour: vec![8] minute: vec![58] second: vec![8] nanos: vec![0, 0, 0, 50]

  3. panicked at 'attempt to multiply with overflow', https://github.com/tokio-rs/prost/blob/468c80cd343321d5d4b361febbeec832ab5228b6/prost-types/src/datetime.rs#L479C8-L479C8 year: vec![80, 96, 32, 240, 99, 0, 32, 180] month: vec![1] day: vec![18] hour: vec![19] minute: vec![26] second: vec![8] nanos: vec![0, 0, 0, 50]

binarynewts avatar Aug 03 '23 19:08 binarynewts

@danburkert if you have the time can you take a look

LucioFranco avatar Aug 11 '23 16:08 LucioFranco

@binarynewts Can you confirm that #1095 fixes this problem?

caspermeijn avatar Jul 05 '24 14:07 caspermeijn