size: 561 B
| 1 | const std = @import("std"); |
| 2 | const mem = std.mem; |
| 3 | |
| 4 | /// Returns current time in ISO 8601 format e.g. 2025-10-13T12:42:43+07:00 |
| 5 | /// Unfortunately zig doesn't have a standard datetime library yet so we're |
| 6 | /// shelling out to `date` here for convenience. |
| 7 | pub fn now(arena: mem.Allocator) ![]u8 { |
| 8 | var proc = try std.process.Child.run(.{ |
| 9 | .allocator = arena, |
| 10 | .argv = &.{ "date", "-Iseconds" }, |
| 11 | }); |
| 12 | std.debug.assert(proc.term.Exited == 0); |
| 13 | std.debug.assert(proc.stdout.len == 25 + 1); // with trailing \n |
| 14 | return proc.stdout[0..25]; |
| 15 | } |