about summary refs log tree commit diff
path: root/src/main.zig
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-09-23 23:46:34 +0200
committerRobert Günzler <r@gnzler.io>2026-10-02 10:39:47 +0200
commit3a6b743935593d21ca8abd286f881f2a9b153a66 (patch)
treeffb0ad311ae70913bf458d6775c8f00984fbb38a /src/main.zig
parentb076ad7f7889a4290091231f9803affdc227553b (diff)
downloadsite-3a6b743935593d21ca8abd286f881f2a9b153a66.tar.gz
write mtime
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 8432917..27aa316 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,3 +1,7 @@
+const C = @cImport({
+    @cInclude("time.h");
+});
+
 const std = @import("std");
 const Io = std.Io;
 const Allocator = std.mem.Allocator;
@@ -541,6 +545,13 @@ const Builder = struct {
             try w.writeAll(self.source.path);
             return;
         }
+        if (std.mem.eql(u8, ref_name, "builtin.mtime")) {
+            var buf: [BUFFER_SIZE]u8 = undefined;
+            const tm: isize = @intCast(self.source.mtime.toSeconds());
+            const n = C.strftime(&buf, buf.len, "%F", C.localtime(&tm));
+            try w.writeAll(buf[0..n]);
+            return;
+        }
         // TODO: other builtins?
 
         switch (ref_name[0]) {