31#ifndef quantlib_date_hpp
32#define quantlib_date_hpp
38#ifdef QL_HIGH_RESOLUTION_DATE
39#include <boost/date_time/posix_time/ptime.hpp>
40#include <boost/date_time/posix_time/posix_time_duration.hpp>
89#ifdef QL_HIGH_RESOLUTION_DATE
92 typedef boost::posix_time::hours::hour_type Hour;
96 typedef boost::posix_time::minutes::min_type Minute;
100 typedef boost::posix_time::minutes::sec_type Second;
104 typedef boost::posix_time::time_duration::fractional_seconds_type
109 typedef boost::posix_time::time_duration::fractional_seconds_type
138#ifdef QL_HIGH_RESOLUTION_DATE
140 explicit Date(
const boost::posix_time::ptime& localTime);
143 Hour hours, Minute minutes, Second seconds,
144 Millisecond millisec = 0, Microsecond microsec = 0);
158#ifdef QL_HIGH_RESOLUTION_DATE
160 Minute minutes()
const;
161 Second seconds()
const;
162 Millisecond milliseconds()
const;
163 Microsecond microseconds()
const;
165 Time fractionOfDay()
const;
166 Time fractionOfSecond()
const;
168 const boost::posix_time::ptime& dateTime()
const;
233#ifdef QL_HIGH_RESOLUTION_DATE
235 static Date localDateTime();
237 static Date universalDateTime();
240 static boost::posix_time::time_duration::tick_type ticksPerSecond();
250#ifdef QL_HIGH_RESOLUTION_DATE
251 boost::posix_time::ptime dateTime_;
337#ifdef QL_HIGH_RESOLUTION_DATE
338 struct iso_datetime_holder {
339 explicit iso_datetime_holder(
const Date&
d) :
d(
d) {}
342 std::ostream&
operator<<(std::ostream&,
const iso_datetime_holder&);
350 detail::short_date_holder
short_date(
const Date&);
354 detail::long_date_holder
long_date(
const Date&);
358 detail::iso_date_holder
iso_date(
const Date&);
363 const std::string& fmt);
365#ifdef QL_HIGH_RESOLUTION_DATE
368 detail::iso_datetime_holder iso_datetime(
const Date&);
373 #ifdef QL_NULL_AS_FUNCTIONS
377 inline Date Null<Date>() {
387 operator Date()
const {
return {}; }
392#ifndef QL_HIGH_RESOLUTION_DATE
397 return Weekday(w == 0 ? 7 : w);
Date & operator-=(Date::serial_type days)
decrement date by the given number of days
static Date::serial_type yearOffset(Year y)
static Date minDate()
earliest allowed date
static Date todaysDate()
today's date.
static Date::serial_type maximumSerialNumber()
Date operator-(Date::serial_type days) const
returns a new date decremented by the given number of days
Date::serial_type serialNumber_
Date operator+(Date::serial_type days) const
returns a new date incremented by the given number of days
Date & operator+=(Date::serial_type days)
increments date by the given number of days
Date & operator--()
1-day pre-decrement
static Date endOfMonth(const Date &d)
last day of the month to which the given date belongs
static Integer monthOffset(Month m, bool leapYear)
Date & operator++()
1-day pre-increment
static Integer monthLength(Month m, bool leapYear)
Day dayOfYear() const
One-based (Jan 1st = 1)
static bool isEndOfMonth(const Date &d)
whether a date is the last day of its month
std::int_fast32_t serial_type
serial number type
Date::serial_type serialNumber() const
static Date advance(const Date &d, Integer units, TimeUnit)
static Date::serial_type minimumSerialNumber()
static void checkSerialNumber(Date::serial_type serialNumber)
static Date nthWeekday(Size n, Weekday w, Month m, Year y)
n-th given weekday in the given month and year
static bool isLeap(Year y)
whether the given year is a leap one
static Date nextWeekday(const Date &d, Weekday w)
next given weekday following or equal to the given date
static Date maxDate()
latest allowed date
Date()
Default constructor returning a null date.
template class providing a null value for a given type.
TimeUnit
Units used to describe time periods.
detail::short_date_holder short_date(const Date &d)
output dates in short format (mm/dd/yyyy)
detail::long_date_holder long_date(const Date &d)
output dates in long format (Month ddth, yyyy)
detail::formatted_date_holder formatted_date(const Date &d, const std::string &f)
output dates in user defined format using boost date functionality
detail::iso_date_holder iso_date(const Date &d)
output dates in ISO format (yyyy-mm-dd)
Real Time
continuous quantity with 1-year units
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
std::ostream & operator<<(std::ostream &out, const short_date_holder &holder)
Quantity operator-(const Quantity &m1, const Quantity &m2)
bool operator==(const Currency &c1, const Currency &c2)
bool operator<(const Quantity &m1, const Quantity &m2)
bool operator>=(const Quantity &m1, const Quantity &m2)
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
bool operator!=(const Currency &c1, const Currency &c2)
bool operator>(const Quantity &m1, const Quantity &m2)
Real days(const Period &p)
std::size_t hash_value(const Date &d)
bool operator<=(const Quantity &m1, const Quantity &m2)
Time daysBetween(const Date &d1, const Date &d2)
period- and frequency-related classes and enumerations
iso_date_holder(const Date &d)
long_date_holder(const Date &d)
short_date_holder(const Date d)
std::size_t operator()(const QuantLib::Date &d) const