From ed7f2588e409b6d154f4a08bd0029ef1e7beb06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20=C3=85stholm?= Date: Wed, 5 Nov 2025 00:50:19 +0100 Subject: [PATCH] io: Translate Windows `Clock.real` timestamps to the POSIX/Unix epoch This fixes `std.http.Client` TLS certificate validation on Windows. --- lib/std/Io/Threaded.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 11f9b149ca..58febae64a 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -2864,7 +2864,8 @@ fn nowWindows(userdata: ?*anyopaque, clock: Io.Clock) Io.Clock.Error!Io.Timestam .real => { // RtlGetSystemTimePrecise() has a granularity of 100 nanoseconds // and uses the NTFS/Windows epoch, which is 1601-01-01. - return .{ .nanoseconds = @as(i96, windows.ntdll.RtlGetSystemTimePrecise()) * 100 }; + const epoch_ns = std.time.epoch.windows * std.time.ns_per_s; + return .{ .nanoseconds = @as(i96, windows.ntdll.RtlGetSystemTimePrecise()) * 100 + epoch_ns }; }, .awake, .boot => { // QPC on windows doesn't fail on >= XP/2000 and includes time suspended.