time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.06k stars 261 forks source link

fix unsigned to signed conversion bug #656

Closed GregoryLakewood closed 5 months ago

GregoryLakewood commented 5 months ago

Casting u32 into i32 and then extending into i64 does not hold the value when val_u32 > i32::MAX. As explained in Microsoft Documentation one should firstly construct u64 from FILETIME and then perform arithmetics.

jhpratt commented 5 months ago

LGTM. As this won't affect (non-artificial) timestamps for 14 years, I won't be cutting a release specifically for this.

GregoryLakewood commented 5 months ago

Thank you. @jhpratt Could you look into this? I found this bug because I am getting Err(IndeterminateOffset) on my machine. That breaks some Rust tools I use, specifically probe-rs. From my understanding 31bit in lower FILETIME DWORD toggles every 2^31*100 nanoseconds what equals roughly 3 and half minutes.

jhpratt commented 5 months ago

Ha, I wasn't thinking of the fact that it represents 100 nanosecond intervals. I was only off by a factor of ten million.

I'll be having another release later today.

jhpratt commented 5 months ago

Released.