How to deal with UTCTime?
- 主要語言
- Elm
- 星號
- 107
- 分支
- 28
- PR 合併指標
- 30 天內沒有已合併 PR
描述
What's the best way to deal with UTCTime? I tried deriving the Elm definition and here's what showed-up on the Elm side:
```
type alias UTCTime =
{ utctDay: Day
, utctDayTime: DiffTime
}
jsonDecUTCTime : Json.Decode.Decoder ( UTCTime )
jsonDecUTCTime =
("utctDay" := jsonDecDay) >>= \putctDay ->
("utctDayTime" := jsonDecDiffTime) >>= \putctDayTime ->
Json.Decode.succeed {utctDay = putctDay, utctDayTime = putctDayTime}
jsonEncUTCTime : UTCTime -> Value
jsonEncUTCTime val =
Json.Encode.object
[ ("utctDay", jsonEncDay val.utctDay)
, ("utctDayTime", jsonEncDiffTime val.utctDayTime)
]
```
Is this the idiomatic way of dealing with timestamps on the Elm side? (I'm new to Elm, so please pardon this newbie question). If not, then how does one specify some sort of "mapping" between an idiomatic Haskell type and its corresponding idiomatic Elm counterpart?
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。