authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-24 21:54:49 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-24 21:54:49 -07:00
log064b4482ae1b0087693be98ae23f3d47d163f2a6
tree85f1d815332c70ce5b871c1870e276362019742f
parentbd98ef8f4c11db600f5c6ff2c73ff4a10159dcf8

add timezone printers (locked at utc for now)


2 files changed, 8 insertions(+), 2 deletions(-)

main.zig+4-1
...@@ -111,6 +111,9 @@ comptime {...@@ -111,6 +111,9 @@ comptime {
111 .{ "S", "7" },111 .{ "S", "7" },
112 .{ "SS", "78" },112 .{ "SS", "78" },
113 .{ "SSS", "789" },113 .{ "SSS", "789" },
114
115 .{ "z", "UTC" },
116 .{ "Z", "+00:00" },
117 .{ "ZZ", "+0000" },
114 });118 });
115}119}
116
time.zig+4-1
...@@ -227,7 +227,6 @@ pub const DateTime = struct {...@@ -227,7 +227,6 @@ pub const DateTime = struct {
227 .DD => try writer.print("{:0>2}", .{self.days + 1}),227 .DD => try writer.print("{:0>2}", .{self.days + 1}),
228 .YYYY => try writer.print("{:0>4}", .{self.years}),228 .YYYY => try writer.print("{:0>4}", .{self.years}),
229 .MM => try writer.print("{:0>2}", .{self.months + 1}),229 .MM => try writer.print("{:0>2}", .{self.months + 1}),
230 .z => try writer.writeAll(@tagName(self.timezone)),
231 .M => try writer.print("{}", .{self.months + 1}),230 .M => try writer.print("{}", .{self.months + 1}),
232 .Mo => try printOrdinal(writer, self.months + 1),231 .Mo => try printOrdinal(writer, self.months + 1),
233 .MMM => try printLongName(writer, self.months, &[_]string{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }),232 .MMM => try printLongName(writer, self.months, &[_]string{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }),
...@@ -268,6 +267,10 @@ pub const DateTime = struct {...@@ -268,6 +267,10 @@ pub const DateTime = struct {
268 .SS => try writer.print("{:0>2}", .{self.ms / 10}),267 .SS => try writer.print("{:0>2}", .{self.ms / 10}),
269 .SSS => try writer.print("{:0>3}", .{self.ms}),268 .SSS => try writer.print("{:0>3}", .{self.ms}),
270269
270 .z => try writer.writeAll(@tagName(self.timezone)),
271 .Z => try writer.writeAll("+00:00"),
272 .ZZ => try writer.writeAll("+0000"),
273
271 else => @compileError("'" ++ @tagName(tag) ++ "' not currently supported"),274 else => @compileError("'" ++ @tagName(tag) ++ "' not currently supported"),
272 }275 }
273 next = null;276 next = null;