Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDate.month crash with dates in the distant future #690
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Aug 11, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Aug 11, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
lukewestby
added
the
bug
label
Sep 12, 2016
evancz
changed the title from
Date.month causes problems and potential runtime errors with invalid dates
to
Date.month crash with dates in the distant future
Sep 23, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kuzux
Dec 27, 2016
Just managed to reproduce the crash using Date.fromTime 10000000000000000 |> Date.month in repl
edit: Looking more into it, it seems to be caused by V8 JS engine returning a NaN citing invalid range error in new Date(). When we try to do anything with it, it just crashes. Adding an isNaN check on Date.fromTime should suffice.
kuzux
commented
Dec 27, 2016
•
|
Just managed to reproduce the crash using edit: Looking more into it, it seems to be caused by V8 JS engine returning a NaN citing invalid range error in new Date(). When we try to do anything with it, it just crashes. Adding an isNaN check on Date.fromTime should suffice. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Tracking in #816 |
MrMovl commentedAug 11, 2016
If you manage to get an invalid date like
Date.fromTime 10000000000000000, everything works until you try something likenotADate |> Date.month |> toString |> Html.text. Then you get the runtime ErrorUncaught TypeError: Cannot read property 'substring' of undefinedIt's the same for Date.dayOfWeek.This seems unlikely, but you can reach that pretty quick when extrapolating Dates. Not sure if this can be fixed with the Date.month function. Maybe the problem could be solved if Date.fromTime would behave like Date.fromString and yield a Result or a Maybe.
Can be reproduced with the following on http://elm-lang.org/examples/hello-html