Skip to content

Commit 1cf746b

Browse files
committed
io: Translate Windows Clock.real timestamps to the POSIX/Unix epoch
This fixes `std.http.Client` TLS certificate validation on Windows.
1 parent 74900e9 commit 1cf746b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/std/Io/Threaded.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,8 @@ fn nowWindows(userdata: ?*anyopaque, clock: Io.Clock) Io.Clock.Error!Io.Timestam
28642864
.real => {
28652865
// RtlGetSystemTimePrecise() has a granularity of 100 nanoseconds
28662866
// 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 };
28682869
},
28692870
.awake, .boot => {
28702871
// QPC on windows doesn't fail on >= XP/2000 and includes time suspended.

0 commit comments

Comments
 (0)