Heavily improve time handling on Windows for time.now() and os.File_Info

This commit is contained in:
gingerBill
2022-10-26 16:05:49 +01:00
parent 7743e34596
commit 7bcde35651
6 changed files with 77 additions and 49 deletions
+10 -3
View File
@@ -7,9 +7,16 @@ _IS_SUPPORTED :: true
_now :: proc "contextless" () -> Time {
file_time: win32.FILETIME
win32.GetSystemTimeAsFileTime(&file_time)
ns := win32.FILETIME_as_unix_nanoseconds(file_time)
return Time{_nsec=ns}
ns: i64
// monotonic
win32.GetSystemTimePreciseAsFileTime(&file_time)
dt := u64(transmute(u64le)file_time) // in 100ns units
ns = i64((dt - 116444736000000000) * 100) // convert to ns
return unix(0, ns)
}
_sleep :: proc "contextless" (d: Duration) {