╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────╮ │19 } else @import("ansi_art"); │ │20 const evt = @import("./event.zig"); │ │21 const inp = @import("./ui/input.zig"); │ │22 + │ │23 +pub const timestamp = @import("./ui/timestamp.zig");│ │24 │ │25 pub const Home = @import("./ui/Home.zig"); │ │26 pub const User = @import("./ui/User.zig"); │ ╰────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │2375 │ │2376 // serializable data sent down to web client │ │2377 pub const Data = struct { │ │2378 + // the server's reference time for relative timestamps on this page.│ │2379 + now: i64 = 0, │ │2380 user_id: ?[]const u8 = null, │ │2381 // the logged-in user's name and email, for the views that show them│ │2382 user_name: ?[]const u8 = null, │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2422 return session; │ │2423 } │ │2424 │ │2425 + // web views share the page's reference time; terminals use the live clock. │ │2426 + pub fn nowSeconds(self: *const Self) !i64 { │ │2427 + if (builtin.target.cpu.arch == .wasm32 or !self.is_terminal) return self.data.now; │ │2428 + const io = self.io orelse return error.NoClock; │ │2429 + return std.math.cast(i64, std.Io.Timestamp.now(io, .real).toSeconds()) orelse error.TimestampOutOfRange;│ │2430 + } │ │2431 + │ │2432 // load the logged-in user's name and persisted preferences from the db │ │2433 pub fn loadUser(self: *Self) !void { │ │2434 const user_id = self.userId() orelse return; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯