Class implements a date object. More...
#include <date.hpp>
Public Types | |
enum | Format { Format::date1, Format::date2, Format::date3, Format::date4, Format::date5, Format::date6 } |
Date formats. More... | |
Public Member Functions | |
void | moveToEndOfMonth () |
Moves to end of month. More... | |
void | moveToEndOfYear () |
Moves to end of year. More... | |
bool | isValid () const |
Checks is date valid. More... | |
bool | isLeapYear () const |
Checks if date is in leap year. More... | |
bool | isEndOfMonth () const |
Checks if date is end of month. More... | |
bool | isEndOfYear () const |
Checks if date is end of year. More... | |
void | operator++ () |
Moves date to next date. More... | |
void | operator-- () |
Moves date back to last day. More... | |
void | operator+= (Tenor t) |
Adds tenor. More... | |
void | operator-= (Tenor t) |
Subtracts tenor. More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int) |
interface used by Boost serialization library More... | |
Constructors | |
Date () | |
Default constructor. More... | |
Date (int year, int month, int day) | |
Constructor. More... | |
Date (int yyyymmdd) | |
Date (std::string, Date::Format) | |
Constructor - from string YYYY-MM-DD. More... | |
Output getters | |
std::string | getString () const |
int | getDay () const |
int | getMonth () const |
int | getYear () const |
int | getN () const |
Calculate number of date. More... | |
Setters | |
void | setDay (int) |
void | setMonth (int) |
void | setYear (int) |
Private Member Functions | |
int | yearOffset () const |
Auxiliary method. More... | |
int | monthOffset () const |
Auxiliary method. More... | |
Private Attributes | |
int | year_ |
This is the integer value representing number of years. More... | |
int | month_ |
This is the integer value representing number of months. More... | |
int | day_ |
This is the integer value representing number of days. More... | |
Friends | |
class | boost::serialization::access |
Detailed Description
Class implements a date object.
This class provides methods to inspect dates as well as methods and operators which implement a limited date algebra (moving by year, month, day, or moving to end of month or year).
- Warning
- Date object can represent only the dates between 1900JAN01 and 2200DEC31
- Examples:
- algebraicBootstrapperExample.cpp, bootstrapperComparison.cpp, constrainedBootstrapperExample.cpp, DataFrameExample.cpp, DatesAndCalendarExample.cpp, DepositExample.cpp, InterestRateExample.cpp, optionPricingExample.cpp, rootFindingBootstrapperExample.cpp, and unconstrainedBootstrapperExample.cpp.
Member Enumeration Documentation
|
strong |
Date formats.
Enumerator | |
---|---|
date1 |
Format 2015-12-31 |
date2 |
Format 15-12-31 |
date3 |
Format 2015DEC31 |
date4 |
Format 2015/12/31 |
date5 |
Format 31/12/2015 |
date6 |
Format 31DEC2015 |
Constructor & Destructor Documentation
julian::Date::Date | ( | ) |
Default constructor.
Constructor creating invalid date: year, month and day number are set to zero. This allows to check if date was initialized or not.
julian::Date::Date | ( | int | year, |
int | month, | ||
int | day | ||
) |
Constructor.
Constructor creating date object on the basis of three integers representing year, month and day number.
julian::Date::Date | ( | std::string | date, |
Date::Format | fmt | ||
) |
Constructor - from string YYYY-MM-DD.
Constructor creating date object on the basis of string. (example date represent 31st of December, 2015):
- 2015-12-31
- 15-12-31
- 2015DEC31
- 2015/12/31
- 31/12/2015
- 31DEC2015
Member Function Documentation
int julian::Date::getN | ( | ) | const |
Calculate number of date.
Operator returns number of days between the date and 1900JAN01.
bool julian::Date::isEndOfMonth | ( | ) | const |
Checks if date is end of month.
Method returns true if date is a last day of its month and false otherwise.
bool julian::Date::isEndOfYear | ( | ) | const |
Checks if date is end of year.
Method returns true if date is a last day of its year and false otherwise.
bool julian::Date::isLeapYear | ( | ) | const |
Checks if date is in leap year.
Method returns true if date is in a leap year and false otherwise.
bool julian::Date::isValid | ( | ) | const |
Checks is date valid.
Method return true if the date is a valid date (month number between 1 and 12 and proper number of days) and false otherwise.
|
private |
Auxiliary method.
Auxiliary method used by method dateNumber to calculated number of days .
void julian::Date::moveToEndOfMonth | ( | ) |
Moves to end of month.
Method moves date to the end of the month.
void julian::Date::moveToEndOfYear | ( | ) |
Moves to end of year.
Method moves date to the end of the year.
void julian::Date::operator++ | ( | ) |
Moves date to next date.
Method increments date by a one day.
void julian::Date::operator+= | ( | Tenor | t | ) |
Adds tenor.
Operator moves date forward by a certain tenor. This operate will not do anything if OverNight, TommmorowNext, SpotDate, Today, SpotNext tenor given.
void julian::Date::operator-- | ( | ) |
Moves date back to last day.
Method decrements date by a one day.
void julian::Date::operator-= | ( | Tenor | t | ) |
Subtracts tenor.
Operator moves date backward by a certain tenor. This operate will not do anything if OverNight TommmorowNext, SpotDate, Today tenor given.
|
inline |
interface used by Boost serialization library
|
private |
Auxiliary method.
Auxiliary method used by method dateNumber to calculated number of days
Member Data Documentation
|
private |
This is the integer value representing number of days.
|
private |
This is the integer value representing number of months.
|
private |
This is the integer value representing number of years.
The documentation for this class was generated from the following files:
- C:/Unix/home/OEM/jULIAN/src/dates/date.hpp
- C:/Unix/home/OEM/jULIAN/src/dates/date.cpp