use github notion on build history start/finish timestamp
@@ -17,10 +17,10 @@ view duration now =
[ pendingLabel "pending" ]
( Just startedAt, Nothing ) ->
- [ labeledRelativeDate "started" now startedAt ]
+ [ labeledDate "started" now startedAt ]
( Nothing, Just finishedAt ) ->
- [ labeledRelativeDate "finished" now finishedAt ]
+ [ labeledDate "finished" now finishedAt ]
( Just startedAt, Just finishedAt ) ->
let
@@ -28,8 +28,8 @@ view duration now =
-- https://github.com/elm-lang/elm-compiler/issues/1223
Duration.between (Date.toTime startedAt) (Date.toTime finishedAt)
in
- [ labeledVerboseDate "started" startedAt
- , labeledVerboseDate "finished" finishedAt
+ [ labeledDate "started" now startedAt
+ , labeledDate "finished" now finishedAt
, labeledDuration "duration" durationElmIssue
]
@@ -38,29 +38,32 @@ show : Time.Time -> Concourse.BuildDuration -> String
show now =
.startedAt >> Maybe.map (Date.toTime >> flip Duration.between now >> Duration.format) >> Maybe.withDefault ""
-labeledVerboseDate : String -> Date -> Html a
-labeledVerboseDate label date =
- let verboseDate =
+
+labeledDate: String -> Time -> Date -> Html a
+labeledDate label now date =
+ let
+ ago =
+ Duration.between (Date.toTime date) now
+ oneDay =
+ toFloat 3600 * 24 * 1000
+ verboseDate =
Date.Format.format "%b %d %Y %I:%M:%S %p" date
+ relativeDate =
+ Duration.format ago ++ " ago"
in
+ if ago < oneDay then
Html.tr []
[ Html.td [ class "dict-key" ] [ Html.text label ]
, Html.td
[ title verboseDate, class "dict-value" ]
- [ Html.span [] [ Html.text verboseDate ] ]
+ [ Html.span [] [ Html.text relativeDate ] ]
]
-
-labeledRelativeDate : String -> Time -> Date -> Html a
-labeledRelativeDate label now date =
- let
- ago =
- Duration.between (Date.toTime date) now
- in
+ else
Html.tr []
[ Html.td [ class "dict-key" ] [ Html.text label ]
, Html.td
- [ title (Date.Format.format "%b %d %Y %I:%M:%S %p" date), class "dict-value" ]
- [ Html.span [] [ Html.text (Duration.format ago ++ " ago") ] ]
+ [ title relativeDate, class "dict-value" ]
+ [ Html.span [] [ Html.text verboseDate ] ]
]
