R/time.R

Defines functions get_persian_date year_month_days

#' year month days
#'
#' @param year
#'
#' @return number of days in each month of a year
#' @export
#'
#' @examples
#' q <- t(sapply(2007:2012,year_month_days))
#' apply(q,1,sum)
year_month_days <- function(year=2007) {
  y <- c(rep(year,12),year+1)
  d <- 1
  m <- c(1:12,1)
  as.numeric(diff(as.Date(paste(y,m,d,sep='-'))))
}

#' get persian date
#'
#' @param miladi_date
#'
#' @return
#' @export
#'
#' @examples
get_persian_date <- function(miladi_date = Sys.Date())
{
  return(ConvCalendar::as.OtherDate(miladi_date,"persian"))
}
faridcher/futils documentation built on Oct. 20, 2017, 9:52 a.m.