| Home | Libraries | People | FAQ | More

## Class date

boost::gregorian::date — A date type based on gregorian_calendar.

## Synopsis

    // In header: <boost/date_time/gregorian/greg_date.hpp>

    class date :
      public date_time::date< date, gregorian_calendar, date_duration >
    {
    public:
      // types
      typedef gregorian_calendar::year_type        year_type;
      typedef gregorian_calendar::month_type       month_type;
      typedef gregorian_calendar::day_type         day_type;
      typedef gregorian_calendar::day_of_year_type day_of_year_type;
      typedef gregorian_calendar::ymd_type         ymd_type;
      typedef gregorian_calendar::date_rep_type    date_rep_type;
      typedef gregorian_calendar::date_int_type    date_int_type;
      typedef date_duration                        duration_type;

      // public member functions
      date();
      date(year_type, month_type, day_type);
      explicit date(const ymd_type &);
      explicit date(const date_int_type &);
      explicit date(date_rep_type);
      explicit date(special_values);
      BOOST_CXX14_CONSTEXPR date_int_type julian_day() const;
      BOOST_CXX14_CONSTEXPR day_of_year_type day_of_year() const;
      BOOST_CXX14_CONSTEXPR date_int_type modjulian_day() const;
      BOOST_CXX14_CONSTEXPR int week_number() const;
      BOOST_CXX14_CONSTEXPR date_int_type day_number() const;
      BOOST_CXX14_CONSTEXPR date end_of_month() const;

      // private member functions
      BOOST_CXX14_CONSTEXPR date_rep_type from_special_adjusted(special_values);
    };

## Description

This class is the primary interface for programming with greogorian dates. The is a lightweight type that can be freely passed by value. All comparison operators are supported.

### `date` public member functions

1.     date();

   Default constructor constructs with not_a_date_time.

2.     date(year_type y, month_type m, day_type d);

   Main constructor with year, month, day.

3.     explicit date(const ymd_type & ymd);

   Constructor from a ymd_type structure.

4.     explicit date(const date_int_type & rhs);

   Needed copy constructor.

5.     explicit date(date_rep_type rhs);

   Needed copy constructor.

6.     explicit date(special_values sv);

   Constructor for infinities, not a date, max and min date.

7.     BOOST_CXX14_CONSTEXPR date_int_type julian_day() const;

   Return the Julian Day number for the date.

8.     BOOST_CXX14_CONSTEXPR day_of_year_type day_of_year() const;

   Return the day of year 1..365 or 1..366 (for leap year)

9.     BOOST_CXX14_CONSTEXPR date_int_type modjulian_day() const;

   Return the Modified Julian Day number for the date.

10.     BOOST_CXX14_CONSTEXPR int week_number() const;

    Return the ISO 8601 week number 1..53.

11.     BOOST_CXX14_CONSTEXPR date_int_type day_number() const;

    Return the day number from the calendar.

12.     BOOST_CXX14_CONSTEXPR date end_of_month() const;

    Return the last day of the current month.

### `date` private member functions

1.     BOOST_CXX14_CONSTEXPR date_rep_type from_special_adjusted(special_values sv);