| ... | @@ -509,12 +509,12 @@ pub const Era = enum { | ... | @@ -509,12 +509,12 @@ pub const Era = enum { |
| 509 | } | 509 | } |
| 510 | }; | 510 | }; |
| 511 | | 511 | |
| | 512 | // https://hueffner.de/falk/blog/a-leap-year-check-in-three-instructions.html |
| 512 | pub fn isLeapYear(year: u16) bool { | 513 | pub fn isLeapYear(year: u16) bool { |
| 513 | var ret = false; | 514 | if (year % 4 != 0) return false; |
| 514 | if (year % 4 == 0) ret = true; | 515 | if (year % 25 != 0) return true; |
| 515 | if (year % 100 == 0) ret = false; | 516 | if (year % 16 == 0) return true; |
| 516 | if (year % 400 == 0) ret = true; | 517 | return false; |
| 517 | return ret; | | |
| 518 | } | 518 | } |
| 519 | | 519 | |
| 520 | pub fn daysInYear(year: u16) u16 { | 520 | pub fn daysInYear(year: u16) u16 { |