From cbba4db4e7f716ba799dc2c65f2df6ddc433c1ac Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 15 Oct 2024 16:33:59 +0200 Subject: format page edit time using strftime and only display %F MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/main.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 6cf86a5..392a75c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -150,8 +150,15 @@ fn build(allocator: std.mem.Allocator, f: std.fs.File, page_name: []const u8, sr defer allocator.free(srcpathZ); _ = std.os.linux.stat(srcpathZ, attr); const mtime = attr.mtime(); - const mtime_str = c.ctime(&mtime.tv_sec); - break :blk std.mem.span(mtime_str); + // const mtime_str = c.ctime(&mtime.tv_sec); + var mtime_str: [200]u8 = undefined; + const n = c.strftime( + &mtime_str, + mtime_str.len, + "%F", + c.localtime(&mtime.tv_sec), + ); + break :blk mtime_str[0..n]; }; // HEAD -- cgit 1.4.1