aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-10-26 16:05:49 +0100
committergingerBill <bill@gingerbill.org>2022-10-26 16:05:49 +0100
commit7bcde35651619f5990234d3e084dcbfdc8e69db4 (patch)
tree3e9a9dab0d484627433475b808c1046cfd6dff1a /core/sys
parent7743e34596a8a369334d8e6c2ee872800907d6cb (diff)
Heavily improve time handling on Windows for `time.now()` and `os.File_Info`
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/windows/kernel32.odin10
-rw-r--r--core/sys/windows/types.odin13
2 files changed, 22 insertions, 1 deletions
diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin
index 304710be2..4f7d24ce8 100644
--- a/core/sys/windows/kernel32.odin
+++ b/core/sys/windows/kernel32.odin
@@ -249,6 +249,16 @@ foreign kernel32 {
GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE ---
GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) ---
GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) ---
+ FileTimeToSystemTime :: proc(lpFileTime: ^FILETIME, lpSystemTime: ^SYSTEMTIME) -> BOOL ---
+ SystemTimeToTzSpecificLocalTime :: proc(
+ lpTimeZoneInformation: ^TIME_ZONE_INFORMATION,
+ lpUniversalTime: ^SYSTEMTIME,
+ lpLocalTime: ^SYSTEMTIME,
+ ) -> BOOL ---
+ SystemTimeToFileTime :: proc(
+ lpSystemTime: ^SYSTEMTIME,
+ lpFileTime: LPFILETIME,
+ ) -> BOOL ---
CreateEventW :: proc(
lpEventAttributes: LPSECURITY_ATTRIBUTES,
bManualReset: BOOL,
diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin
index af28a9060..62b7d25a7 100644
--- a/core/sys/windows/types.odin
+++ b/core/sys/windows/types.odin
@@ -2267,9 +2267,10 @@ FILETIME :: struct {
FILETIME_as_unix_nanoseconds :: proc "contextless" (ft: FILETIME) -> i64 {
t := i64(u64(ft.dwLowDateTime) | u64(ft.dwHighDateTime) << 32)
- return (t - 0x019db1ded53e8000) * 100
+ return (t - 116444736000000000) * 100
}
+
OVERLAPPED :: struct {
Internal: ^c_ulong,
InternalHigh: ^c_ulong,
@@ -2943,6 +2944,16 @@ SYSTEMTIME :: struct {
milliseconds: WORD,
}
+TIME_ZONE_INFORMATION :: struct {
+ Bias: LONG,
+ StandardName: [32]WCHAR,
+ StandardDate: SYSTEMTIME,
+ StandardBias: LONG,
+ DaylightName: [32]WCHAR,
+ DaylightDate: SYSTEMTIME,
+ DaylightBias: LONG,
+}
+
@(private="file")
IMAGE_DOS_HEADER :: struct {