From c8c3201ec0488f17c1245e1fd2293ba5bc0748d5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 31 Aug 2018 13:59:51 -0400 Subject: [PATCH] Upgrade to elm-iso8601-date-strings 1.1.0 --- elm.json | 2 +- src/Article.elm | 4 ++-- src/Article/Comment.elm | 4 ++-- src/Timestamp.elm | 25 +------------------------ 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/elm.json b/elm.json index 06273239cb..9f4d9f04c9 100644 --- a/elm.json +++ b/elm.json @@ -15,7 +15,7 @@ "elm/time": "1.0.0", "elm/url": "1.0.0", "elm-explorations/markdown": "1.0.0", - "rtfeldman/elm-iso8601-date-strings": "1.0.0" + "rtfeldman/elm-iso8601-date-strings": "1.1.0" }, "indirect": { "elm/parser": "1.0.0", diff --git a/src/Article.elm b/src/Article.elm index cf8e69db74..fc65faa822 100644 --- a/src/Article.elm +++ b/src/Article.elm @@ -21,13 +21,13 @@ import Html exposing (Attribute, Html, i) import Html.Attributes exposing (class) import Html.Events exposing (stopPropagationOn) import Http +import Iso8601 import Json.Decode as Decode exposing (Decoder) import Json.Decode.Pipeline exposing (custom, hardcoded, required) import Json.Encode as Encode import Markdown import Profile exposing (Profile) import Time -import Timestamp import Username as Username exposing (Username) import Viewer exposing (Viewer) @@ -196,7 +196,7 @@ metadataDecoder = |> required "description" (Decode.map (Maybe.withDefault "") (Decode.nullable Decode.string)) |> required "title" Decode.string |> required "tagList" (Decode.list Decode.string) - |> required "createdAt" Timestamp.iso8601Decoder + |> required "createdAt" Iso8601.decoder |> required "favorited" Decode.bool |> required "favoritesCount" Decode.int diff --git a/src/Article/Comment.elm b/src/Article/Comment.elm index c777c7402d..301799d11e 100644 --- a/src/Article/Comment.elm +++ b/src/Article/Comment.elm @@ -7,12 +7,12 @@ import Article.Slug as Slug exposing (Slug) import Author exposing (Author) import CommentId exposing (CommentId) import Http +import Iso8601 import Json.Decode as Decode exposing (Decoder) import Json.Decode.Pipeline exposing (custom, required) import Json.Encode as Encode exposing (Value) import Profile exposing (Profile) import Time -import Timestamp @@ -103,6 +103,6 @@ decoder maybeCred = Decode.succeed Internals |> required "id" CommentId.decoder |> required "body" Decode.string - |> required "createdAt" Timestamp.iso8601Decoder + |> required "createdAt" Iso8601.decoder |> required "author" (Author.decoder maybeCred) |> Decode.map Comment diff --git a/src/Timestamp.elm b/src/Timestamp.elm index fde03e0e9d..07982d692a 100644 --- a/src/Timestamp.elm +++ b/src/Timestamp.elm @@ -1,8 +1,7 @@ -module Timestamp exposing (format, iso8601Decoder, view) +module Timestamp exposing (format, view) import Html exposing (Html, span, text) import Html.Attributes exposing (class) -import Iso8601 import Json.Decode as Decode exposing (Decoder, fail, succeed) import Time exposing (Month(..)) @@ -17,28 +16,6 @@ view timeZone timestamp = --- DECODE - - -{-| Decode an ISO-8601 date string. --} -iso8601Decoder : Decoder Time.Posix -iso8601Decoder = - Decode.string - |> Decode.andThen fromString - - -fromString : String -> Decoder Time.Posix -fromString str = - case Iso8601.toTime str of - Ok successValue -> - succeed successValue - - Err _ -> - fail ("Invalid date: " ++ str) - - - -- FORMAT