1#ifndef GREG_DATE_HPP___
2#define GREG_DATE_HPP___
20#include <boost/throw_exception.hpp>
21#include <boost/date_time/compiler_config.hpp>
22#include <boost/date_time/date.hpp>
23#include <boost/date_time/special_defs.hpp>
24#include <boost/date_time/gregorian/greg_calendar.hpp>
25#include <boost/date_time/gregorian/greg_duration.hpp>
31 using date_time::special_values;
32 using date_time::not_special;
33 using date_time::neg_infin;
34 using date_time::pos_infin;
35 using date_time::not_a_date_time;
36 using date_time::max_date_time;
37 using date_time::min_date_time;
46 class BOOST_SYMBOL_VISIBLE
date :
public date_time::date<date, gregorian_calendar, date_duration>
57#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
59 BOOST_CXX14_CONSTEXPR
date():
60 date_time::
date<
date, gregorian_calendar, date_duration>(
date_rep_type::from_special(not_a_date_time))
64 BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
65 : date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
67 if (gregorian_calendar::end_of_month_day(y, m) < d) {
68 boost::throw_exception(bad_day_of_month(std::string(
"Day of month is not valid for year")));
73 : date_time::
date<
date, gregorian_calendar, date_duration>(ymd)
77 date_time::
date<
date,gregorian_calendar, date_duration>(rhs)
81 date_time::
date<
date,gregorian_calendar, date_duration>(rhs)
84 BOOST_CXX14_CONSTEXPR
explicit date(special_values sv):
87 if (sv == min_date_time)
89 *
this =
date(1400, 1, 1);
91 if (sv == max_date_time)
93 *
this =
date(9999, 12, 31);
101 return gregorian_calendar::julian_day_number(ymd);
106 date start_of_year(year(), 1, 1);
107 unsigned short doy =
static_cast<unsigned short>((*
this-start_of_year).days() + 1);
114 return gregorian_calendar::modjulian_day_number(ymd);
120 return gregorian_calendar::week_number(ymd);
131 unsigned short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
132 return date(ymd.year, ymd.month, eom_day);
135 friend BOOST_CXX14_CONSTEXPR
142 inline BOOST_CXX14_CONSTEXPR
145 return lhs.days_ == rhs.days_;
A date type based on gregorian_calendar.
Definition: greg_date.hpp:47
BOOST_CXX14_CONSTEXPR date end_of_month() const
Return the last day of the current month.
Definition: greg_date.hpp:128
gregorian_calendar::year_type year_type
Definition: greg_date.hpp:49
gregorian_calendar::day_of_year_type day_of_year_type
Definition: greg_date.hpp:52
BOOST_CXX14_CONSTEXPR date_int_type day_number() const
Return the day number from the calendar.
Definition: greg_date.hpp:123
BOOST_CXX14_CONSTEXPR int week_number() const
Return the iso 8601 week number 1..53.
Definition: greg_date.hpp:117
gregorian_calendar::date_int_type date_int_type
Definition: greg_date.hpp:55
BOOST_CXX14_CONSTEXPR date(special_values sv)
Constructor for infinities, not a date, max and min date.
Definition: greg_date.hpp:84
BOOST_CXX14_CONSTEXPR date()
Default constructor constructs with not_a_date_time.
Definition: greg_date.hpp:59
date_duration duration_type
Definition: greg_date.hpp:56
BOOST_CXX14_CONSTEXPR date_int_type modjulian_day() const
Return the Modified Julian Day number for the date.
Definition: greg_date.hpp:111
BOOST_CXX14_CONSTEXPR date(const ymd_type &ymd)
Constructor from a ymd_type structure.
Definition: greg_date.hpp:72
gregorian_calendar::ymd_type ymd_type
Definition: greg_date.hpp:53
gregorian_calendar::day_type day_type
Definition: greg_date.hpp:51
BOOST_CXX14_CONSTEXPR date_int_type julian_day() const
Return the Julian Day number for the date.
Definition: greg_date.hpp:98
gregorian_calendar::date_rep_type date_rep_type
Definition: greg_date.hpp:54
BOOST_CXX14_CONSTEXPR date(const date_int_type &rhs)
Needed copy constructor.
Definition: greg_date.hpp:76
gregorian_calendar::month_type month_type
Definition: greg_date.hpp:50
BOOST_CXX14_CONSTEXPR date(date_rep_type rhs)
Needed copy constructor.
Definition: greg_date.hpp:80
BOOST_CXX14_CONSTEXPR day_of_year_type day_of_year() const
Return the day of year 1..365 or 1..366 (for leap year)
Definition: greg_date.hpp:104
BOOST_CXX14_CONSTEXPR bool operator==(const date &lhs, const date &rhs)
Definition: greg_date.hpp:143
Definition: greg_date.hpp:27