From 2527d016432cb34e042bedd3530b480c5a8a1c74 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 11 Feb 2022 01:59:48 -0800 Subject: [PATCH] add jsonStringify methods to the enums --- time.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/time.zig b/time.zig index 97b638d7298cf659fa97cf32f3bf5cde81c3c849..61581e1f08dcebd53c104a47d31bd8eefc0c2d7f 100644 --- a/time.zig +++ b/time.zig @@ -404,6 +404,11 @@ pub const format = struct { pub const TimeZone = enum { UTC, + + pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void { + _ = options; + try out_stream.writeAll(@tagName(self)); + } }; pub const WeekDay = enum { @@ -426,11 +431,21 @@ pub const WeekDay = enum { .Sat => .Sun, }; } + + pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void { + _ = options; + try out_stream.writeAll(@tagName(self)); + } }; pub const Era = enum { // BC, AD, + + pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void { + _ = options; + try out_stream.writeAll(@tagName(self)); + } }; pub fn isLeapYear(year: u16) bool { -- 2.54.0