R/class_timespan_compat_pillar.R

Defines functions format.pillar_shaft_timespan pillar_shaft.timespan type_sum.timespan

#' @importFrom pillar type_sum
#' @export
type_sum.timespan <- function(x) {
  "tmspn"
}



#' @importFrom pillar pillar_shaft
#' @importFrom crayon col_nchar
#' @export
pillar_shaft.timespan <- function(x, ...) {
  x_fmt <- format(x, ..., quote = FALSE)

  pillar::new_pillar_shaft(
    x_fmt,
    width = max(crayon::col_nchar(x_fmt)),
    subclass = "pillar_shaft_timespan")
}



#' @export
format.pillar_shaft_timespan <- function(x, width, ...) {
  pillar::new_ornament(x, width = width, align = "left")
}

Try the parttime package in your browser

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

parttime documentation built on May 29, 2024, 6:25 a.m.