diff --git a/time.zig b/time.zig index 4de255aba866707ad5054b3c66f5b0da1634084e..d0fe2f26b8d315b6a222d4676ccf098bd7e4f077 100644 --- a/time.zig +++ b/time.zig @@ -169,11 +169,15 @@ pub const DateTime = struct { return if (self.isLeapYear()) 366 else 365; } - pub fn daysThisMonth(self: Self) u64 { - const norm = [12]u64{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - const leap = [12]u64{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + pub fn daysThisMonth(self: Self) u16 { + return self.daysInMonth(self.months); + } + + fn daysInMonth(self: Self, month: u16) u16 { + const norm = [12]u16{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + const leap = [12]u16{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const month_days = if (!self.isLeapYear()) norm else leap; - return month_days[self.months]; + return month_days[month]; } fn incrementWeekday(self: *Self, count: u64) void {