Skip to content

Commit 72ab962

Browse files
authored
Correct leap year calculation (#66)
A leap year is every four years, except for years that are a multiple of 100 and not a multiple of 400.
1 parent 7dd5603 commit 72ab962

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/Deserializer/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ func localDateUTF8(_ utf8: inout Substring.UTF8View) -> (Int, Int, Int)?? {
13471347
return .some(nil)
13481348
}
13491349

1350-
let isLeapYear = year % 4 == 0 && year % 100 != 0
1350+
let isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
13511351
if (month == 3 || month == 6 || month == 9 || month == 11) && day > 30 ||
13521352
month == 2 && !isLeapYear && day > 28 ||
13531353
month == 2 && isLeapYear && day > 29 ||

0 commit comments

Comments
 (0)