R/get_date.R

Defines functions get_date

Documented in get_date

#' Get Date format out of numeric year and monthday character value
#' @param year numeric year
#' @param monthday character with month and day i.e. ("-02-01" or "Feb 01")
#' @param prevyear if TRUE starts with previous year
#' @keywords internal
#' @family Helper

get_date <- function(year, monthday, prevyear = FALSE) {

  year <- ifelse(prevyear, year - 1, year)

  day <- lubridate::as_date(
    lubridate::ymd(
      paste0(year, monthday),
      tz = NULL),
    tz = NULL)

  return(day)

}

Try the PHENTHAUproc package in your browser

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

PHENTHAUproc documentation built on June 22, 2024, 7:12 p.m.