Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Library Reference

Date Time Reference
Gregorian Reference
Posix Time Reference

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.

Date Time Reference

Header <boost/date_time/adjust_functors.hpp>
Header <boost/date_time/c_local_time_adjustor.hpp>
Header <boost/date_time/c_time.hpp>
Header <boost/date_time/compiler_config.hpp>
Header <boost/date_time/constrained_value.hpp>
Header <boost/date_time/date.hpp>
Header <boost/date_time/date_clock_device.hpp>
Header <boost/date_time/date_defs.hpp>
Header <boost/date_time/date_duration.hpp>
Header <boost/date_time/date_duration_types.hpp>
Header <boost/date_time/date_format_simple.hpp>
Header <boost/date_time/date_formatting.hpp>
Header <boost/date_time/date_formatting_limited.hpp>
Header <boost/date_time/date_formatting_locales.hpp>
Header <boost/date_time/date_generators.hpp>
Header <boost/date_time/date_iterator.hpp>
Header <boost/date_time/date_names_put.hpp>
Header <boost/date_time/dst_rules.hpp>
Header <boost/date_time/dst_transition_generators.hpp>
Header <boost/date_time/filetime_functions.hpp>
Header <boost/date_time/gregorian_calendar.hpp>
Header <boost/date_time/int_adapter.hpp>
Header <boost/date_time/iso_format.hpp>
Header <boost/date_time/local_time_adjustor.hpp>
Header <boost/date_time/local_timezone_defs.hpp>
Header <boost/date_time/microsec_time_clock.hpp>
Header <boost/date_time/parse_format_base.hpp>
Header <boost/date_time/period.hpp>
Header <boost/date_time/special_defs.hpp>
Header <boost/date_time/time.hpp>
Header <boost/date_time/time_clock.hpp>
Header <boost/date_time/time_defs.hpp>
Header <boost/date_time/time_duration.hpp>
Header <boost/date_time/time_formatting_streams.hpp>
Header <boost/date_time/time_iterator.hpp>
Header <boost/date_time/time_parsing.hpp>
Header <boost/date_time/time_resolution_traits.hpp>
Header <boost/date_time/time_system_counted.hpp>
Header <boost/date_time/time_system_split.hpp>
Header <boost/date_time/wrapping_int.hpp>
Header <boost/date_time/year_month_day.hpp>
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 std {
}
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_long;
struct duration_traits_adapted;
}
}
namespace boost {
namespace date_time {
template<typename duration_config> class weeks_duration;
template<typename base_config> class months_duration;
template<typename base_config> class years_duration;
}
}
namespace boost {
namespace date_time {
template<typename charT> class simple_format;

template<> class simple_format<wchar_t>;
}
}
namespace boost {
namespace date_time {
template<typename month_type, typename format_type, typename charT = char> 
  class month_formatter;
template<typename ymd_type, typename format_type, typename charT = char> 
  class ymd_formatter;
template<typename date_type, typename format_type, typename charT = char> 
  class date_formatter;
}
}
namespace boost {
namespace date_time {
}
}
namespace boost {
namespace date_time {
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;
template<typename date_type, typename facet_type, typename charT = char> 
  class ostream_date_formatter;
}
}

Definition and implementation of date algorithm templates

namespace boost {
namespace date_time {
template<typename date_type> class year_based_generator;
template<typename date_type> class partial_date;
template<typename date_type> class nth_kday_of_month;
template<typename date_type> class first_kday_of_month;
template<typename date_type> class last_kday_of_month;
template<typename date_type> class first_kday_after;
template<typename date_type> class first_kday_before;

// 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 date_type> class date_itr_base;
template<typename offset_functor, typename date_type> class date_itr;

// 

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 date_names_put;
template<typename Config, typename charT = char, 
typename OutputIterator = std::ostreambuf_iterator<charT> > 
  class all_date_names_put;
}
}

Contains template class to provide static dst rule calculations

namespace boost {
namespace date_time {
template<typename date_type_, typename time_duration_type_> 
  class dst_calculator;
template<typename date_type, typename time_duration_type, 
typename dst_traits> 
  class dst_calc_engine;
template<typename date_type_, typename time_duration_type_, 
unsigned int dst_start_offset_minutes = , 
short dst_length_minutes = > 
  class us_dst_rules;
template<typename date_type_, typename time_duration_type_> 
  class null_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 date_type> class dst_day_calc_rule;
template<typename spec> class day_calc_dst_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 time_type> time_type time_from_ftime(const FILETIME &);
}
}
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_format_base;

template<> class iso_format_base<wchar_t>;

template<typename charT> class iso_format;
template<typename charT> class iso_extended_format;
}
}

Time adjustment calculations for local times

namespace boost {
namespace date_time {
template<typename time_duration_type, short hours, 
unsigned short minutes = > 
  class utc_adjustment;
template<typename time_type, typename dst_rules> 
  class dynamic_local_time_adjustor;
template<typename time_type, typename dst_rules, 
typename utc_offset_rules> 
  class static_local_time_adjustor;
template<typename time_type, short utc_offset, typename dst_rule> 
  class local_adjustor;
void dummy_to_prevent_msvc6_ice();
}
}
namespace boost {
namespace date_time {
template<typename date_type> struct us_dst_trait;
template<typename date_type> struct eu_dst_trait;
template<typename date_type> struct uk_dst_trait;
template<typename date_type> struct acst_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 {

enum special_values { not_a_date_time, neg_infin, pos_infin, 
min_date_time, max_date_time, not_special, 
NumSpecialValues };
}
}

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 date_type, 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, 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 T, typename rep_type> class time_duration;
template<typename base_duration, long frac_of_second> 
  class subsecond_duration;
}
}
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 {
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 (eg: 120259 is 12 hours 2 min 59 seconds). 
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 {
struct time_resolution_traits_bi32_impl;
struct time_resolution_traits_adapted32_impl;
struct time_resolution_traits_bi64_impl;
struct time_resolution_traits_adapted64_impl;

template<typename frac_sec_type, time_resolutions res, 
#if(defined(BOOST_MSVC)&&(_MSC_VER<=1200)) boost::int64_t resolution_adjust, 
#else typename frac_sec_type::int_type resolution_adjust, 
#endif unsigned short frac_digits, 
typename v_type = boost::int32_t> 
  class time_resolution_traits;

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 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;
}
}

Gregorian Reference

namespace boost {
namespace gregorian {
template<typename charT> 
std::basic_string< charT > to_simple_string_type(const date & d);

// To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01. 
std::string to_simple_string(const date & d);
template<typename charT> 
std::basic_string< charT > to_simple_string_type(const date_period & d);

// Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]. 
std::string to_simple_string(const date_period & d);
template<typename charT> 
std::basic_string< charT > to_iso_string_type(const date_period & d);

// Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231. 
std::string to_iso_string(const date_period & d);
template<typename charT> 
std::basic_string< charT > to_iso_extended_string_type(const date & d);

// Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31. 
std::string to_iso_extended_string(const date & d);
template<typename charT> 
std::basic_string< charT > to_iso_string_type(const date & d);

// Convert to iso standard string YYYYMMDD. Example: 20021231. 
std::string to_iso_string(const date & d);
template<typename charT> 
std::basic_string< charT > to_sql_string_type(const date & d);
std::string to_sql_string(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 {
}
}
namespace boost {
namespace gregorian {
class gregorian_calendar;

typedef date_time::int_adapter< unsigned long > 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 {
typedef boost::date_time::duration_traits_adapted date_duration_rep;  // An internal date representation that includes infinities, not a date. 
typedef date_time::date_duration< date_duration_rep > date_duration;  // Durations in days for gregorian system. 
typedef date_duration days;  // Shorthand for date_duration. 
}
}
namespace boost {
namespace gregorian {
struct greg_durations_config;

typedef date_time::months_duration< greg_durations_config > months;
typedef date_time::years_duration< greg_durations_config > years;
typedef date_time::weeks_duration< date_time::duration_traits_adapted > 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, 10000, 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.

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;  // A unifying date_generator base type. 
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 {

// 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);
}
}

Posix Time Reference

namespace boost {
namespace posix_time {

// Function that converts a time_t into a ptime. 
ptime from_time_t(std::time_t t);
template<typename time_type> time_type from_ftime(const FILETIME &);
}
}

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 time_duration;

struct simple_time_rep;

class posix_time_system_config;
class millisec_posix_time_system_config;

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 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::date_type, 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);
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 {

// 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);

// 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);
}
}
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);
}
}
namespace boost {
namespace posix_time {
typedef date_time::period< ptime, time_duration > time_period;  // Time period type. 
}
}
Copyright 2001-2004 CrystalClear Software, Inc

PrevUpHomeNext