authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2025-11-05 00:50:19+01:00
committergravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2025-11-10 22:12:39+01:00
loged7f2588e409b6d154f4a08bd0029ef1e7beb06b
tree1a8a6d970e619b51c6cdf5e49acb4f80f92b452c
parentcbfa87cbea0274e1e88d6a61bba82a2099e19fd6

io: Translate Windows `Clock.real` timestamps to the POSIX/Unix epoch

This fixes `std.http.Client` TLS certificate validation on Windows.

1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+2-1
...@@ -2864,7 +2864,8 @@ fn nowWindows(userdata: ?*anyopaque, clock: Io.Clock) Io.Clock.Error!Io.Timestam...@@ -2864,7 +2864,8 @@ fn nowWindows(userdata: ?*anyopaque, clock: Io.Clock) Io.Clock.Error!Io.Timestam
2864 .real => {2864 .real => {
2865 // RtlGetSystemTimePrecise() has a granularity of 100 nanoseconds2865 // RtlGetSystemTimePrecise() has a granularity of 100 nanoseconds
2866 // and uses the NTFS/Windows epoch, which is 1601-01-01.2866 // and uses the NTFS/Windows epoch, which is 1601-01-01.
2867 return .{ .nanoseconds = @as(i96, windows.ntdll.RtlGetSystemTimePrecise()) * 100 };2867 const epoch_ns = std.time.epoch.windows * std.time.ns_per_s;
2868 return .{ .nanoseconds = @as(i96, windows.ntdll.RtlGetSystemTimePrecise()) * 100 + epoch_ns };
2868 },2869 },
2869 .awake, .boot => {2870 .awake, .boot => {
2870 // QPC on windows doesn't fail on >= XP/2000 and includes time suspended.2871 // QPC on windows doesn't fail on >= XP/2000 and includes time suspended.