| ... | ... | @@ -169,11 +169,15 @@ pub const DateTime = struct { |
| 169 | 169 | return if (self.isLeapYear()) 366 else 365; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | | pub fn daysThisMonth(self: Self) u64 { |
| 173 | | const norm = [12]u64{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 174 | | const leap = [12]u64{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 172 | pub fn daysThisMonth(self: Self) u16 { |
| 173 | return self.daysInMonth(self.months); |
| 174 | } |
| 175 | |
| 176 | fn daysInMonth(self: Self, month: u16) u16 { |
| 177 | const norm = [12]u16{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 178 | const leap = [12]u16{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 175 | 179 | const month_days = if (!self.isLeapYear()) norm else leap; |
| 176 | | return month_days[self.months]; |
| 180 | return month_days[month]; |
| 177 | 181 | } |
| 178 | 182 | |
| 179 | 183 | fn incrementWeekday(self: *Self, count: u64) void { |