roc-lang / basic-webserver

A basic webserver in Roc

Home Page:https://roc-lang.github.io/basic-webserver/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

imclerran opened this issue · comments

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 >.