R/leap-year.R

Defines functions dtt_leap_year

Documented in dtt_leap_year

#' Test for Leap Year
#'
#' Tests whether each year is a leap year.
#'
#' @inheritParams params
#'
#' @return A logical vector indicating whether each year is a leap year.
#' @family leap year
#' @export
#'
#' @examples
#' dtt_leap_year(as.Date("1999-03-04", "2000-02-01"))
dtt_leap_year <- function(x) {
  year <- dtt_year(x)
  (year %% 4 == 0) & ((year %% 100 != 0) | (year %% 400 == 0))
}

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.