Skip to content

Commit ef7bfbd

Browse files
fix unsigned to signed conversion bug (#656)
1 parent 76468cb commit ef7bfbd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

time/src/sys/local_offset_at/windows.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ fn systemtime_to_filetime(systime: &SystemTime) -> Option<FileTime> {
5959
/// Convert a `FILETIME` to an `i64`, representing a number of seconds.
6060
fn filetime_to_secs(filetime: &FileTime) -> i64 {
6161
/// FILETIME represents 100-nanosecond intervals
62-
const FT_TO_SECS: i64 = Nanosecond::per(Second) as i64 / 100;
63-
(filetime.dwHighDateTime.cast_signed().extend::<i64>() << 32
64-
| filetime.dwLowDateTime.cast_signed().extend::<i64>())
65-
/ FT_TO_SECS
62+
const FT_TO_SECS: u64 = Nanosecond::per(Second) as u64 / 100;
63+
((filetime.dwHighDateTime.extend::<u64>() << 32 | filetime.dwLowDateTime.extend::<u64>())
64+
/ FT_TO_SECS) as i64
6665
}
6766

6867
/// Convert an [`OffsetDateTime`] to a `SYSTEMTIME`.

0 commit comments

Comments
 (0)