about summary refs log tree commit diff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to '')
-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]) {