Feature request: Beginning of day in timezone
sporto opened this issue · comments
Sebastian Porto commented
It would be great that elm-time could give me the beginning of a day in a particular timezone
This is what I'm doing now. based on a reference time and an offset
beginningOfDay : Int -> Time -> DT.DateTime
beginningOfDay offset referenceTime =
referenceTime
|> DT.fromTimestamp
|> DT.addMilliseconds -offset
|> DT.setHour 0
|> DT.setMinute 0
|> DT.setSecond 0
|> DT.addMilliseconds offset
Bogdan Popa commented
I've added a number of functions to ZonedDateTime
in 1.4.0
that should make this kinda stuff easier. You should now be able to do:
beginningOfDay : TimeZone -> Time -> ZD.ZonedDateTime
beginningOfDay timeZone time =
ZD.fromTimestamp timeZone time
|> ZD.setHour 0
|> ZD.setMinute 0
|> ZD.setSecond 0