Date Class Reference
[Date and time calculations]

#include <ql/date.hpp>

List of all members.


Detailed Description

Concrete date class.

This class provides methods to inspect dates as well as methods and operators which implement a limited date algebra (increasing and decreasing dates, and calculating their difference).

Tests:
self-consistency of dates, serial numbers, days of month, months, and weekdays is checked over the whole date range.


Public Member Functions

constructors
 Date ()
 Default constructor returning a null date.
 Date (BigInteger serialNumber)
 Constructor taking a serial number as given by Applix or Excel.
 Date (Day d, Month m, Year y)
 More traditional constructor.
inspectors
Weekday weekday () const
Day dayOfMonth () const
Day dayOfYear () const
 One-based (Jan 1st = 1).
Month month () const
Year year () const
BigInteger serialNumber () const
bool isEndOfMonth () const
Day lastDayOfMonth () const
date algebra
Dateoperator+= (BigInteger days)
 increments date by the given number of days
Dateoperator+= (const Period &)
 increments date by the given period
Dateoperator-= (BigInteger days)
 decrement date by the given number of days
Dateoperator-= (const Period &)
 decrements date by the given period
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+ (BigInteger days) const
 returns a new date incremented by the given number of days
Date operator+ (const Period &) const
 returns a new date incremented by the given period
Date operator- (BigInteger days) const
 returns a new date decremented by the given number of days
Date operator- (const Period &) const
 returns a new date decremented by the given period
other methods to increment/decrement dates
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
Date plus (const Period &) const

Static Public Member Functions

static methods
Date todaysDate ()
 today's date.
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 (Size n, Weekday, Month m, Year y)
 n-th given weekday in the given month and year
bool isIMMdate (const Date &d)
 whether or not the given date is an IMM date
Date nextIMMdate (const Date &d)
 next IMM date following (or equal to) the given date

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &, const Date &)
BigInteger operator- (const Date &, const Date &)
 Difference in days between dates.
bool operator== (const Date &, const Date &)
bool operator!= (const Date &, const Date &)
bool operator< (const Date &, const Date &)
bool operator<= (const Date &, const Date &)
bool operator> (const Date &, const Date &)
bool operator>= (const Date &, const Date &)


Member Function Documentation

bool isEndOfMonth  )  const
 

Deprecated:
use the static isEOM() method instead

Day lastDayOfMonth  )  const
 

Deprecated:
use the static endOfMonth() method instead

Date plusDays Integer  n  )  const
 

Deprecated:
use date + n*Days instead

Date plusWeeks Integer  n  )  const
 

Deprecated:
use date + n*Weeks instead

Date plusMonths Integer  n  )  const
 

Deprecated:
use date + n*Months instead

Date plusYears Integer  n  )  const
 

Deprecated:
use date + n*Years instead

Date plus Integer  n,
TimeUnit  units
const
 

Deprecated:
use date + n*units instead

Date plus const Period  )  const
 

Deprecated:
use date + period instead

Date nextWeekday const Date d,
Weekday 
[static]
 

next given weekday following or equal to the given date

E.g., the Friday following January 15th, 20 (a Tuesday) was January 18th, 2002.

see http://www.cpearson.com/excel/DateTimeWS.htm

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

n-th given weekday in the given month and year

E.g., the 4th Thursday of March, 1998 was March 26th, 1998.

see http://www.cpearson.com/excel/DateTimeWS.htm

Date nextIMMdate const Date d  )  [static]
 

next IMM date following (or equal to) the given date

returns the 1st delivery date for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.

Warning:
The result date is following or equal to the original date
Examples:
swapvaluation.cpp.


Friends And Related Function Documentation

std::ostream & operator<< std::ostream &  ,
const Date
[related]
 

Deprecated:
send to the stream the output of DateFormatter


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen