authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-23 18:09:36 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-23 18:09:36 -07:00
logf824ecbf41935e1fcbd84360cf679ddbcf4c67ca
tree7a03e247de579c7e0116a13596e22b7e563c5ee8
parent237b728736900863ba21eccab5ffa68d1df0a644

add dayOfThisYear


1 files changed, 9 insertions(+), 0 deletions(-)

time.zig+9
...@@ -186,6 +186,15 @@ pub const DateTime = struct {...@@ -186,6 +186,15 @@ pub const DateTime = struct {
186 }186 }
187 }187 }
188188
189 pub fn dayOfThisYear(self: Self) u16 {
190 var ret: u16 = 0;
191 for (range(self.months)) |_, item| {
192 ret += self.daysInMonth(@intCast(u16, item));
193 }
194 ret += self.days;
195 return ret;
196 }
197
189 /// fmt is based on https://momentjs.com/docs/#/displaying/format/198 /// fmt is based on https://momentjs.com/docs/#/displaying/format/
190 pub fn format(self: Self, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void {199 pub fn format(self: Self, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) !void {
191 _ = options;200 _ = options;