authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-02-27 15:48:38 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-02-27 15:48:38 -08:00
loga22054de725ef19b3f91b9ad960d4093f852b7e0
tree301a4233a4d2e190469f6da85af7d5129e91dd79
parent2527d016432cb34e042bedd3530b480c5a8a1c74

fix jsonStringify support in the enums


2 files changed, 5 insertions(+), 12 deletions(-)

time.zig+4-12
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const string = []const u8;2const string = []const u8;
3const range = @import("range").range;3const range = @import("range").range;
4const extras = @import("extras");
4const time = @This();5const time = @This();
56
6pub const DateTime = struct {7pub const DateTime = struct {
...@@ -405,10 +406,7 @@ pub const format = struct {...@@ -405,10 +406,7 @@ pub const format = struct {
405pub const TimeZone = enum {406pub const TimeZone = enum {
406 UTC,407 UTC,
407408
408 pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void {409 usingnamespace extras.TagNameJsonStringifyMixin(@This());
409 _ = options;
410 try out_stream.writeAll(@tagName(self));
411 }
412};410};
413411
414pub const WeekDay = enum {412pub const WeekDay = enum {
...@@ -432,20 +430,14 @@ pub const WeekDay = enum {...@@ -432,20 +430,14 @@ pub const WeekDay = enum {
432 };430 };
433 }431 }
434432
435 pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void {433 usingnamespace extras.TagNameJsonStringifyMixin(@This());
436 _ = options;
437 try out_stream.writeAll(@tagName(self));
438 }
439};434};
440435
441pub const Era = enum {436pub const Era = enum {
442 // BC,437 // BC,
443 AD,438 AD,
444439
445 pub fn jsonStringify(self: @This(), options: std.json.StringifyOptions, out_stream: anytype) !void {440 usingnamespace extras.TagNameJsonStringifyMixin(@This());
446 _ = options;
447 try out_stream.writeAll(@tagName(self));
448 }
449};441};
450442
451pub fn isLeapYear(year: u16) bool {443pub fn isLeapYear(year: u16) bool {
zig.mod+1
...@@ -5,3 +5,4 @@ license: MIT...@@ -5,3 +5,4 @@ license: MIT
5description: A date and time parsing and formatting library for Zig.5description: A date and time parsing and formatting library for Zig.
6dependencies:6dependencies:
7 - src: git https://github.com/nektro/zig-range7 - src: git https://github.com/nektro/zig-range
8 - src: git https://github.com/nektro/zig-extras