aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Date.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Model/Date.elm')
-rw-r--r--src/client/Model/Date.elm15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/client/Model/Date.elm b/src/client/Model/Date.elm
new file mode 100644
index 0000000..bfba02f
--- /dev/null
+++ b/src/client/Model/Date.elm
@@ -0,0 +1,15 @@
+module Model.Date exposing
+ ( timeDecoder
+ , dateDecoder
+ )
+
+import Date as Date exposing (Date)
+import Json.Decode as Decode exposing (Decoder)
+import Json.Decode.Extra as Decode
+import Time exposing (Time)
+
+timeDecoder : Decoder Time
+timeDecoder = Decode.map Date.toTime dateDecoder
+
+dateDecoder : Decoder Date
+dateDecoder = Decode.string |> Decode.andThen (Date.fromString >> Decode.fromResult)