Calculate elapsed time between two points and present prettily
Source:R/pretty.R
pretty_time_taken.Rd
Converts a start and end value to a readable time format.
Details
Designed to be used with Sys.time() when tracking start and end times.
Shows as seconds up until 119 seconds, then minutes until 119 minutes, then hours for anything larger.
Input start and end times must be convertible to POSIXct format.
See also
comma_sep()
round_five_up()
as.POSIXct()
Other prettying:
pretty_filesize()
,
pretty_num()
,
pretty_num_table()
Examples
pretty_time_taken(
"2024-03-23 07:05:53 GMT",
"2024-03-23 12:09:56 GMT"
)
#> [1] "5 hours 4 minutes 3 seconds"
# Track the start and end time of a process
start <- Sys.time()
Sys.sleep(0.1)
end <- Sys.time()
# Use this function to present it prettily
pretty_time_taken(start, end)
#> [1] "0.1 seconds"