R/datePlus.R

Defines functions datePlus

Documented in datePlus

#' Add a period of time to a Date object
#'
#' Add a period of time to a Date object
#' @param x starting Date
#' @param years years to be added
#' @param months months to be added
#' @param days days to be added
#' @examples
#' (today <- Sys.Date())
#' datePlus(today, years = 1, months = 1, days = 1)
#' @export
datePlus <- function(x, years = 0, months = 0, days = 0){
  x <- as.POSIXlt(x)
  x$year <- x$year + years
  x$mon <- x$mon + months
  x$day <- x$day + days
  as.Date(x)
  
}
lbraglia/yapomif documentation built on May 20, 2019, 11:26 p.m.