R/wday.R

Defines functions dtt_wday.default dtt_wday

Documented in dtt_wday dtt_wday.default

#' Get Week Day
#'
#' Gets the week days for the locale.
#'
#' @inheritParams params
#'
#' @return An character vector of the week days.
#' @export
#'
#' @examples
#' x <- as.Date("1990-01-02")
#' dtt_wday(x)
#'
#' x <- as.POSIXct("1990-01-02 23:40:51")
#' dtt_wday(x, abbr = TRUE)
dtt_wday <- function(x, abbr = FALSE, ...) {
  UseMethod("dtt_wday")
}

#' @describeIn dtt_wday Get character vector of week days for a Date vector
#' @export
dtt_wday.default <- function(x, abbr = FALSE, ...) {
  chk_flag(abbr)
  chk_unused(...)
  x <- dtt_floor(x)
  format <- if (abbr) "%a" else "%A"
  format(x, format)
}

Try the dttr2 package in your browser

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

dttr2 documentation built on Sept. 19, 2021, 9:06 a.m.