R/adj.next.bus.day.R

#' Adjust to next business day.
#' 
#' \code{adj.next.bus.day} gets the next business day following 5D bus day
#' convention.
#' 
#' @param date, a \code{Date} type.
#'   
#' @return Date adjusted to the following business day

adj.next.bus.day <- function(date){
  
  for(i in 1:length(date)){
    
    dateWday <- as.POSIXlt(as.Date(date[i]))$wday
    
    ## change date to the most recent weekday if necessary
    
    if (dateWday == 0){
      date[i] <- date[i] + 1
    } else if (dateWday == 6) {
      date[i] <- date[i] + 2
    }
  }
  return(date)
}
davidkane9/creditrISDA documentation built on May 15, 2019, 1:13 a.m.