R/get_fy.R

Defines functions get_fy

Documented in get_fy

#' Get Fiscal Year from date
#'
#' @param date lubridate object
#'
#' @return numeric
#'
#' @author Lillian Nguyen
#'
#' @import dplyr
#' @import lubridate
#' @export


get_fy <- function(date = NULL) {

  stopifnot("Argument should be class 'date'" = identical(class(date), "Date"))

  case_when(
    month(date) >= 7 ~ year(date) + 1,
    month(date) <= 6 ~ year(date)) %>%
    return()

}
baltimorebudget/bbmR documentation built on Aug. 28, 2023, 6:32 p.m.