#' The function generates the teaching dates for my semester
#' schelme
#' @author Guomin Li
#' @param begin.date: default = "2015-09-01"
#' @param weeks: default = 30
#' @param cat default=false (not cat the result)
#' @return date serials
#' @export
#' @examples
#' teach_date("2015-09-01")
#' holiday <- c("2017-03-30","2017-05-04")
#' add_date <-c("2017-04-01")
#' teach_date("2017-03-02",holiday,add_date,cat=TRUE)
#'
teach_date <- function(begin.date,holidays=c(""),add_dates=c(""),weeks=30,cat=FALSE){
begin = as.Date(begin.date,"%Y-%m-%d")
dates = begin + seq(from = 0, to = (weeks-1)*7,by=7)
datess <- as.character(dates)
# check up the added teaching dates
if (add_dates !="" & holidays !="") {
#hol_len <- length(holidays) - length(add_dates) #length("")=1
data <- sort(c(datess[!(datess %in% holidays)],add_dates))
} else if (add_dates == "" & holidays !="" ){
data <- sort(datess[!(datess %in% holidays)])
} else {
data <- datess
}
data17 <- data[1:17]
tdat = format(as.Date(data17,"%Y-%m-%d"),"%Y年%m月%d日")
if (cat==TRUE) {
cat(paste(1:length(tdat),tdat,sep="\t"),sep="\n")
cat(tdat,sep="\n")
}
return(tdat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.