close
Skip to content

feat: add duration and time_ago to theme #814#815

Open
jjjermiah wants to merge 5 commits intor-lib:mainfrom
jjjermiah:jermiahj/feat/time_formatters_theme
Open

feat: add duration and time_ago to theme #814#815
jjjermiah wants to merge 5 commits intor-lib:mainfrom
jjjermiah:jermiahj/feat/time_formatters_theme

Conversation

@jjjermiah
Copy link
Copy Markdown

closes #814

# Downloading a file
start <- proc.time()[[3]]
Sys.sleep(0.1)
elapsed <- proc.time()[[3]] - start
cli::cli_text('Downloaded {.file data.csv} in {.duration {elapsed}}')
#> Downloaded 'data.csv' in 107ms

# Processing step with relative time
last_sync <- Sys.time() - 125
cli::cli_text('Last sync: {.time_ago {last_sync}}')
#> Last sync: 2 minutes ago

# Progress completion
dt <- as.difftime(2.4, units = 'mins')
cli::cli_alert_success('Build completed without errors [{.duration {dt}}]')
#> ✔ Build completed without errors [2m 24s]

Created on 2026-04-22 with reprex v2.1.1

no new dependencies, was able to use existing formatters.
i wouldve used pretty_dt but noted the issue in in this comment, i could add the missing fxn to the local env and swap out the custom transform

…alisation

- Remove bracket decoration from builtin_theme and simple_theme; users
  can add via cli.user_theme (consistent with .bytes/.num pattern)
- Normalise difftime to seconds before pretty_sec to avoid unit mismatch
- Simplify .time_ago transform (as.POSIXct handles numeric directly)
- Expand tests: difftime normalisation + POSIXct/POSIXlt input variants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add .duration and .time_ago inline styles

1 participant