╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ timestamp.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
28 const count = elapsed / unit.seconds; 29 return aa.print("{s}{d} {s}{s}{s}", .{ if (future) "in " else "", count, unit.name, if (count == 1) "" else "s", if (future) "" else " ago" }); 30 } 31 unreachable; 32 } 33 34 // compact utc, including seconds; z is the utc designator. 35 fn exact(aa: std.mem.Allocator, timestamp: u64) ![]const u8 { 36 const seconds = std.time.epoch.EpochSeconds{ .secs = timestamp }; 37 const year = seconds.getEpochDay().calculateYearDay(); 38 const month = year.calculateMonthDay(); 39 const day = seconds.getDaySeconds(); 40 return aa.print("{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}Z", .{ year.year, month.month.numeric(), month.day_index + 1, day.getHoursIntoDay(), day.getMinutesIntoHour(), day.getSecondsIntoMinute() }); 41 } 42