R/clocks.R

#' Birthday clock
#'
#' @param month English name for the month of your birth; see \code{\link[base]{month.name}}
#' @param day integer day of the month in which you were born; should be one of \emph{1-31}
#'
#' @export
#'
#' @examples
#' bday_clock("January", 1)
bday_clock <- function(month, day) {

  stopifnot(month %in% base::month.name)

  bday_str <- paste(month,
                    day,
                    next_year(),
                    sep = "/")

  bday <- as.Date(bday_str, format = "%B/%d/%Y")

  d <- as.numeric(bday - Sys.Date(), units = "days")

  msg <- paste0(d, " days until your birthday there are ...")

  cowsay::say(msg, by = "yoda")

}
uvasomrc/scratchr documentation built on May 29, 2019, 10:51 a.m.