roc-lang / basic-webserver

A basic webserver in Roc
https://roc-lang.github.io/basic-webserver/
Universal Permissive License v1.0
76 stars 16 forks source link

Bug in InternalDateTime: epochMillisToDateTime does not correctly handle last day of month / year #24

Closed imclerran closed 9 months ago

imclerran commented 9 months ago

The following tests will fail with the current handling of converting millis to DateTime:

# test last day of 1st year after epoch
expect 
    str = epochMillisToDateTime (364 * 24 * 60 * 60 * 1000) |> toIso8601Str
    str == "1970-12-31T00:00.00Z"

# test last day of 1st month after epoch
expect
    str = epochMillisToDateTime (30 * 24 * 60 * 60 * 1000) |> toIso8601Str
    str == "1970-01-31T00:00.00Z"

Bug is due to use of >= in current.day > countDaysInMonth and current.day > countDaysInYear. Should be >.