aboutsummaryrefslogtreecommitdiff
path: root/src/time.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/time.zig')
-rw-r--r--src/time.zig8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/time.zig b/src/time.zig
index 290c9de..9c162e2 100644
--- a/src/time.zig
+++ b/src/time.zig
@@ -83,7 +83,7 @@ pub const Time = struct {
};
}
- pub fn format(self: Time, w: *std.io.Writer) std.io.Writer.Error!void {
+ pub fn format(self: Time, w: *std.Io.Writer) std.Io.Writer.Error!void {
try w.print(
"{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2} UTC",
.{ self.year, self.month, self.day, self.hour, self.minute, self.second },
@@ -92,8 +92,10 @@ pub const Time = struct {
};
pub fn now() u64 {
- const ts = std.posix.clock_gettime(.REALTIME) catch return 0;
- return if (ts.sec < 0) 0 else @intCast(ts.sec);
+ var ts: std.posix.timespec = undefined;
+ const res = std.posix.system.clock_gettime(std.posix.CLOCK.REALTIME, &ts);
+ if (res < 0 or ts.sec < 0) return 0;
+ return @intCast(ts.sec);
}
test "time from timestamp" {