Calendar: Creates a calendar

Description Usage Arguments Details Examples

Description

The Calendar stores all information necessary to compute business days. This works like a helper class for many of bizdays' methods.

Usage

1
2
3
Calendar(holidays = integer(0), startDate = "2005-01-01",
  endDate = "2020-12-31", pattern = c("%Y-%m-%d", "%Y%m%d"),
  name = "gregorian", dib = NULL)

Arguments

holidays

a vector of Dates which contains the holidays

name

calendar's name

dib

a single numeric variable which indicates the amount of days within a year (dib stands for days in base).

start.date

the date which the calendar starts

end.date

the date which the calendar ends

Details

The arguments start.date and end.date can be set but once they aren't and holidays is set, start.date is defined to min(holidays) and end.date to max(holidays). If holidays isn't set start.date is set to '1970-01-01' and end.date to '2071-01-01'.

weekdays is controversial but it is only a sequence of nonworking weekdays. In the great majority of situations it refers to the weekend but it is also possible defining it differently. weekdays accepts a character sequence with lower case weekdays ( sunday, monday, thuesday, wednesday, thursday, friday, saturday). This argument defaults to NULL because the default intended behavior for Calendar returns an actual calendar, so calling Calendar(dib=365) returns a actual/365 calendar and Calendar(dib=360) and actual/360 (for more calendars see Day Count Convention) To define the weekend as the nonworking weekdays one could simply use weekdays=c("saturday", "sunday").

dib reffers to days in base and represents the amount of days within a year. That is necessary for defining Day Count Conventions and for accounting annualized periods (see bizyears).

The arguments adjust.from and adjust.to are used to adjust bizdays' arguments from and to, respectively. These arguments need to be adjusted when nonworking days are provided. The default behavior, setting adjust.from=adjust.previous and adjust.to=adjust.next, works like Excel's function NETWORKDAYS, since that is fairly used by a great number of practitioners.

Calendar doesn't have to be named, but it helps identifying the calendars once many are instantiated. You name a Calendar by setting the argument name.

Examples

1
2
3
4
5
6
7
8
9
data(holidayCN)
that <- Calendar(name="CN", holidays = holidayCN)
options(calendar=that)

# ACTUAL calendar
cal <- Calendar(name="Actual", dib=365)
# calendar default name is gregorian
cal <- Calendar(start.date="1976-07-12", end.date="2013-10-28")
is.null(cal$name) # TRUE

jokbull/bizday documentation built on May 19, 2019, 6:19 p.m.