diff --git a/main.zig b/main.zig index e6426001333ede53510cf3e1ebf50217e482ff06..b1febcf680a765f3c3a0287175d010d23449b91d 100644 --- a/main.zig +++ b/main.zig @@ -125,6 +125,26 @@ comptime { .{ "x", "1144509852789" }, .{ "X", "1144509852" }, + + .{ time.format.LT, "3:24 PM" }, + + .{ time.format.LTS, "3:24:12 PM" }, + + .{ time.format.L, "04/08/2006" }, + + .{ time.format.l, "4/8/2006" }, + + .{ time.format.LL, "April 8, 2006" }, + + .{ time.format.ll, "Apr 8, 2006" }, + + .{ time.format.LLL, "April 8, 2006 3:24 PM" }, + + .{ time.format.lll, "Apr 8, 2006 3:24 PM" }, + + .{ time.format.LLLL, "Saturday, April 8, 2006 3:24 PM" }, + + .{ time.format.llll, "Sat, Apr 8, 2006 3:24 PM" }, }); // https://github.com/nektro/zig-time/issues/3 diff --git a/time.zig b/time.zig index dbd0270c0b1eb5ad8ff0295768ca098edaf6824a..91a27a889618900173d61f601308f784eb2d205c 100644 --- a/time.zig +++ b/time.zig @@ -311,6 +311,7 @@ pub const DateTime = struct { '.', 'T', 'W', + '/', => { try writer.writeAll(&.{c}); s = i + 1; @@ -403,16 +404,16 @@ pub const DateTime = struct { }; pub const format = struct { - pub const LT = ""; - pub const LTS = ""; - pub const L = ""; - pub const l = ""; - pub const LL = ""; - pub const ll = ""; - pub const LLL = ""; - pub const lll = ""; - pub const LLLL = ""; - pub const llll = ""; + pub const LT = "h:mm A"; + pub const LTS = "h:mm:ss A"; + pub const L = "MM/DD/YYYY"; + pub const l = "M/D/YYY"; + pub const LL = "MMMM D, YYYY"; + pub const ll = "MMM D, YYY"; + pub const LLL = LL ++ " " ++ LT; + pub const lll = ll ++ " " ++ LT; + pub const LLLL = "dddd, " ++ LLL; + pub const llll = "ddd, " ++ lll; }; pub const TimeZone = enum {