update: receive Time

This commit is contained in:
Lucas F. 2026-01-16 18:20:15 -03:00
parent 5ff94ccf17
commit c4319f5da3

View file

@ -1,4 +1,6 @@
const std = @import("std"); const std = @import("std");
const time = @import("time.zig");
const util = @import("util.zig");
pub const Value = union(enum) { pub const Value = union(enum) {
null, null,
@ -36,6 +38,10 @@ pub const Context = struct {
fn toValue(self: *Context, value: anytype) !Value { fn toValue(self: *Context, value: anytype) !Value {
const T = @TypeOf(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)) { return switch (@typeInfo(T)) {
.bool => Value{ .bool = value }, .bool => Value{ .bool = value },
.int, .comptime_int => Value{ .int = @intCast(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); 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 { // 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.map.get(key) orelse return error.KeyNotFound;
// const opt_value = self.getOptional(T, key); // const opt_value = self.getOptional(T, key);