Calendar Class Reference
[Date and time calculations]

#include <ql/calendar.hpp>

Inheritance diagram for Calendar:

Inheritance graph
[legend]
List of all members.

Detailed Description

calendar class

This class provides methods for determining whether a date is a business day or a holiday for a given market, and for incrementing/decrementing a date of a given number of business days.

The Bridge pattern is used to provide the base behavior of the calendar, namely, to determine whether a date is a business day.

A calendar should be defined for specific exchange holiday schedule or for general country holiday schedule. Legacy city holiday schedule calendars will be moved to the exchange/country convention.

Tests:
the methods for adding and removing holidays are tested by inspecting the calendar before and after their invocation.
Examples:

BermudanSwaption.cpp, ConvertibleBonds.cpp, and swapvaluation.cpp.


Public Member Functions

 Calendar ()
Calendar interface
std::string name () const
 Returns the name of the calendar.
bool isBusinessDay (const Date &d) const
bool isHoliday (const Date &d) const
bool isEndOfMonth (const Date &d) const
void addHoliday (const Date &)
void removeHoliday (const Date &)
Date adjust (const Date &, BusinessDayConvention convention=Following, const Date &origin=Date()) const
Date advance (const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following) const
Date advance (const Date &date, const Period &period, BusinessDayConvention convention=Following) const

Protected Member Functions

 Calendar (const boost::shared_ptr< CalendarImpl > &impl)

Related Functions

(Note that these are not member functions.)

bool operator== (const Calendar &, const Calendar &)
bool operator!= (const Calendar &, const Calendar &)

Classes

class  OrthodoxImpl
 partial calendar implementation More...
class  WesternImpl
 partial calendar implementation More...


Constructor & Destructor Documentation

Calendar  ) 
 

This default constructor returns a calendar with a null implementation, which is therefore unusable except as a placeholder.

Calendar const boost::shared_ptr< CalendarImpl > &  impl  )  [protected]
 

This protected constructor will only be invoked by derived classes which define a given Calendar implementation


Member Function Documentation

std::string name  )  const
 

Returns the name of the calendar.

Warning:
This method is used for output and comparison between calendars. It is not meant to be used for writing switch-on-type code.

bool isBusinessDay const Date d  )  const
 

Returns true iff the date is a business day for the given market.

bool isHoliday const Date d  )  const
 

Returns true iff the date is a holiday for the given market.

bool isEndOfMonth const Date d  )  const
 

Returns true iff the date is last business day for the month in given market.

void addHoliday const Date  ) 
 

Adds a date to the set of holidays for the given calendar.

void removeHoliday const Date  ) 
 

Removes a date from the set of holidays for the given calendar.

Date adjust const Date ,
BusinessDayConvention  convention = Following,
const Date origin = Date()
const
 

Adjusts a non-business day to the appropriate near business day with respect to the given convention.

Examples:
ConvertibleBonds.cpp, and swapvaluation.cpp.

Date advance const Date ,
Integer  n,
TimeUnit  unit,
BusinessDayConvention  convention = Following
const
 

Advances the given date of the given number of business days and returns the result.

Note:
The input date is not modified.
Examples:
BermudanSwaption.cpp, ConvertibleBonds.cpp, and swapvaluation.cpp.

Date advance const Date date,
const Period period,
BusinessDayConvention  convention = Following
const
 

Advances the given date as specified by the given period and returns the result.

Note:
The input date is not modified.


Friends And Related Function Documentation

bool operator== const Calendar ,
const Calendar
[related]
 

Returns true iff the two calendars belong to the same derived class.