Hi, first: great package - thank you very much for it.
I have this function for determining if a year is a leap year, may you want to integrate it? Can be very useful, for example for date pickers:
isLeapYear : Int -> Bool
isLeapYear year =
case modBy 4 year of
0 ->
if String.endsWith "00" (String.fromInt year) then
case modBy 400 year of
0 ->
True
_ ->
False
else
True
_ ->
False
suite : Test
suite =
describe "A leap year is divisible by 4 when it's not the last year of a century (e.g. 1800) that is not divisible by 400 (e.g. 2000)"
[ test "2019 is not a leap year" <|
\_ -> False |> Expect.equal (Date.isLeapYear 2019)
, test "2020 is a leap year" <|
\_ -> True |> Expect.equal (Date.isLeapYear 2020)
, test "2000 is a leap year" <|
\_ -> True |> Expect.equal (Date.isLeapYear 2000)
, test "2100 is not a leap year" <|
\_ -> False |> Expect.equal (Date.isLeapYear 2100)
]