...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The following is a detailed reference of the date_time library. A click on any of the reference links will take you to a list of the header files found in that section. Following one of those links will take you to a list of the items declared in that header file. Further sublinks take you to detailed descriptions of each individual item.
namespace boost { namespace date_time { template<typename date_type> class day_functor; template<typename date_type> class month_functor; template<typename date_type> class week_functor; template<typename date_type> class year_functor; } }
Time adjustment calculations based on machine
namespace boost { namespace date_time { template<typename time_type> class c_local_adjustor; } }
Provide workarounds related to the ctime header
namespace std { }namespace boost { namespace date_time { struct c_time; } }
namespace boost { namespace CV { template<typename value_policies> class constrained_value; template<typename rep_type, rep_type min_value, rep_type max_value, typename exception_type> class simple_exception_policy; // Represent a min or max violation type. enum violation_enum { min_violation, max_violation }; } }
namespace boost { namespace date_time { template<typename T, typename calendar, typename duration_type_> class date; } }
namespace boost { namespace date_time { template<typename date_type> class day_clock; } }
namespace boost { namespace date_time { // An enumeration of weekday names. enum weekdays { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; // Simple enum to allow for nice programming with Jan, Feb, etc. enum months_of_year { Jan = =1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, NotAMonth, NumMonths }; } }
namespace boost { namespace date_time { template<typename duration_rep_traits> class date_duration; struct duration_traits_adapted; struct duration_traits_long; } }
namespace boost { namespace date_time { template<typename base_config> class months_duration; template<typename duration_config> class weeks_duration; template<typename base_config> class years_duration; class BOOST_SYMBOL_VISIBLE years_duration; } }
namespace boost { namespace date_time { template<typename date_type, typename CharT, typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > class date_facet; template<typename date_type, typename CharT, typename InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > > class date_input_facet; } }
namespace boost { namespace date_time { template<typename charT> class simple_format; template<> class simple_format<wchar_t>; } }
namespace boost { namespace date_time { template<typename date_type, typename format_type> class date_formatter; template<typename month_type, typename format_type> class month_formatter; template<typename ymd_type, typename format_type> class ymd_formatter; } }
namespace boost { namespace date_time { template<typename date_type, typename facet_type, typename charT = char> class ostream_date_formatter; template<typename facet_type, typename charT = char> class ostream_month_formatter; template<typename weekday_type, typename facet_type, typename charT = char> class ostream_weekday_formatter; template<typename ymd_type, typename facet_type, typename charT = char> class ostream_ymd_formatter; } }
namespace boost { namespace date_time { template<typename date_type, typename CharT, typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > class date_generator_formatter; } }
namespace boost { namespace date_time { template<typename date_type, typename charT> class date_generator_parser; } }
Definition and implementation of date algorithm templates
namespace boost { namespace date_time { template<typename date_type> class first_kday_after; template<typename date_type> class first_kday_before; template<typename date_type> class first_kday_of_month; template<typename date_type> class last_kday_of_month; template<typename date_type> class nth_kday_of_month; template<typename date_type> class partial_date; template<typename date_type> class year_based_generator; // Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5. BOOST_DATE_TIME_DECL const char * nth_as_str(int n); template<typename date_type, typename weekday_type> date_type::duration_type days_until_weekday(const date_type &, const weekday_type &); template<typename date_type, typename weekday_type> date_type::duration_type days_before_weekday(const date_type &, const weekday_type &); template<typename date_type, typename weekday_type> date_type next_weekday(const date_type &, const weekday_type &); template<typename date_type, typename weekday_type> date_type previous_weekday(const date_type &, const weekday_type &); } }
namespace boost { namespace date_time { template<typename offset_functor, typename date_type> class date_itr; template<typename date_type> class date_itr_base; // An iterator over dates with varying resolution (day, week, month, year, etc) enum date_resolutions { day, week, months, year, decade, century, NumDateResolutions }; } }
namespace boost { namespace date_time { template<typename Config, typename charT = char, typename OutputIterator = std::ostreambuf_iterator<charT> > class all_date_names_put; template<typename Config, typename charT = char, typename OutputIterator = std::ostreambuf_iterator<charT> > class date_names_put; } }
namespace boost { namespace date_time { std::string convert_to_lower(std::string); // Helper function for parse_date. template<typename month_type> unsigned short month_str_to_ushort(std::string const & s); template<typename charT> short find_match(const charT *const *, const charT *const *, short, const std::basic_string< charT > &); template<typename date_type> date_type parse_date(const std::string &, int = ymd_order_iso); // Generic function to parse undelimited date (eg: 20020201) template<typename date_type> date_type parse_undelimited_date(const std::string & s); template<typename date_type, typename iterator_type> date_type from_stream_type(iterator_type &, iterator_type const &, char); template<typename date_type, typename iterator_type> date_type from_stream_type(iterator_type &, iterator_type const &, std::string const &); template<typename date_type, typename iterator_type> date_type from_stream_type(iterator_type &, iterator_type const &, wchar_t); template<typename date_type, typename iterator_type> date_type from_stream_type(iterator_type &, iterator_type const &, std::wstring const &); // function called by wrapper functions: date_period_from_(w)string() template<typename date_type, typename charT> period< date_type, typename date_type::duration_type > from_simple_string_type(const std::basic_string< charT > & s); } }
Contains template class to provide static dst rule calculations
namespace boost { namespace date_time { template<typename date_type, typename time_duration_type, typename dst_traits> class dst_calc_engine; template<typename date_type_, typename time_duration_type_> class dst_calculator; template<typename date_type_, typename time_duration_type_> class null_dst_rules; template<typename date_type_, typename time_duration_type_, unsigned int dst_start_offset_minutes = 120, short dst_length_minutes = 60> class us_dst_rules; enum time_is_dst_result { is_not_in_dst, is_in_dst, ambiguous, invalid_time_label }; } }
namespace boost { namespace date_time { template<typename spec> class day_calc_dst_rule; template<typename date_type> class dst_day_calc_rule; } }
Function(s) for converting between a FILETIME structure and a time object. This file is only available on systems that have BOOST_HAS_FTIME defined.
namespace boost { namespace date_time { template<typename TimeT, typename FileTimeT> TimeT time_from_ftime(const FileTimeT &); } }
namespace std { }namespace boost { namespace date_time { template<typename date_type, typename charT> class format_date_parser; template<typename int_type, typename charT> int_type fixed_string_to_int(std::istreambuf_iterator< charT > &, std::istreambuf_iterator< charT > &, parse_match_result< charT > &, unsigned int, const charT &); template<typename int_type, typename charT> int_type fixed_string_to_int(std::istreambuf_iterator< charT > &, std::istreambuf_iterator< charT > &, parse_match_result< charT > &, unsigned int); template<typename int_type, typename charT> int_type var_string_to_int(std::istreambuf_iterator< charT > &, const std::istreambuf_iterator< charT > &, unsigned int); } }
namespace boost { namespace date_time { template<typename ymd_type_, typename date_int_type_> class gregorian_calendar_base; } }
namespace boost { namespace date_time { template<typename int_type_> class int_adapter; template<typename charT, typename traits, typename int_type> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, const int_adapter< int_type > &); } }
namespace boost { namespace date_time { template<typename charT> class iso_extended_format; template<typename charT> class iso_format; template<typename charT> class iso_format_base; template<> class iso_format_base<wchar_t>; } }
Time adjustment calculations for local times
namespace boost { namespace date_time { template<typename time_type, typename dst_rules> class dynamic_local_time_adjustor; template<typename time_type, short utc_offset, typename dst_rule> class local_adjustor; template<typename time_type, typename dst_rules, typename utc_offset_rules> class static_local_time_adjustor; template<typename time_duration_type, short hours, unsigned short minutes = 0> class utc_adjustment; void dummy_to_prevent_msvc6_ice(); } }
namespace boost { namespace date_time { template<typename date_type> struct acst_dst_trait; template<typename date_type> struct eu_dst_trait; template<typename date_type> struct uk_dst_trait; template<typename date_type> struct us_dst_trait; } }
This file contains a high resolution time clock implementation.
namespace boost { namespace date_time { template<typename time_type> class microsec_clock; } }
namespace boost { namespace date_time { // Enum for distinguishing parsing and formatting options. enum month_format_spec { month_as_integer, month_as_short_string, month_as_long_string }; enum ymd_order_spec; } }
This file contain the implementation of the period abstraction. This is basically the same idea as a range. Although this class is intended for use in the time library, it is pretty close to general enough for other numeric uses.
namespace boost { namespace date_time { template<typename point_rep, typename duration_rep> class period; } }
namespace boost { namespace date_time { template<typename CharT, typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > class period_formatter; } }
namespace boost { namespace date_time { template<typename date_type, typename CharT> class period_parser; } }
namespace boost { namespace date_time { enum special_values { not_a_date_time, neg_infin, pos_infin, min_date_time, max_date_time, not_special, NumSpecialValues }; } }
namespace boost { namespace date_time { template<typename CharT, typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > class special_values_formatter; } }
namespace boost { namespace date_time { template<typename date_type, typename charT> class special_values_parser; } }
namespace boost { namespace date_time { template<typename InputT, typename OutputT> std::basic_string< OutputT > convert_string_type(const std::basic_string< InputT > &); } }
namespace boost { namespace date_time { template<typename charT> struct parse_match_result; template<typename charT> struct string_parse_tree; template<typename charT> std::basic_ostream< charT > & operator<<(std::basic_ostream< charT > & os, parse_match_result< charT > & mr); } }
namespace boost { namespace date_time { template<typename charT> std::vector< std::basic_string< charT > > gather_month_strings(const std::locale &, bool = true); template<typename charT> std::vector< std::basic_string< charT > > gather_weekday_strings(const std::locale &, bool = true); } }
This file contains the interface for the time associated classes.
namespace boost { namespace date_time { template<typename T, typename time_system> class base_time; } }
This file contains the interface for clock devices.
namespace boost { namespace date_time { template<typename time_type> class second_clock; } }
This file contains nice definitions for handling the resoluion of various time reprsentations.
namespace boost { namespace date_time { // Defines some nice types for handling time level resolutions. enum time_resolutions { sec, tenth, hundreth, hundredth = = hundreth, milli, ten_thousandth, micro, nano, NumResolutions }; // Flags for daylight savings or summer time. enum dst_flags { not_dst, is_dst, calculate }; } }
namespace boost { namespace date_time { template<typename base_duration, boost::int64_t frac_of_second> class subsecond_duration; template<typename T, typename rep_type> class time_duration; } }
namespace boost { namespace date_time { template<typename time_type, typename CharT, typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > class time_facet; template<typename CharT> struct time_formats; template<typename time_type, typename CharT, typename InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > > class time_input_facet; } }
namespace boost { namespace date_time { template<typename time_duration_type, typename charT = char> class ostream_time_duration_formatter; template<typename time_type, typename charT = char> class ostream_time_formatter; template<typename time_period_type, typename charT = char> class ostream_time_period_formatter; } }
namespace boost { namespace date_time { template<typename time_type> class time_itr; } }
namespace boost { namespace date_time { // computes exponential math like 2^8 => 256, only works with positive integers template<typename int_type> int_type power(int_type base, int_type exponent); template<typename time_duration, typename char_type> time_duration str_from_delimited_time_duration(const std::basic_string< char_type > &); template<typename time_duration> time_duration parse_delimited_time_duration(const std::string &); // Utility function to split appart string. bool split(const std::string & s, char sep, std::string & first, std::string & second); template<typename time_type> time_type parse_delimited_time(const std::string & s, char sep); // Parse time duration part of an iso time of form: [-]hhmmss.fff... template<typename time_duration> time_duration parse_undelimited_time_duration(const std::string & s); // Parse time string of form YYYYMMDDThhmmss where T is delimeter between date and time. template<typename time_type> time_type parse_iso_time(const std::string & s, char sep); } }
namespace boost { namespace date_time { template<typename frac_sec_type, time_resolutions res, #if(defined(BOOST_MSVC) &&(_MSC_VER< 1300)) boost::int64_t resolution_adjust, #else typename frac_sec_type::int_type resolution_adjust, #endif unsigned short frac_digits, typename var_type = boost::int64_t> class time_resolution_traits; struct time_resolution_traits_adapted32_impl; struct time_resolution_traits_adapted64_impl; struct time_resolution_traits_bi32_impl; struct time_resolution_traits_bi64_impl; typedef time_resolution_traits< time_resolution_traits_adapted32_impl, milli, 1000, 3 > milli_res; typedef time_resolution_traits< time_resolution_traits_adapted64_impl, micro, 1000000, 6 > micro_res; typedef time_resolution_traits< time_resolution_traits_adapted64_impl, nano, 1000000000, 9 > nano_res; // Simple function to calculate absolute value of a numeric type. template<typename T> T absolute_value(T x); } }
namespace boost { namespace date_time { template<typename config> struct counted_time_rep; template<typename time_rep> class counted_time_system; } }
namespace boost { namespace date_time { template<typename config, boost::int32_t ticks_per_second> class split_timedate_system; } }
namespace boost { namespace date_time { template<typename time_duration_type> class dst_adjustment_offsets; template<typename time_type, typename CharT> class time_zone_base; } }
namespace boost { namespace date_time { template<typename CharT> struct default_zone_names; template<typename CharT> class time_zone_names_base; } }
namespace boost { namespace date_time { class bad_field_count; class data_not_accessible; template<typename time_zone_type, typename rule_type> class tz_db_base; } }
namespace boost { namespace date_time { template<typename int_type_, int_type_ wrap_val> class wrapping_int; template<typename int_type_, int_type_ wrap_min, int_type_ wrap_max> class wrapping_int2; } }
namespace boost { namespace date_time { template<typename YearType, typename MonthType, typename DayType> struct year_month_day_base; } }
namespace boost { namespace gregorian { // Converts a date to a tm struct. Throws out_of_range exception if date is a special value. std::tm to_tm(const date & d); // Converts a tm structure into a date dropping the any time values. date date_from_tm(const std::tm & datetm); } }
namespace boost { namespace gregorian { template<typename charT> std::basic_string< charT > to_simple_string_type(const date & d); template<typename charT> std::basic_string< charT > to_simple_string_type(const date_period & d); template<typename charT> std::basic_string< charT > to_iso_string_type(const date_period & d); template<typename charT> std::basic_string< charT > to_iso_extended_string_type(const date & d); template<typename charT> std::basic_string< charT > to_iso_string_type(const date & d); template<typename charT> std::basic_string< charT > to_sql_string_type(const date & d); // Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]. std::wstring to_simple_wstring(const date_period & d); // To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01. std::wstring to_simple_wstring(const date & d); // Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231. std::wstring to_iso_wstring(const date_period & d); // Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31. std::wstring to_iso_extended_wstring(const date & d); // Convert to iso standard string YYYYMMDD. Example: 20021231. std::wstring to_iso_wstring(const date & d); std::wstring to_sql_wstring(const date & d); } }
namespace boost { namespace gregorian { // To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01. std::string to_simple_string(const date & d); // Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]. std::string to_simple_string(const date_period & d); // Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231. std::string to_iso_string(const date_period & d); // Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31. std::string to_iso_extended_string(const date & d); // Convert to iso standard string YYYYMMDD. Example: 20021231. std::string to_iso_string(const date & d); std::string to_sql_string(const date & d); } }
namespace boost { namespace gregorian { class gregorian_calendar; typedef date_time::int_adapter< uint32_t > fancy_date_rep; // An internal date representation that includes infinities, not a date. } }
namespace boost { namespace gregorian { class date; } }
namespace boost { namespace gregorian { struct bad_day_of_month; class greg_day; typedef CV::simple_exception_policy< unsigned short, 1, 31, bad_day_of_month > greg_day_policies; // Policy class that declares error handling and day of month ranges. typedef CV::constrained_value< greg_day_policies > greg_day_rep; // Generated represetation for gregorian day of month. } }
namespace boost { namespace gregorian { struct bad_day_of_year; typedef CV::simple_exception_policy< unsigned short, 1, 366, bad_day_of_year > greg_day_of_year_policies; // A day of the year range (1..366) typedef CV::constrained_value< greg_day_of_year_policies > greg_day_of_year_rep; // Define a range representation type for the day of the year 1..366. } }
namespace boost { namespace gregorian { class date_duration; typedef boost::date_time::duration_traits_adapted date_duration_rep; // An internal date representation that includes infinities, not a date. typedef date_duration days; // Shorthand for date_duration. } }
namespace boost { namespace gregorian { struct greg_durations_config; class weeks_duration; typedef date_time::months_duration< greg_durations_config > months; typedef date_time::years_duration< greg_durations_config > years; typedef weeks_duration weeks; } }
namespace boost { namespace gregorian { struct greg_facet_config; typedef boost::date_time::date_names_put< greg_facet_config > greg_base_facet; // Create the base facet type for gregorian::date. template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, const date &); template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, const greg_month &); template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, const greg_weekday &); template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, const date_period &); template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const date_duration & dd); // operator<< for gregorian::partial_date. Output: "Jan 1" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const partial_date & pd); // operator<< for gregorian::nth_kday_of_month. Output: "first Mon of Jun" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const nth_kday_of_month & nkd); // operator<< for gregorian::first_kday_of_month. Output: "first Mon of Jun" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const first_kday_of_month & fkd); // operator<< for gregorian::last_kday_of_month. Output: "last Mon of Jun" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const last_kday_of_month & lkd); // operator<< for gregorian::first_kday_after. Output: "first Mon after" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const first_kday_after & fka); // operator<< for gregorian::first_kday_before. Output: "first Mon before" template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const first_kday_before & fkb); // operator>> for gregorian::date template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, date & d); // operator>> for gregorian::date_duration template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, date_duration & dd); // operator>> for gregorian::date_period template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, date_period & dp); // generates a locale with the set of gregorian name-strings of type char* BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale & loc, char type); // Returns a pointer to a facet with a default set of names (English) BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put< greg_facet_config, char > * create_facet_def(char type); // generates a locale with the set of gregorian name-strings of type wchar_t* BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale & loc, wchar_t type); // Returns a pointer to a facet with a default set of names (English) BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put< greg_facet_config, wchar_t > * create_facet_def(wchar_t type); // operator>> for gregorian::greg_month - throws exception if invalid month given template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, greg_month & m); // operator>> for gregorian::greg_weekday - throws exception if invalid weekday given template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, greg_weekday & wd); } }
namespace boost { namespace gregorian { struct bad_month; class greg_month; typedef date_time::months_of_year months_of_year; typedef CV::simple_exception_policy< unsigned short, 1, 12, bad_month > greg_month_policies; // Build a policy class for the greg_month_rep. typedef CV::constrained_value< greg_month_policies > greg_month_rep; // A constrained range that implements the gregorian_month rules. } }
namespace boost { namespace gregorian { struct bad_weekday; class greg_weekday; typedef CV::simple_exception_policy< unsigned short, 0, 6, bad_weekday > greg_weekday_policies; typedef CV::constrained_value< greg_weekday_policies > greg_weekday_rep; } }
namespace boost { namespace gregorian { struct bad_year; class greg_year; typedef CV::simple_exception_policy< unsigned short, 1400, 9999, bad_year > greg_year_policies; // Policy class that declares error handling gregorian year type. typedef CV::constrained_value< greg_year_policies > greg_year_rep; // Generated representation for gregorian year. } }
namespace boost { namespace gregorian { typedef date_time::year_month_day_base< greg_year, greg_month, greg_day > greg_year_month_day; } }
Single file header that provides overall include for all elements of the gregorian date-time system. This includes the various types defined, but also other functions for formatting and parsing.
namespace boost { namespace gregorian { typedef boost::date_time::period_formatter< wchar_t > wperiod_formatter; typedef boost::date_time::period_formatter< char > period_formatter; typedef boost::date_time::date_facet< date, wchar_t > wdate_facet; typedef boost::date_time::date_facet< date, char > date_facet; typedef boost::date_time::period_parser< date, char > period_parser; typedef boost::date_time::period_parser< date, wchar_t > wperiod_parser; typedef boost::date_time::special_values_formatter< char > special_values_formatter; typedef boost::date_time::special_values_formatter< wchar_t > wspecial_values_formatter; typedef boost::date_time::special_values_parser< date, char > special_values_parser; typedef boost::date_time::special_values_parser< date, wchar_t > wspecial_values_parser; typedef boost::date_time::date_input_facet< date, char > date_input_facet; typedef boost::date_time::date_input_facet< date, wchar_t > wdate_input_facet; template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::date & d); // input operator for date template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, date & d); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::date_duration & dd); // input operator for date_duration template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, date_duration & dd); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::date_period & dp); // input operator for date_period template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, date_period & dp); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::greg_month & gm); // input operator for greg_month template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, greg_month & m); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::greg_weekday & gw); // input operator for greg_weekday template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, greg_weekday & wd); // input operator for greg_day template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, greg_day & gd); // input operator for greg_year template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, greg_year & gy); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::partial_date & pd); // input operator for partial_date template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, partial_date & pd); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::nth_day_of_the_week_in_month & nkd); // input operator for nth_day_of_the_week_in_month template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, nth_day_of_the_week_in_month & nday); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::first_day_of_the_week_in_month & fkd); // input operator for first_day_of_the_week_in_month template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, first_day_of_the_week_in_month & fkd); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::last_day_of_the_week_in_month & lkd); // input operator for last_day_of_the_week_in_month template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, last_day_of_the_week_in_month & lkd); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::first_day_of_the_week_after & fda); // input operator for first_day_of_the_week_after template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, first_day_of_the_week_after & fka); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::gregorian::first_day_of_the_week_before & fdb); // input operator for first_day_of_the_week_before template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, first_day_of_the_week_before & fkb); } }
Single file header that defines most of the types for the gregorian date-time system.
namespace boost { namespace gregorian { typedef date_time::period< date, date_duration > date_period; // Date periods for the gregorian system. typedef date_time::year_based_generator< date > year_based_generator; typedef date_time::partial_date< date > partial_date; // A date generation object type. typedef date_time::nth_kday_of_month< date > nth_kday_of_month; typedef nth_kday_of_month nth_day_of_the_week_in_month; typedef date_time::first_kday_of_month< date > first_kday_of_month; typedef first_kday_of_month first_day_of_the_week_in_month; typedef date_time::last_kday_of_month< date > last_kday_of_month; typedef last_kday_of_month last_day_of_the_week_in_month; typedef date_time::first_kday_after< date > first_kday_after; typedef first_kday_after first_day_of_the_week_after; typedef date_time::first_kday_before< date > first_kday_before; typedef first_kday_before first_day_of_the_week_before; typedef date_time::day_clock< date > day_clock; // A clock to get the current day from the local computer. typedef date_time::date_itr_base< date > date_iterator; // Base date_iterator type for gregorian types. typedef date_time::date_itr< date_time::day_functor< date >, date > day_iterator; // A day level iterator. typedef date_time::date_itr< date_time::week_functor< date >, date > week_iterator; // A week level iterator. typedef date_time::date_itr< date_time::month_functor< date >, date > month_iterator; // A month level iterator. typedef date_time::date_itr< date_time::year_functor< date >, date > year_iterator; // A year level iterator. } }
namespace boost { namespace gregorian { BOOST_DATE_TIME_DECL special_values special_value_from_string(const std::string &); // Deprecated: Use from_simple_string. date from_string(std::string s); // From delimited date string where with order year-month-day eg: 2002-1-25 or 2003-Jan-25 (full month name is also accepted) date from_simple_string(std::string s); // From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted) date from_us_string(std::string s); // From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted) date from_uk_string(std::string s); // From iso type date string where with order year-month-day eg: 20020125. date from_undelimited_string(std::string s); // From iso type date string where with order year-month-day eg: 20020125. date date_from_iso_string(const std::string & s); // Stream should hold a date in the form of: 2002-1-25. Month number, abbrev, or name are accepted. template<typename iterator_type> date from_stream(iterator_type beg, iterator_type end); // Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25]) date_period date_period_from_string(const std::string & s); // Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25]) date_period date_period_from_wstring(const std::wstring & s); } }
namespace boost { namespace posix_time { // Function that converts a time_t into a ptime. ptime from_time_t(std::time_t t); // Function that converts a ptime into a time_t. std::time_t to_time_t(ptime pt); // Convert a time to a tm structure truncating any fractional seconds. std::tm to_tm(const boost::posix_time::ptime & t); // Convert a time_duration to a tm structure truncating any fractional seconds and zeroing fields for date components. std::tm to_tm(const boost::posix_time::time_duration & td); // Convert a tm struct to a ptime ignoring is_dst flag. ptime ptime_from_tm(const std::tm & timetm); template<typename TimeT, typename FileTimeT> TimeT from_ftime(const FileTimeT &); } }
Operators for ptime and optional gregorian types. Operators use snap-to-end-of-month behavior. Further details on this behavior can be found in reference for date_time/date_duration_types.hpp and documentation for month and year iterators.
namespace boost { namespace posix_time { ptime operator+(const ptime &, const boost::gregorian::months &); ptime operator+=(ptime &, const boost::gregorian::months &); ptime operator-(const ptime &, const boost::gregorian::months &); ptime operator-=(ptime &, const boost::gregorian::months &); ptime operator+(const ptime &, const boost::gregorian::years &); ptime operator+=(ptime &, const boost::gregorian::years &); ptime operator-(const ptime &, const boost::gregorian::years &); ptime operator-=(ptime &, const boost::gregorian::years &); } }
Global header file to get all of posix time types
namespace boost { namespace posix_time { class millisec_posix_time_system_config; class posix_time_system_config; struct simple_time_rep; class time_duration; typedef date_time::time_resolution_traits< boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano, 1000000000, 9 > time_res_traits; } }
namespace boost { namespace posix_time { class hours; class minutes; class seconds; typedef date_time::subsecond_duration< time_duration, 1000 > millisec; // Allows expression of durations as milli seconds. typedef date_time::subsecond_duration< time_duration, 1000 > milliseconds; typedef date_time::subsecond_duration< time_duration, 1000000 > microsec; // Allows expression of durations as micro seconds. typedef date_time::subsecond_duration< time_duration, 1000000 > microseconds; typedef date_time::subsecond_duration< time_duration, 1000000000 > nanosec; // Allows expression of durations as nano seconds. typedef date_time::subsecond_duration< time_duration, 1000000000 > nanoseconds; } }
namespace boost { namespace posix_time { typedef boost::date_time::time_facet< ptime, wchar_t > wtime_facet; typedef boost::date_time::time_facet< ptime, char > time_facet; typedef boost::date_time::time_input_facet< ptime, wchar_t > wtime_input_facet; typedef boost::date_time::time_input_facet< ptime, char > time_input_facet; template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const ptime & p); // input operator for ptime template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, ptime & pt); template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::posix_time::time_period & p); // input operator for time_period template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, time_period & tp); // ostream operator for posix_time::time_duration template<typename CharT, typename Traits> std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > & os, const time_duration & td); // input operator for time_duration template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, time_duration & td); } }
namespace boost { namespace posix_time { // ostream operator for posix_time::time_duration template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const time_duration & td); // ostream operator for posix_time::ptime template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const ptime & t); // ostream operator for posix_time::time_period template<typename charT, typename traits> std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > & os, const time_period & tp); template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, time_duration & td); template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > & is, ptime & pt); template<typename charT> std::basic_istream< charT > & operator>>(std::basic_istream< charT > &, time_period &); } }
namespace boost { namespace posix_time { typedef date_time::split_timedate_system< posix_time_system_config, 1000000000 > posix_time_system; typedef date_time::counted_time_rep< millisec_posix_time_system_config > int64_time_rep; } }
namespace boost { namespace posix_time { typedef date_time::time_itr< ptime > time_iterator; // Iterator over a defined time duration. typedef date_time::second_clock< ptime > second_clock; // A time clock that has a resolution of one second. typedef date_time::microsec_clock< ptime > microsec_clock; // A time clock that has a resolution of one microsecond. typedef date_time::null_dst_rules< ptime::date_type, time_duration > no_dst; // Define a dst null dst rule for the posix_time system. typedef date_time::us_dst_rules< ptime::date_type, time_duration > us_dst; // Define US dst rule calculator for the posix_time system. } }
namespace boost { namespace posix_time { class ptime; } }
namespace boost { namespace posix_time { template<typename charT> std::basic_string< charT > to_simple_string_type(time_duration td); template<typename charT> std::basic_string< charT > to_iso_string_type(time_duration td); // Time to simple format CCYY-mmm-dd hh:mm:ss.fffffff. template<typename charT> std::basic_string< charT > to_simple_string_type(ptime t); template<typename charT> std::basic_string< charT > to_simple_string_type(time_period tp); template<typename charT> std::basic_string< charT > to_iso_string_type(ptime t); template<typename charT> std::basic_string< charT > to_iso_extended_string_type(ptime t); // Time duration to wstring -hh::mm::ss.fffffff. Example: 10:09:03.0123456. std::wstring to_simple_wstring(time_duration td); // Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456. std::wstring to_iso_wstring(time_duration td); std::wstring to_simple_wstring(ptime t); // Convert to wstring of form [YYYY-mmm-DD HH:MM::SS.ffffff/YYYY-mmm-DD HH:MM::SS.fffffff]. std::wstring to_simple_wstring(time_period tp); // Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator. std::wstring to_iso_wstring(ptime t); // Convert to form YYYY-MM-DDTHH:MM:SS where T is the date-time separator. std::wstring to_iso_extended_wstring(ptime t); } }
namespace boost { namespace posix_time { // Time duration to string -hh::mm::ss.fffffff. Example: 10:09:03.0123456. std::string to_simple_string(time_duration td); // Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456. std::string to_iso_string(time_duration td); // Time to simple format CCYY-mmm-dd hh:mm:ss.fffffff. std::string to_simple_string(ptime t); // Convert to string of form [YYYY-mmm-DD HH:MM::SS.ffffff/YYYY-mmm-DD HH:MM::SS.fffffff]. std::string to_simple_string(time_period tp); // Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator. std::string to_iso_string(ptime t); // Convert to form YYYY-MM-DDTHH:MM:SS where T is the date-time separator. std::string to_iso_extended_string(ptime t); } }
namespace boost { namespace posix_time { time_duration duration_from_string(const std::string &); ptime time_from_string(const std::string & s); ptime from_iso_string(const std::string & s); ptime from_iso_extended_string(const std::string & s); } }
namespace boost { namespace posix_time { typedef date_time::period< ptime, time_duration > time_period; // Time period type. } }
namespace boost { namespace local_time { // Function that creates a tm struct from a local_date_time. std::tm to_tm(const local_date_time & lt); } }
namespace boost { namespace local_time { template<typename CharT> class custom_time_zone_base; typedef boost::shared_ptr< dst_calc_rule > dst_calc_rule_ptr; typedef custom_time_zone_base< char > custom_time_zone; } }
Operators for local_date_time and optional gregorian types. Operators use snap-to-end-of-month behavior. Further details on this behavior can be found in reference for date_time/date_duration_types.hpp and documentation for month and year iterators.
namespace boost { namespace local_time { local_date_time operator+(const local_date_time &, const boost::gregorian::months &); local_date_time operator+=(local_date_time &, const boost::gregorian::months &); local_date_time operator-(const local_date_time &, const boost::gregorian::months &); local_date_time operator-=(local_date_time &, const boost::gregorian::months &); local_date_time operator+(const local_date_time &, const boost::gregorian::years &); local_date_time operator+=(local_date_time &, const boost::gregorian::years &); local_date_time operator-(const local_date_time &, const boost::gregorian::years &); local_date_time operator-=(local_date_time &, const boost::gregorian::years &); } }
namespace boost { namespace local_time { struct first_last_rule_spec; struct last_last_rule_spec; struct nth_kday_rule_spec; struct nth_last_rule_spec; struct partial_date_rule_spec; typedef date_time::dst_day_calc_rule< gregorian::date > dst_calc_rule; // Provides rule of the form starting Apr 30 ending Oct 21. typedef date_time::day_calc_dst_rule< partial_date_rule_spec > partial_date_dst_rule; // Provides rule of the form first Sunday in April, last Saturday in Oct. typedef date_time::day_calc_dst_rule< first_last_rule_spec > first_last_dst_rule; // Provides rule of the form first Sunday in April, last Saturday in Oct. typedef date_time::day_calc_dst_rule< last_last_rule_spec > last_last_dst_rule; // Provides rule of the form last Sunday in April, last Saturday in Oct. typedef date_time::day_calc_dst_rule< nth_last_rule_spec > nth_last_dst_rule; // Provides rule in form of [1st|2nd|3rd|4th] Sunday in April, last Sunday in Oct. typedef date_time::day_calc_dst_rule< nth_kday_rule_spec > nth_kday_dst_rule; // Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October. typedef date_time::day_calc_dst_rule< nth_kday_rule_spec > nth_day_of_the_week_in_month_dst_rule; // Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October. } }
namespace boost { namespace local_time { struct ambiguous_result; struct dst_not_valid; template<typename utc_time_ = posix_time::ptime, typename tz_type = date_time::time_zone_base<utc_time_,char> > class local_date_time_base; struct time_label_invalid; typedef local_date_time_base local_date_time; // Use the default parameters to define local_date_time. } }
namespace boost { namespace local_time { typedef boost::date_time::time_facet< local_date_time, wchar_t > wlocal_time_facet; typedef boost::date_time::time_facet< local_date_time, char > local_time_facet; typedef boost::date_time::time_input_facet< local_date_time::utc_time_type, wchar_t > wlocal_time_input_facet; typedef boost::date_time::time_input_facet< local_date_time::utc_time_type, char > local_time_input_facet; // operator<< for local_date_time - see local_time docs for formatting details template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const local_date_time & ldt); // input operator for local_date_time template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, local_date_time & ldt); // output operator for local_time_period template<typename CharT, typename TraitsT> std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > & os, const boost::local_time::local_time_period & p); // input operator for local_time_period template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, boost::local_time::local_time_period & tp); } }
namespace boost { namespace local_time { typedef boost::date_time::period< local_date_time, boost::posix_time::time_duration > local_time_period; typedef date_time::time_itr< local_date_time > local_time_iterator; typedef date_time::second_clock< local_date_time > local_sec_clock; typedef date_time::microsec_clock< local_date_time > local_microsec_clock; typedef date_time::time_zone_base< posix_time::ptime, char > time_zone; typedef date_time::time_zone_base< posix_time::ptime, wchar_t > wtime_zone; typedef boost::shared_ptr< time_zone > time_zone_ptr; // Shared Pointer for custom_time_zone and posix_time_zone objects. typedef boost::shared_ptr< wtime_zone > wtime_zone_ptr; typedef date_time::time_zone_names_base< char > time_zone_names; typedef date_time::time_zone_names_base< wchar_t > wtime_zone_names; } }
namespace boost { namespace local_time { struct bad_adjustment; struct bad_offset; template<typename CharT> class posix_time_zone_base; typedef boost::date_time::dst_adjustment_offsets< boost::posix_time::time_duration > dst_adjustment_offsets; typedef posix_time_zone_base< char > posix_time_zone; } }
namespace boost { namespace local_time { typedef date_time::tz_db_base< custom_time_zone, nth_kday_dst_rule > tz_database; } }