R/leap_year.R

Defines functions leap_year

Documented in leap_year

#' @title Calculate whether a given year is a leap year
#'
#' @description
#' Calculate whether a given year is a leap year.
#'
#' @param year A given year, vectorization parameter passing is supported.
#'
#' @return TRUE or FALSE. Return TRUE if it is a leap year, FALSE otherwise.
#'
#' @examples
#' leap_year(2024)
#'
#' @export

#------------------------------------------------------------------------------#

leap_year = function(year) {
  (year %% 4 == 0 & year %% 100 != 0) | (year %% 400 == 0)
}

#------------------------------------------------------------------------------#

Try the CNID package in your browser

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

CNID documentation built on April 4, 2025, 5:22 a.m.