Boost::Date_Time::gregorian














































Boost::Date_Time::gregorian



DESCRIPTION:

Boost.DateTime only supports calendar dates based on the Gregorian calendar, which in general is not a problem since this is the most widely used calendar. If you arrange a meeting with someone for May 12, 2014, you don%u2019t need to say that the date is based on the Gregorian calendar.

The Gregorian calendar was introduced by Pope Gregory XIII in 1582. Boost.DateTime supports calendar dates for the years 1400 to 9999, which means that support goes back before the year 1582. Thus, you can use Boost.DateTime for any calendar date after the year 1400 as long as that date is converted to the Gregorian calendar. To process earlier dates, Boost.DateTime has to be extended by a new calendar.

The header file boost/date_time/gregorian/gregorian.hpp contains definitions for all classes and functions that process calendar dates. These functions and classes can be found in the namespace boost::gregorian. To create a date, use the class boost::gregorian::date.


//////PROGRAM CODE/////

#include <boost/date_time/gregorian/gregorian.hpp> #include <iostream> int main() { boost::gregorian::date d{2014, 1, 31}; std::cout << d.year() << '\n'; std::cout << d.month() << '\n'; std::cout << d.day() << '\n'; std::cout << d.day_of_week() << '\n'; std::cout << d.end_of_month() << '\n'; }


///OUTPUT///

2014

Jan

31

Fri

2014-Jan-31



Comments