Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoding epoch millis to "DateTime" in Elm 0.19?

Tags:

datetime

elm

Let's say I have an epoch millis value such as 1538637258426, how do I convert that into a something like a DateTime representation in Elm 0.19?

I'm not even sure which model I should use to represent a "date time" in Elm 0.19. I cannot find the Date module in core that is referred to from a lot of places on the web (such as this stackoverflow question). Also I cannot seem to install the elm-community/elm-time package since it's not upgraded to support 0.19.

like image 735
Johan Avatar asked Oct 06 '18 10:10

Johan


1 Answers

The official date/time library in 0.19 is elm/time, which has replaced the old Date module in core. The type you'll want to use is Time.Posix, which you can obtain from a milliseconds value using Time.millisToPosix.

like image 96
glennsl Avatar answered Nov 01 '22 01:11

glennsl