Skip to content

Commit

Permalink
fix(schedules): add precise date+time to last_updated and last_schedu…
Browse files Browse the repository at this point in the history
…led (#712)
  • Loading branch information
plyr4 authored Aug 29, 2023
1 parent 3d5c22c commit ec8f81c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/elm/Pages/Build/History.elm
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ recentBuildTooltip now timezone build =
, em [] [ text build.event ]
]
, buildInfo build
, viewTooltipField "started:" <| Util.humanReadableWithDefault timezone build.started
, viewTooltipField "finished:" <| Util.humanReadableWithDefault timezone build.finished
, viewTooltipField "started:" <| Util.humanReadableDateWithDefault timezone build.started
, viewTooltipField "finished:" <| Util.humanReadableDateWithDefault timezone build.finished
, viewTooltipField "duration:" <| Util.formatRunTime now build.started build.finished
, viewTooltipField "worker:" build.host
, viewTooltipField "author:" build.author
Expand Down
4 changes: 2 additions & 2 deletions src/elm/Pages/Schedules/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ renderSchedule zone org repo schedule =
, scope "row"
, class "break-word"
]
[ text <| Util.humanReadableWithDefault zone schedule.scheduled_at ]
[ text <| Util.humanReadableDateTimeWithDefault zone schedule.scheduled_at ]
, td
[ attribute "data-label" "updated by"
, scope "row"
Expand All @@ -185,7 +185,7 @@ renderSchedule zone org repo schedule =
, scope "row"
, class "break-word"
]
[ text <| Util.humanReadableWithDefault zone schedule.updated_at ]
[ text <| Util.humanReadableDateTimeWithDefault zone schedule.updated_at ]
]


Expand Down
33 changes: 18 additions & 15 deletions src/elm/Util.elm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module Util exposing
, formatTestTag
, getNameFromRef
, humanReadableDateTimeFormatter
, humanReadableWithDefault
, humanReadableDateTimeWithDefault
, humanReadableDateWithDefault
, isLoading
, isSuccess
, largeLoader
Expand Down Expand Up @@ -84,22 +85,26 @@ millisToSeconds millis =
millis // 1000


{-| dateToHumanReadable : takes timezone and posix timestamp and returns human readable date string
{-| humanReadableDateWithDefault : takes timezone and posix timestamp and returns human readable date string with a default value for 0
-}
dateToHumanReadable : Zone -> Int -> String
dateToHumanReadable timezone time =
humanReadableDateFormatter timezone <| Time.millisToPosix <| secondsToMillis time
humanReadableDateWithDefault : Zone -> Int -> String
humanReadableDateWithDefault timezone t =
if t == 0 then
"-"

else
humanReadableDateFormatter timezone <| Time.millisToPosix <| secondsToMillis t


{-| humanReadableWithDefault : takes timezone and posix timestamp and returns human readable date string with a default value for 0
{-| humanReadableDateTimeWithDefault : takes timezone and posix timestamp and returns human readable date time string with a default value for 0
-}
humanReadableWithDefault : Zone -> Int -> String
humanReadableWithDefault timezone t =
humanReadableDateTimeWithDefault : Zone -> Int -> String
humanReadableDateTimeWithDefault timezone t =
if t == 0 then
"-"

else
dateToHumanReadable timezone t
humanReadableDateTimeFormatter timezone <| Time.millisToPosix <| secondsToMillis t


{-| humanReadableDateFormatter : formats a zone and date into human readable chunks
Expand All @@ -120,17 +125,15 @@ humanReadableDateFormatter =
humanReadableDateTimeFormatter : Zone -> Posix -> String
humanReadableDateTimeFormatter =
DateFormat.format
[ DateFormat.monthNameAbbreviated
, DateFormat.text " "
, DateFormat.dayOfMonthSuffix
, DateFormat.text ", "
[ DateFormat.monthFixed
, DateFormat.text "/"
, DateFormat.dayOfMonthFixed
, DateFormat.text "/"
, DateFormat.yearNumber
, DateFormat.text " at "
, DateFormat.hourFixed
, DateFormat.text ":"
, DateFormat.minuteFixed
, DateFormat.text ":"
, DateFormat.secondFixed
, DateFormat.text " "
, DateFormat.amPmUppercase
]
Expand Down

0 comments on commit ec8f81c

Please sign in to comment.