Skip to content

Commit c8c3201

Browse files
author
Richard Feldman
committed
Upgrade to elm-iso8601-date-strings 1.1.0
1 parent ad14ff6 commit c8c3201

File tree

4 files changed

+6
-29
lines changed

4 files changed

+6
-29
lines changed

elm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"elm/time": "1.0.0",
1616
"elm/url": "1.0.0",
1717
"elm-explorations/markdown": "1.0.0",
18-
"rtfeldman/elm-iso8601-date-strings": "1.0.0"
18+
"rtfeldman/elm-iso8601-date-strings": "1.1.0"
1919
},
2020
"indirect": {
2121
"elm/parser": "1.0.0",

src/Article.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import Html exposing (Attribute, Html, i)
2121
import Html.Attributes exposing (class)
2222
import Html.Events exposing (stopPropagationOn)
2323
import Http
24+
import Iso8601
2425
import Json.Decode as Decode exposing (Decoder)
2526
import Json.Decode.Pipeline exposing (custom, hardcoded, required)
2627
import Json.Encode as Encode
2728
import Markdown
2829
import Profile exposing (Profile)
2930
import Time
30-
import Timestamp
3131
import Username as Username exposing (Username)
3232
import Viewer exposing (Viewer)
3333

@@ -196,7 +196,7 @@ metadataDecoder =
196196
|> required "description" (Decode.map (Maybe.withDefault "") (Decode.nullable Decode.string))
197197
|> required "title" Decode.string
198198
|> required "tagList" (Decode.list Decode.string)
199-
|> required "createdAt" Timestamp.iso8601Decoder
199+
|> required "createdAt" Iso8601.decoder
200200
|> required "favorited" Decode.bool
201201
|> required "favoritesCount" Decode.int
202202

src/Article/Comment.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import Article.Slug as Slug exposing (Slug)
77
import Author exposing (Author)
88
import CommentId exposing (CommentId)
99
import Http
10+
import Iso8601
1011
import Json.Decode as Decode exposing (Decoder)
1112
import Json.Decode.Pipeline exposing (custom, required)
1213
import Json.Encode as Encode exposing (Value)
1314
import Profile exposing (Profile)
1415
import Time
15-
import Timestamp
1616

1717

1818

@@ -103,6 +103,6 @@ decoder maybeCred =
103103
Decode.succeed Internals
104104
|> required "id" CommentId.decoder
105105
|> required "body" Decode.string
106-
|> required "createdAt" Timestamp.iso8601Decoder
106+
|> required "createdAt" Iso8601.decoder
107107
|> required "author" (Author.decoder maybeCred)
108108
|> Decode.map Comment

src/Timestamp.elm

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
module Timestamp exposing (format, iso8601Decoder, view)
1+
module Timestamp exposing (format, view)
22

33
import Html exposing (Html, span, text)
44
import Html.Attributes exposing (class)
5-
import Iso8601
65
import Json.Decode as Decode exposing (Decoder, fail, succeed)
76
import Time exposing (Month(..))
87

@@ -17,28 +16,6 @@ view timeZone timestamp =
1716

1817

1918

20-
-- DECODE
21-
22-
23-
{-| Decode an ISO-8601 date string.
24-
-}
25-
iso8601Decoder : Decoder Time.Posix
26-
iso8601Decoder =
27-
Decode.string
28-
|> Decode.andThen fromString
29-
30-
31-
fromString : String -> Decoder Time.Posix
32-
fromString str =
33-
case Iso8601.toTime str of
34-
Ok successValue ->
35-
succeed successValue
36-
37-
Err _ ->
38-
fail ("Invalid date: " ++ str)
39-
40-
41-
4219
-- FORMAT
4320

4421

0 commit comments

Comments
 (0)