R/days-in-month.R

Defines functions dtt_days_in_month

Documented in dtt_days_in_month

#' Days in the Month
#'
#' @param x A Date or POSIXct vector.
#' @return A integer vector of 28 to 31 indicating the days in the month.
#' @family days
#' @export
#'
#' @examples
#' dtt_days_in_month(as.Date(c("2000-02-11", "2001-02-01")))
dtt_days_in_month <- function(x) {
  month <- dtt_month(x)
  days <- .days_in_month[month]
  days[month == 2L & dtt_leap_year(x)] <- 29L
  days
}

Try the dttr2 package in your browser

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

dttr2 documentation built on Nov. 14, 2023, 5:10 p.m.