R/pretty_dt.R

Defines functions cli_format.pretty_dt as_pretty_dt

Documented in as_pretty_dt cli_format.pretty_dt

#' Format a difftime
#'
#' Internal method used to print a [selenider_session()] object. Designed to
#' be used with [prettyunits::pretty_dt()], [prettyunits::pretty_ms()] and
#' [prettyunits::pretty_sec()].
#'
#' @param x A string representing a difftime.
#' @param style,... Not used.
#'
#' @returns
#' An object of class `pretty_dt`.
#'
#' @examples
#' x <- as_pretty_dt(prettyunits::pretty_sec(10))
#'
#' cli::cli_text("{.val x}")
#'
#' @keywords internal
#'
#' @export
as_pretty_dt <- function(x) {
  class(x) <- "pretty_dt"
  x
}

#' @rdname as_pretty_dt
#'
#' @importFrom cli cli_format
#' @export
cli_format.pretty_dt <- function(x, style = NULL, ...) {
  x
}

Try the selenider package in your browser

Any scripts or data that you put into this service are public.

selenider documentation built on April 3, 2025, 5:51 p.m.