diff --git a/src/context.zig b/src/context.zig index 63da514..4885974 100644 --- a/src/context.zig +++ b/src/context.zig @@ -1,4 +1,6 @@ const std = @import("std"); +const time = @import("time.zig"); +const util = @import("util.zig"); pub const Value = union(enum) { null, @@ -36,6 +38,10 @@ pub const Context = struct { fn toValue(self: *Context, value: anytype) !Value { const T = @TypeOf(value); + if (T == time.Time) { + return Value{ .string = try time.formatDateTime(self.allocator(), value, "Y-m-d H:i:s") }; + } + return switch (@typeInfo(T)) { .bool => Value{ .bool = value }, .int, .comptime_int => Value{ .int = @intCast(value) }, @@ -109,6 +115,11 @@ pub const Context = struct { return self.get(path) orelse try self.toValue(default); } + fn isArrayList(value: anytype) bool { + if (std.mem.startsWith(u8, @typeName(value), "array_list")) return true; + return false; + } + // pub fn get(self: *const Context, comptime T: type, key: []const u8) !T { // // const opt_value = self.map.get(key) orelse return error.KeyNotFound; // const opt_value = self.getOptional(T, key);