Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Date Class Reference

#include <date.h>

Inheritance diagram for Date:

UsDate List of all members.

Public Member Functions

 Date (void)
 Default constructor.

 Date (LongInteger serialNumber)
 Constructor taking a serial number.

 Date (Day d, Month m, Year y)
 Constructor taking day, month and year.

 Date (Day d, ShortNatural m, Year y)
 Constructor taking day, month as an integer and year.

 ~Date (void)
Weekday weekday () const
Day dayOfMonth () const
Day dayOfYear () const
Month month () const
Year year () const
LongInteger serialNumber () const
bool isEndOfMonth () const
Day lastDayOfMonth () const
void setDateToToday ()
 Set Date to system today's date.

Dateoperator+= (LongInteger days)
 increments date by the given number of days

Dateoperator-= (LongInteger days)
 decrement date by the given number of days

Dateoperator++ ()
 1-day pre-increment

Date operator++ (int)
 1-day post-increment

Dateoperator-- ()
 1-day pre-decrement

Date operator-- (int)
 1-day post-decrement

Date operator+ (LongInteger days) const
 returns a new date incremented by the given number of days

Date operator- (LongInteger days) const
 returns a new date decremented by the given number of days

bool operator== (const Date &d2)
bool operator!= (const Date &d2)
bool operator< (const Date &d2)
bool operator<= (const Date &d2)
bool operator> (const Date &d2)
bool operator>= (const Date &d2)
Date plusDays (Integer n) const
Date plusWeeks (Integer n) const
Date plusMonths (Integer n) const
Date plusYears (Integer n) const
Date plus (Integer n, TimeUnit units) const
bool isBusinessDay ()
 Apply Conventions (use for UsDate for example).

void applyConvention (BusinessDayConvention convention=Following)
Date returnDateConvention (const Date &date, BusinessDayConvention convention=Following)
Real dayCount (const Date &d, DayCountConvention dayconvention=ACT_365) const
 DayCount Between Dates.

char * toString () const
 Return char* version of the date.


Static Public Member Functions

Date minDate ()
 earliest allowed date

Date maxDate ()
 latest allowed date

bool isLeap (Year y)
 whether the given year is a leap one

Date endOfMonth (const Date &d)
 last day of the month to which the given date belongs

bool isEOM (const Date &d)
 whether a date is the last day of its month

Date nextWeekday (const Date &d, Weekday)
 next given weekday following or equal to the given date

Date nthWeekday (ShortInteger n, Weekday, Month m, Year y)
 n-th given weekday in the given month and year


Static Private Member Functions

Date advance (const Date &d, Integer units, TimeUnit)
Integer monthLength (Month m, bool leapYear)
Integer monthOffset (Month m, bool leapYear)
LongInteger yearOffset (Year y)
LongInteger minimumSerialNumber ()
LongInteger maximumSerialNumber ()

Private Attributes

LongInteger _serialNumber

Constructor & Destructor Documentation

Date::Date void   ) 
 

Default constructor.

Definition at line 4 of file date.cpp.

References LongInteger.

Referenced by advance(), applyConvention(), Date(), endOfMonth(), nthWeekday(), operator+(), operator-(), and returnDateConvention().

Date::Date LongInteger  serialNumber  ) 
 

Constructor taking a serial number.

Definition at line 8 of file date.cpp.

References LongInteger.

Date::Date Day  d,
Month  m,
Year  y
 

Constructor taking day, month and year.

Definition at line 12 of file date.cpp.

References _serialNumber, Day, isLeap(), m, monthLength(), monthOffset(), Year, and yearOffset().

Date::Date Day  d,
ShortNatural  m,
Year  y
 

Constructor taking day, month as an integer and year.

Definition at line 18 of file date.cpp.

References April, August, Date(), Day, December, February, January, July, June, m, March, May, November, October, September, ShortNatural, and Year.

Date::~Date void   ) 
 

Definition at line 418 of file date.cpp.


Member Function Documentation

Date Date::advance const Date d,
Integer  units,
TimeUnit 
[static, private]
 

Definition at line 175 of file date.cpp.

References Date(), Day, dayOfMonth(), Days, February, Integer, isLeap(), m, Month, month(), monthLength(), Months, Weeks, year(), Year, and Years.

Referenced by plus(), plusDays(), plusMonths(), plusWeeks(), and plusYears().

void Date::applyConvention BusinessDayConvention  convention = Following  ) 
 

Definition at line 366 of file date.cpp.

References _serialNumber, Date(), Following, isBusinessDay(), LongInteger, ModifiedFollowing, ModifiedPreceding, month(), and Preceding.

Referenced by bond::getCashflow(), returnDateConvention(), and SwapLeg::SwapLeg().

Real Date::dayCount const Date d,
DayCountConvention  dayconvention = ACT_365
const
 

DayCount Between Dates.

Definition at line 397 of file date.cpp.

References _serialNumber, ACT_360, ACT_365, Day30_360, Day30_365, dayOfMonth(), month(), Real, serialNumber(), TN_REAL, and year().

Referenced by bond::convexity(), yieldCurve::discountFactor(), bond::duration(), asset::forwardPrice(), yieldCurve::forwardRate(), volsurface::forwardVolatility(), bond::getCashflow(), bond::getMaturityInYears(), riskybond::quotedPrice(), bond::quotedPrice(), volsurface::setvolsurface(), yieldCurve::spotRate(), volsurface::volatility(), and bond::yieldToMaturity().

Day Date::dayOfMonth  )  const
 

Definition at line 53 of file date.cpp.

References Day, dayOfYear(), isLeap(), month(), monthOffset(), and year().

Referenced by advance(), dayCount(), bond::fairvalue(), UsDate::isBusinessDay(), isEOM(), lastDayOfMonth(), and toString().

Day Date::dayOfYear  )  const
 

Definition at line 57 of file date.cpp.

References _serialNumber, Day, year(), and yearOffset().

Referenced by dayOfMonth(), and month().

Date Date::endOfMonth const Date d  )  [static]
 

last day of the month to which the given date belongs

Definition at line 263 of file date.cpp.

References Date(), isLeap(), m, month(), Month, monthLength(), year(), and Year.

Referenced by lastDayOfMonth().

bool Date::isBusinessDay  ) 
 

Apply Conventions (use for UsDate for example).

Reimplemented in UsDate.

Definition at line 362 of file date.cpp.

Referenced by applyConvention().

bool Date::isEndOfMonth  )  const
 

Definition at line 83 of file date.cpp.

References isEOM().

bool Date::isEOM const Date d  )  [static]
 

whether a date is the last day of its month

Definition at line 269 of file date.cpp.

References dayOfMonth(), isLeap(), month(), monthLength(), and year().

Referenced by isEndOfMonth().

bool Date::isLeap Year  y  )  [static]
 

whether the given year is a leap one

Definition at line 215 of file date.cpp.

References Year.

Referenced by advance(), Date(), dayOfMonth(), endOfMonth(), isEOM(), month(), and setDateToToday().

Day Date::lastDayOfMonth  )  const
 

Definition at line 87 of file date.cpp.

References Day, dayOfMonth(), and endOfMonth().

Referenced by maindate().

Date Date::maxDate  )  [static]
 

latest allowed date

Definition at line 170 of file date.cpp.

References maximumSerialNumber().

LongInteger Date::maximumSerialNumber  )  [static, private]
 

Definition at line 358 of file date.cpp.

References LongInteger.

Referenced by maxDate().

Date Date::minDate  )  [static]
 

earliest allowed date

Definition at line 165 of file date.cpp.

References minimumSerialNumber().

LongInteger Date::minimumSerialNumber  )  [static, private]
 

Definition at line 354 of file date.cpp.

References LongInteger.

Referenced by minDate().

Month Date::month  )  const
 

Definition at line 61 of file date.cpp.

References Day, dayOfYear(), Integer, isLeap(), m, Month, monthOffset(), and year().

Referenced by advance(), applyConvention(), dayCount(), dayOfMonth(), endOfMonth(), bond::fairvalue(), UsDate::isBusinessDay(), isEOM(), and toString().

Integer Date::monthLength Month  m,
bool  leapYear
[static, private]
 

Definition at line 285 of file date.cpp.

References Integer, and m.

Referenced by advance(), Date(), endOfMonth(), isEOM(), and setDateToToday().

Integer Date::monthOffset Month  m,
bool  leapYear
[static, private]
 

Definition at line 295 of file date.cpp.

References Integer, and m.

Referenced by Date(), dayOfMonth(), month(), and setDateToToday().

Date Date::nextWeekday const Date d,
Weekday 
[static]
 

next given weekday following or equal to the given date

Definition at line 273 of file date.cpp.

References weekday(), and Weekday.

Date Date::nthWeekday ShortInteger  n,
Weekday  ,
Month  m,
Year  y
[static]
 

n-th given weekday in the given month and year

Definition at line 278 of file date.cpp.

References Date(), m, ShortInteger, Weekday, and Year.

bool Date::operator!= const Date d2  )  [inline]
 

Definition at line 124 of file date.h.

References _serialNumber, and serialNumber().

Date Date::operator+ LongInteger  days  )  const
 

returns a new date incremented by the given number of days

Definition at line 137 of file date.cpp.

References _serialNumber, Date(), and LongInteger.

Date Date::operator++ int   ) 
 

1-day post-increment

Definition at line 117 of file date.cpp.

References _serialNumber, and LongInteger.

Date & Date::operator++  ) 
 

1-day pre-increment

Definition at line 111 of file date.cpp.

References _serialNumber, and LongInteger.

Date & Date::operator+= LongInteger  days  ) 
 

increments date by the given number of days

Definition at line 99 of file date.cpp.

References _serialNumber, and LongInteger.

Date Date::operator- LongInteger  days  )  const
 

returns a new date decremented by the given number of days

Definition at line 141 of file date.cpp.

References _serialNumber, Date(), and LongInteger.

Date Date::operator-- int   ) 
 

1-day post-decrement

Definition at line 130 of file date.cpp.

References _serialNumber, and LongInteger.

Date & Date::operator--  ) 
 

1-day pre-decrement

Definition at line 124 of file date.cpp.

References _serialNumber, and LongInteger.

Date & Date::operator-= LongInteger  days  ) 
 

decrement date by the given number of days

Definition at line 105 of file date.cpp.

References _serialNumber, and LongInteger.

bool Date::operator< const Date d2  )  [inline]
 

Definition at line 125 of file date.h.

References _serialNumber, and serialNumber().

bool Date::operator<= const Date d2  )  [inline]
 

Definition at line 126 of file date.h.

References _serialNumber, and serialNumber().

bool Date::operator== const Date d2  )  [inline]
 

Definition at line 123 of file date.h.

References _serialNumber, and serialNumber().

bool Date::operator> const Date d2  )  [inline]
 

Definition at line 127 of file date.h.

References _serialNumber, and serialNumber().

bool Date::operator>= const Date d2  )  [inline]
 

Definition at line 128 of file date.h.

References _serialNumber, and serialNumber().

Date Date::plus Integer  n,
TimeUnit  units
const
 

Definition at line 161 of file date.cpp.

References advance(), and Integer.

Referenced by mainconvertiblebond().

Date Date::plusDays Integer  n  )  const
 

Definition at line 145 of file date.cpp.

References advance(), Days, and Integer.

Referenced by Drift::Drift(), asset::forwardPrice(), Exotics::getTheta(), inputBond(), inputBSOption(), inputButterflySpread(), inputCallSpread(), inputConvertibleBond(), inputPutSpread(), inputRatioCallSpread(), inputStraddle(), inputStrangle(), inputVanillaSwap(), mainasset(), RainbowOption::reassignVolsAtThemoney(), and RainbowOption::reassignVolsAtThestrike().

Date Date::plusMonths Integer  n  )  const
 

Definition at line 153 of file date.cpp.

References advance(), Integer, and Months.

Referenced by bond::getCashflow(), mainasset(), mainIRVanillaSwap(), and mainyieldcurve().

Date Date::plusWeeks Integer  n  )  const
 

Definition at line 149 of file date.cpp.

References advance(), Integer, and Weeks.

Date Date::plusYears Integer  n  )  const
 

Definition at line 157 of file date.cpp.

References advance(), Integer, and Years.

Referenced by mainasset(), and mainIRVanillaSwap().

Date Date::returnDateConvention const Date date,
BusinessDayConvention  convention = Following
 

Definition at line 391 of file date.cpp.

References applyConvention(), Date(), and serialNumber().

LongInteger Date::serialNumber  )  const
 

Definition at line 79 of file date.cpp.

References _serialNumber, and LongInteger.

Referenced by CashFlow::CashFlow(), dayCount(), Drift::Drift(), bond::fairvalue(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), returnDateConvention(), and SwapLeg::SwapLeg().

void Date::setDateToToday  ) 
 

Set Date to system today's date.

Definition at line 91 of file date.cpp.

References _serialNumber, Day, isLeap(), Month, monthLength(), monthOffset(), and yearOffset().

Referenced by CashFlow::CashFlow(), yieldCurve::discountFactor(), asset::forwardPrice(), yieldCurve::forwardRate(), Exotics::getTheta(), importData::importVolSurface(), inputBond(), inputBSOption(), inputButterflySpread(), inputCallSpread(), inputConvertibleBond(), inputPutSpread(), inputRainbowOption(), inputRatioCallSpread(), inputStraddle(), inputStrangle(), inputVanillaSwap(), mainasset(), mainconvertiblebond(), maindate(), mainIRVanillaSwap(), mainmc(), mainrainbowoptions(), mainyieldcurve(), RainbowOption::RainbowOption(), and yieldCurve::spotRate().

char * Date::toString  )  const
 

Return char* version of the date.

Definition at line 412 of file date.cpp.

References dayOfMonth(), month(), and year().

Referenced by mainasset(), maindate(), mainvolsurface(), and operator<<().

Weekday Date::weekday  )  const
 

Definition at line 48 of file date.cpp.

References _serialNumber, Integer, and Weekday.

Referenced by UsDate::isBusinessDay(), and nextWeekday().

Year Date::year  )  const
 

Definition at line 72 of file date.cpp.

References _serialNumber, Year, and yearOffset().

Referenced by advance(), dayCount(), dayOfMonth(), dayOfYear(), endOfMonth(), bond::fairvalue(), isEOM(), month(), and toString().

LongInteger Date::yearOffset Year  y  )  [static, private]
 

Definition at line 306 of file date.cpp.

References LongInteger, and Year.

Referenced by Date(), dayOfYear(), setDateToToday(), and year().


Member Data Documentation

LongInteger Date::_serialNumber [private]
 

Definition at line 167 of file date.h.

Referenced by applyConvention(), Date(), dayCount(), dayOfYear(), operator!=(), operator+(), operator++(), operator+=(), operator-(), operator--(), operator-=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), serialNumber(), setDateToToday(), weekday(), and year().


The documentation for this class was generated from the following files:
Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:39 2005 for terreneuve by doxygen 1.3.6