diff --git a/lib/std/Io.zig b/lib/std/Io.zig index 810a7a8102b2..f648322a8474 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -734,7 +734,7 @@ pub const Clock = enum { /// A settable system-wide clock that measures real (i.e. wall-clock) /// time. This clock is affected by discontinuous jumps in the system /// time (e.g., if the system administrator manually changes the - /// clock), and by frequency adjust‐ ments performed by NTP and similar + /// clock), and by frequency adjustments performed by NTP and similar /// applications. /// /// This clock normally counts the number of seconds since 1970-01-01 @@ -742,8 +742,8 @@ pub const Clock = enum { /// leap seconds; near a leap second it is typically adjusted by NTP to /// stay roughly in sync with UTC. /// - /// The epoch is implementation-defined. For example NTFS/Windows uses - /// 1601-01-01. + /// The epoch is 1970-01-01T00:00:00Z, which corresponds to a clock + /// value of zero. real, /// A nonsettable system-wide clock that represents time since some /// unspecified point in the past. diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 11f9b149caf5..3f17f53e554e 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_100_ns = std.time.epoch.windows * (std.time.ns_per_s / 100); + return .{ .nanoseconds = @as(i96, windows.ntdll.RtlGetSystemTimePrecise() + epoch_100_ns) * 100 }; }, .awake, .boot => { // QPC on windows doesn't fail on >= XP/2000 and includes time suspended.