Introduction -- Usage Examples
Temporal Types
Class date -- Class date_duration -- Class date_period
Other Topics
Date Iterators -- Date Generators / Algorithms -- Class gregorian_calendar -- Class day_clock
The gregorian date system provides a date programming system based on the Gregorian Calendar. The current implementation supports dates in the range 1400-Jan-01 to 10000-Jan-01. The implemented calendar is a "propleptic Gregorian calendar" thus extending dates back prior to it's first adoption in in 1582.
Caution is required when handling historic dates as there are many adjustments required to account for the local adoption of various calendar systems. See Calendrical Calculations by Reingold & Dershowitz for more details. The current historical range of the calendar is not limited by algorithm, but rather time to write and perform tests to ensure correctness. It is expected that the range of this calendar system will continue to increase in the future.
Date information from Calendrical Calculations has been used to cross-test the correctness of the Gregorian calendar implementation.
All types for the gregorian system are found in namespace boost::gregorian. The library supports a convience header boost/date_time/gregorian/gregorian_types.hpp that will include all the classes of the library with no input/output depedency. Another header boost/date_time/gregorian/gregorian.hpp will include the types and the input/output code.
The class boost::gregorian::date is the primary temporal type for users. If you are interested in learning about writing programs do specialized date calculations such as finding the "first sunday in april" see the date generators and algorithms page.
Example | Description |
Days Alive Days Till New Year | Simple date arithmetic. Retrieve current day from clock. |
Dates as strings | Simple parsing and formmatting of dates from/to strings |
Date Period Calculations | See if a date is in a set of date periods (eg: is it a holiday/weekend) |
Print a month | Small utility program which prints out all the days in a month from command line. Need to know if 1999-Jan-1 was a Friday or a Saturday? This program shows how to do it. |
Print Holidays | Uses date generators to convert abstract specification into concrete set of dates. |