R/days-in-year.R

Defines functions dtt_days_in_year

Documented in dtt_days_in_year

#' Days in the Year
#'
#' @param x A Date or POSIXct vector.
#' @return A integer vector of 365 and 366 indicates the days of the year.
#' @family days
#' @export
#'
#' @examples
#' dtt_days_in_year(as.Date(c("2000-10-11", "2001-01-01")))
dtt_days_in_year <- function(x) {
  x <- ifelse(dtt_leap_year(x), 366L, 365L)
  as.integer(x)
}

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.