Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schedules): add precise date+time to last_updated and last_scheduled #712

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading