Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
#ifndef _GREGORIAN__CONVERSION_HPP___
#define _GREGORIAN__CONVERSION_HPP___
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2010-06-09 14:10:13 -0400 (Wed, 09 Jun 2010) $
*/
#include <cstring>
#include <string>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/c_time.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
namespace boost {
namespace gregorian {
//! Converts a date to a tm struct. Throws out_of_range exception if date is a special value
inline
std::tm to_tm(const date& d)
{
if (d.is_special())
{
std::string s = "tm unable to handle ";
switch (d.as_special())
{
case date_time::not_a_date_time:
s += "not-a-date-time value"; break;
case date_time::neg_infin:
s += "-infinity date value"; break;
case date_time::pos_infin:
s += "+infinity date value"; break;
default:
s += "a special date value"; break;
}
boost::throw_exception(std::out_of_range(s));
}
std::tm datetm;
std::memset(&datetm, 0, sizeof(datetm));
boost::gregorian::date::ymd_type ymd = d.year_month_day();
datetm.tm_year = ymd.year - 1900;
datetm.tm_mon = ymd.month - 1;
datetm.tm_mday = ymd.day;
datetm.tm_wday = d.day_of_week();
datetm.tm_yday = d.day_of_year() - 1;
datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst
return datetm;
}
//! Converts a tm structure into a date dropping the any time values.
inline
date date_from_tm(const std::tm& datetm)
{
return date(static_cast<unsigned short>(datetm.tm_year+1900),
static_cast<unsigned short>(datetm.tm_mon+1),
static_cast<unsigned short>(datetm.tm_mday));
}
} } //namespace boost::gregorian
#endif

View File

@@ -0,0 +1,162 @@
#ifndef GREGORIAN_FORMATTERS_HPP___
#define GREGORIAN_FORMATTERS_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/gregorian/gregorian_types.hpp"
#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
#include "boost/date_time/date_formatting_limited.hpp"
#else
#include "boost/date_time/date_formatting.hpp"
#endif
#include "boost/date_time/iso_format.hpp"
#include "boost/date_time/date_format_simple.hpp"
/* NOTE: "to_*_string" code for older compilers, ones that define
* BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS, is located in
* formatters_limited.hpp
*/
namespace boost {
namespace gregorian {
// wrapper function for to_simple_(w)string(date)
template<class charT>
inline
std::basic_string<charT> to_simple_string_type(const date& d) {
return date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d);
}
//! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
/*!\ingroup date_format
*/
inline std::string to_simple_string(const date& d) {
return to_simple_string_type<char>(d);
}
// wrapper function for to_simple_(w)string(date_period)
template<class charT>
inline std::basic_string<charT> to_simple_string_type(const date_period& d) {
typedef std::basic_string<charT> string_type;
charT b = '[', m = '/', e=']';
string_type d1(date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d.begin()));
string_type d2(date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d.last()));
return string_type(b + d1 + m + d2 + e);
}
//! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
/*!\ingroup date_format
*/
inline std::string to_simple_string(const date_period& d) {
return to_simple_string_type<char>(d);
}
// wrapper function for to_iso_(w)string(date_period)
template<class charT>
inline std::basic_string<charT> to_iso_string_type(const date_period& d) {
charT sep = '/';
std::basic_string<charT> s(date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d.begin()));
return s + sep + date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d.last());
}
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
return to_iso_string_type<char>(d);
}
// wrapper function for to_iso_extended_(w)string(date)
template<class charT>
inline std::basic_string<charT> to_iso_extended_string_type(const date& d) {
return date_time::date_formatter<date,date_time::iso_extended_format<charT>,charT>::date_to_string(d);
}
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::string to_iso_extended_string(const date& d) {
return to_iso_extended_string_type<char>(d);
}
// wrapper function for to_iso_(w)string(date)
template<class charT>
inline std::basic_string<charT> to_iso_string_type(const date& d) {
return date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d);
}
//! Convert to iso standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
return to_iso_string_type<char>(d);
}
// wrapper function for to_sql_(w)string(date)
template<class charT>
inline std::basic_string<charT> to_sql_string_type(const date& d)
{
date::ymd_type ymd = d.year_month_day();
std::basic_ostringstream<charT> ss;
ss << ymd.year << "-"
<< std::setw(2) << std::setfill(ss.widen('0'))
<< ymd.month.as_number() //solves problem with gcc 3.1 hanging
<< "-"
<< std::setw(2) << std::setfill(ss.widen('0'))
<< ymd.day;
return ss.str();
}
inline std::string to_sql_string(const date& d) {
return to_sql_string_type<char>(d);
}
#if !defined(BOOST_NO_STD_WSTRING)
//! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
/*!\ingroup date_format
*/
inline std::wstring to_simple_wstring(const date_period& d) {
return to_simple_string_type<wchar_t>(d);
}
//! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
/*!\ingroup date_format
*/
inline std::wstring to_simple_wstring(const date& d) {
return to_simple_string_type<wchar_t>(d);
}
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::wstring to_iso_wstring(const date_period& d) {
return to_iso_string_type<wchar_t>(d);
}
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::wstring to_iso_extended_wstring(const date& d) {
return to_iso_extended_string_type<wchar_t>(d);
}
//! Convert to iso standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::wstring to_iso_wstring(const date& d) {
return to_iso_string_type<wchar_t>(d);
}
inline std::wstring to_sql_wstring(const date& d) {
return to_sql_string_type<wchar_t>(d);
}
#endif // BOOST_NO_STD_WSTRING
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,81 @@
#ifndef GREGORIAN_FORMATTERS_LIMITED_HPP___
#define GREGORIAN_FORMATTERS_LIMITED_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/date_formatting_limited.hpp"
#include "boost/date_time/iso_format.hpp"
#include "boost/date_time/date_format_simple.hpp"
#include "boost/date_time/compiler_config.hpp"
namespace boost {
namespace gregorian {
//! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
/*!\ingroup date_format
*/
inline std::string to_simple_string(const date& d) {
return date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d);
}
//! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
/*!\ingroup date_format
*/
inline std::string to_simple_string(const date_period& d) {
std::string s("[");
std::string d1(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.begin()));
std::string d2(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.last()));
return std::string("[" + d1 + "/" + d2 + "]");
}
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
std::string s(date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.begin()));
return s + "/" + date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.last());
}
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::string to_iso_extended_string(const date& d) {
return date_time::date_formatter<date,date_time::iso_extended_format<char> >::date_to_string(d);
}
//! Convert to iso standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
return date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d);
}
inline std::string to_sql_string(const date& d)
{
date::ymd_type ymd = d.year_month_day();
std::ostringstream ss;
ss << ymd.year << "-"
<< std::setw(2) << std::setfill('0')
<< ymd.month.as_number() //solves problem with gcc 3.1 hanging
<< "-"
<< std::setw(2) << std::setfill('0')
<< ymd.day;
return ss.str();
}
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,48 @@
#ifndef GREGORIAN_GREGORIAN_CALENDAR_HPP__
#define GREGORIAN_GREGORIAN_CALENDAR_HPP__
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2010-01-10 14:17:23 -0500 (Sun, 10 Jan 2010) $
*/
#include <boost/cstdint.hpp>
#include <boost/date_time/gregorian/greg_weekday.hpp>
#include <boost/date_time/gregorian/greg_day_of_year.hpp>
#include <boost/date_time/gregorian_calendar.hpp>
#include <boost/date_time/gregorian/greg_ymd.hpp>
#include <boost/date_time/int_adapter.hpp>
namespace boost {
namespace gregorian {
//!An internal date representation that includes infinities, not a date
typedef date_time::int_adapter<uint32_t> fancy_date_rep;
//! Gregorian calendar for this implementation, hard work in the base
class gregorian_calendar :
public date_time::gregorian_calendar_base<greg_year_month_day, fancy_date_rep::int_type> {
public:
//! Type to hold a weekday (eg: Sunday, Monday,...)
typedef greg_weekday day_of_week_type;
//! Counter type from 1 to 366 for gregorian dates.
typedef greg_day_of_year_rep day_of_year_type;
//! Internal date representation that handles infinity, not a date
typedef fancy_date_rep date_rep_type;
//! Date rep implements the traits stuff as well
typedef fancy_date_rep date_traits_type;
private:
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,136 @@
#ifndef GREG_DATE_HPP___
#define GREG_DATE_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2010-01-10 14:17:23 -0500 (Sun, 10 Jan 2010) $
*/
#include <boost/throw_exception.hpp>
#include <boost/date_time/date.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/gregorian/greg_calendar.hpp>
#include <boost/date_time/gregorian/greg_duration.hpp>
namespace boost {
namespace gregorian {
//bring special enum values into the namespace
using date_time::special_values;
using date_time::not_special;
using date_time::neg_infin;
using date_time::pos_infin;
using date_time::not_a_date_time;
using date_time::max_date_time;
using date_time::min_date_time;
//! A date type based on gregorian_calendar
/*! 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.
\ingroup date_basics
*/
class date : public date_time::date<date, gregorian_calendar, date_duration>
{
public:
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;
#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
//! Default constructor constructs with not_a_date_time
date():
date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(not_a_date_time))
{}
#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
//! Main constructor with year, month, day
date(year_type y, month_type m, day_type d)
: date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
{
if (gregorian_calendar::end_of_month_day(y, m) < d) {
boost::throw_exception(bad_day_of_month(std::string("Day of month is not valid for year")));
}
}
//! Constructor from a ymd_type structure
explicit date(const ymd_type& ymd)
: date_time::date<date, gregorian_calendar, date_duration>(ymd)
{}
//! Needed copy constructor
explicit date(const date_int_type& rhs):
date_time::date<date,gregorian_calendar, date_duration>(rhs)
{}
//! Needed copy constructor
explicit date(date_rep_type rhs):
date_time::date<date,gregorian_calendar, date_duration>(rhs)
{}
//! Constructor for infinities, not a date, max and min date
explicit date(special_values sv):
date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(sv))
{
if (sv == min_date_time)
{
*this = date(1400, 1, 1);
}
if (sv == max_date_time)
{
*this = date(9999, 12, 31);
}
}
//!Return the Julian Day number for the date.
date_int_type julian_day() const
{
ymd_type ymd = year_month_day();
return gregorian_calendar::julian_day_number(ymd);
}
//!Return the day of year 1..365 or 1..366 (for leap year)
day_of_year_type day_of_year() const
{
date start_of_year(year(), 1, 1);
unsigned short doy = static_cast<unsigned short>((*this-start_of_year).days() + 1);
return day_of_year_type(doy);
}
//!Return the Modified Julian Day number for the date.
date_int_type modjulian_day() const
{
ymd_type ymd = year_month_day();
return gregorian_calendar::modjulian_day_number(ymd);
}
//!Return the iso 8601 week number 1..53
int week_number() const
{
ymd_type ymd = year_month_day();
return gregorian_calendar::week_number(ymd);
}
//! Return the day number from the calendar
date_int_type day_number() const
{
return days_;
}
//! Return the last day of the current month
date end_of_month() const
{
ymd_type ymd = year_month_day();
short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
return date(ymd.year, ymd.month, eom_day);
}
private:
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,57 @@
#ifndef GREG_DAY_HPP___
#define GREG_DAY_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
namespace boost {
namespace gregorian {
//! Exception type for gregorian day of month (1..31)
struct bad_day_of_month : public std::out_of_range
{
bad_day_of_month() :
std::out_of_range(std::string("Day of month value is out of range 1..31"))
{}
//! Allow other classes to throw with unique string for bad day like Feb 29
bad_day_of_month(const std::string& s) :
std::out_of_range(s)
{}
};
//! Policy class that declares error handling and day of month ranges
typedef CV::simple_exception_policy<unsigned short, 1, 31, bad_day_of_month> greg_day_policies;
//! Generated represetation for gregorian day of month
typedef CV::constrained_value<greg_day_policies> greg_day_rep;
//! Represent a day of the month (range 1 - 31)
/*! This small class allows for simple conversion an integer value into
a day of the month for a standard gregorian calendar. The type
is automatically range checked so values outside of the range 1-31
will cause a bad_day_of_month exception
*/
class greg_day : public greg_day_rep {
public:
greg_day(unsigned short day_of_month) : greg_day_rep(day_of_month) {}
unsigned short as_number() const {return value_;}
operator unsigned short() const {return value_;}
private:
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,38 @@
#ifndef GREG_DAY_OF_YEAR_HPP___
#define GREG_DAY_OF_YEAR_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
namespace boost {
namespace gregorian {
//! Exception type for day of year (1..366)
struct bad_day_of_year : public std::out_of_range
{
bad_day_of_year() :
std::out_of_range(std::string("Day of year value is out of range 1..366"))
{}
};
//! A day of the year range (1..366)
typedef CV::simple_exception_policy<unsigned short,1,366,bad_day_of_year> greg_day_of_year_policies;
//! Define a range representation type for the day of the year 1..366
typedef CV::constrained_value<greg_day_of_year_policies> greg_day_of_year_rep;
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,134 @@
#ifndef GREG_DURATION_HPP___
#define GREG_DURATION_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $
*/
#include <boost/date_time/date_duration.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace gregorian {
//!An internal date representation that includes infinities, not a date
typedef boost::date_time::duration_traits_adapted date_duration_rep;
//! Durations in days for gregorian system
/*! \ingroup date_basics
*/
class date_duration :
public boost::date_time::date_duration< date_duration_rep >
{
typedef boost::date_time::date_duration< date_duration_rep > base_type;
public:
typedef base_type::duration_rep duration_rep;
//! Construct from a day count
explicit date_duration(duration_rep day_count = 0) : base_type(day_count) {}
//! construct from special_values
date_duration(date_time::special_values sv) : base_type(sv) {}
//! Copy constructor
date_duration(const date_duration& other) : base_type(static_cast< base_type const& >(other))
{}
//! Construct from another date_duration
date_duration(const base_type& other) : base_type(other)
{}
// Relational operators
// NOTE: Because of date_time::date_duration< T > design choice we don't use Boost.Operators here,
// because we need the class to be a direct base. Either lose EBO, or define operators by hand.
// The latter is more effecient.
bool operator== (const date_duration& rhs) const
{
return base_type::operator== (rhs);
}
bool operator!= (const date_duration& rhs) const
{
return !operator== (rhs);
}
bool operator< (const date_duration& rhs) const
{
return base_type::operator< (rhs);
}
bool operator> (const date_duration& rhs) const
{
return !(base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator<= (const date_duration& rhs) const
{
return (base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator>= (const date_duration& rhs) const
{
return !base_type::operator< (rhs);
}
//! Subtract another duration -- result is signed
date_duration& operator-= (const date_duration& rhs)
{
base_type::operator-= (rhs);
return *this;
}
friend date_duration operator- (date_duration rhs, date_duration const& lhs)
{
rhs -= lhs;
return rhs;
}
//! Add a duration -- result is signed
date_duration& operator+= (const date_duration& rhs)
{
base_type::operator+= (rhs);
return *this;
}
friend date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
rhs += lhs;
return rhs;
}
//! unary- Allows for dd = -date_duration(2); -> dd == -2
date_duration operator- ()const
{
return date_duration(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
date_duration& operator/= (int divisor)
{
base_type::operator/= (divisor);
return *this;
}
friend date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
//! Returns the smallest duration -- used by to calculate 'end'
static date_duration unit()
{
return date_duration(base_type::unit().get_rep());
}
};
//! Shorthand for date_duration
typedef date_duration days;
} } //namespace gregorian
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include <boost/date_time/date_duration_types.hpp>
#endif
#endif

View File

@@ -0,0 +1,43 @@
#ifndef GREG_DURATION_TYPES_HPP___
#define GREG_DURATION_TYPES_HPP___
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Subject to Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $
*/
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/adjust_functors.hpp>
#include <boost/date_time/date_duration_types.hpp>
#include <boost/date_time/gregorian/greg_duration.hpp>
namespace boost {
namespace gregorian {
//! config struct for additional duration types (ie months_duration<> & years_duration<>)
struct greg_durations_config {
typedef date date_type;
typedef date_time::int_adapter<int> int_rep;
typedef date_time::month_functor<date_type> month_adjustor_type;
};
typedef date_time::months_duration<greg_durations_config> months;
typedef date_time::years_duration<greg_durations_config> years;
class weeks_duration : public date_duration {
public:
weeks_duration(duration_rep w)
: date_duration(w * 7) {}
weeks_duration(date_time::special_values sv)
: date_duration(sv) {}
};
typedef weeks_duration weeks;
}} // namespace boost::gregorian
#endif // GREG_DURATION_TYPES_HPP___

View File

@@ -0,0 +1,354 @@
#ifndef GREGORIAN_FACET_HPP___
#define GREGORIAN_FACET_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-11-23 06:13:35 -0500 (Sun, 23 Nov 2008) $
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/date_formatting_locales.hpp" // sets BOOST_DATE_TIME_NO_LOCALE
#include "boost/date_time/gregorian/parsers.hpp"
//This file is basically commented out if locales are not supported
#ifndef BOOST_DATE_TIME_NO_LOCALE
#include <string>
#include <memory>
#include <locale>
#include <iostream>
#include <exception>
namespace boost {
namespace gregorian {
//! Configuration of the output facet template
struct greg_facet_config
{
typedef boost::gregorian::greg_month month_type;
typedef boost::date_time::special_values special_value_enum;
typedef boost::gregorian::months_of_year month_enum;
typedef boost::date_time::weekdays weekday_enum;
};
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
//! Create the base facet type for gregorian::date
typedef boost::date_time::date_names_put<greg_facet_config> greg_base_facet;
//! ostream operator for gregorian::date
/*! Uses the date facet to determine various output parameters including:
* - string values for the month (eg: Jan, Feb, Mar) (default: English)
* - string values for special values (eg: not-a-date-time) (default: English)
* - selection of long, short strings, or numerical month representation (default: short string)
* - month day year order (default yyyy-mmm-dd)
*/
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const date& d)
{
typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
typedef boost::date_time::ostream_date_formatter<date, facet_def, charT> greg_ostream_formatter;
greg_ostream_formatter::date_put(d, os);
return os;
}
//! operator<< for gregorian::greg_month typically streaming: Jan, Feb, Mar...
/*! Uses the date facet to determine output string as well as selection of long or short strings.
* Default if no facet is installed is to output a 2 wide numeric value for the month
* eg: 01 == Jan, 02 == Feb, ... 12 == Dec.
*/
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const greg_month& m)
{
typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
typedef boost::date_time::ostream_month_formatter<facet_def, charT> greg_month_formatter;
std::locale locale = os.getloc();
if (std::has_facet<facet_def>(locale)) {
const facet_def& f = std::use_facet<facet_def>(locale);
greg_month_formatter::format_month(m, os, f);
}
else { //default to numeric
charT fill_char = '0';
os << std::setw(2) << std::setfill(fill_char) << m.as_number();
}
return os;
}
//! operator<< for gregorian::greg_weekday typically streaming: Sun, Mon, Tue, ...
/*! Uses the date facet to determine output string as well as selection of long or short string.
* Default if no facet is installed is to output a 3 char english string for the
* day of the week.
*/
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const greg_weekday& wd)
{
typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
typedef boost::date_time::ostream_weekday_formatter<greg_weekday, facet_def, charT> greg_weekday_formatter;
std::locale locale = os.getloc();
if (std::has_facet<facet_def>(locale)) {
const facet_def& f = std::use_facet<facet_def>(locale);
greg_weekday_formatter::format_weekday(wd.as_enum(), os, f, true);
}
else { //default to short English string eg: Sun, Mon, Tue, Wed...
os << wd.as_short_string();
}
return os;
}
//! operator<< for gregorian::date_period typical output: [2002-Jan-01/2002-Jan-31]
/*! Uses the date facet to determine output string as well as selection of long
* or short string fr dates.
* Default if no facet is installed is to output a 3 char english string for the
* day of the week.
*/
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const date_period& dp)
{
os << '['; //TODO: facet or manipulator for periods?
os << dp.begin();
os << '/'; //TODO: facet or manipulator for periods?
os << dp.last();
os << ']';
return os;
}
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const date_duration& dd)
{
//os << dd.days();
os << dd.get_rep();
return os;
}
//! operator<< for gregorian::partial_date. Output: "Jan 1"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const partial_date& pd)
{
os << std::setw(2) << std::setfill('0') << pd.day() << ' '
<< pd.month().as_short_string() ;
return os;
}
//! operator<< for gregorian::nth_kday_of_month. Output: "first Mon of Jun"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const nth_kday_of_month& nkd)
{
os << nkd.nth_week_as_str() << ' '
<< nkd.day_of_week() << " of "
<< nkd.month().as_short_string() ;
return os;
}
//! operator<< for gregorian::first_kday_of_month. Output: "first Mon of Jun"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const first_kday_of_month& fkd)
{
os << "first " << fkd.day_of_week() << " of "
<< fkd.month().as_short_string() ;
return os;
}
//! operator<< for gregorian::last_kday_of_month. Output: "last Mon of Jun"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const last_kday_of_month& lkd)
{
os << "last " << lkd.day_of_week() << " of "
<< lkd.month().as_short_string() ;
return os;
}
//! operator<< for gregorian::first_kday_after. Output: "first Mon after"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const first_kday_after& fka)
{
os << fka.day_of_week() << " after";
return os;
}
//! operator<< for gregorian::first_kday_before. Output: "first Mon before"
template <class charT, class traits>
inline
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const first_kday_before& fkb)
{
os << fkb.day_of_week() << " before";
return os;
}
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
/**************** Input Streaming ******************/
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
//! operator>> for gregorian::date
template<class charT>
inline
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, date& d)
{
std::istream_iterator<std::basic_string<charT>, charT> beg(is), eos;
typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
d = from_stream(beg, eos);
return is;
}
#endif // BOOST_NO_STD_ITERATOR_TRAITS
//! operator>> for gregorian::date_duration
template<class charT>
inline
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,
date_duration& dd)
{
long v;
is >> v;
dd = date_duration(v);
return is;
}
//! operator>> for gregorian::date_period
template<class charT>
inline
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,
date_period& dp)
{
std::basic_string<charT> s;
is >> s;
dp = date_time::from_simple_string_type<date>(s);
return is;
}
//! 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)
/* Necessary in the event an exception is thrown from op>> for
* weekday or month. See comments in those functions for more info */
BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put<greg_facet_config, char>* create_facet_def(char type);
#ifndef BOOST_NO_STD_WSTRING
//! 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)
/* Necessary in the event an exception is thrown from op>> for
* weekday or month. See comments in those functions for more info */
BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put<greg_facet_config, wchar_t>* create_facet_def(wchar_t type);
#endif // BOOST_NO_STD_WSTRING
//! operator>> for gregorian::greg_month - throws exception if invalid month given
template<class charT>
inline
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,greg_month& m)
{
typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
std::basic_string<charT> s;
is >> s;
if(!std::has_facet<facet_def>(is.getloc())) {
std::locale loc = is.getloc();
charT a = '\0';
is.imbue(generate_locale(loc, a));
}
short num = 0;
try{
const facet_def& f = std::use_facet<facet_def>(is.getloc());
num = date_time::find_match(f.get_short_month_names(),
f.get_long_month_names(),
(greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size,
// which is needed by find_match
}
/* bad_cast will be thrown if the desired facet is not accessible
* so we can generate the facet. This has the drawback of using english
* names as a default. */
catch(std::bad_cast&){
charT a = '\0';
std::auto_ptr< const facet_def > f(create_facet_def(a));
num = date_time::find_match(f->get_short_month_names(),
f->get_long_month_names(),
(greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size,
// which is needed by find_match
}
++num; // months numbered 1-12
m = greg_month(num);
return is;
}
//! operator>> for gregorian::greg_weekday - throws exception if invalid weekday given
template<class charT>
inline
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,greg_weekday& wd)
{
typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
std::basic_string<charT> s;
is >> s;
if(!std::has_facet<facet_def>(is.getloc())) {
std::locale loc = is.getloc();
charT a = '\0';
is.imbue(generate_locale(loc, a));
}
short num = 0;
try{
const facet_def& f = std::use_facet<facet_def>(is.getloc());
num = date_time::find_match(f.get_short_weekday_names(),
f.get_long_weekday_names(),
(greg_weekday::max)() + 1, s); // greg_weekday spans 0..6, so increment is needed
// to form the array size which is needed by find_match
}
/* bad_cast will be thrown if the desired facet is not accessible
* so we can generate the facet. This has the drawback of using english
* names as a default. */
catch(std::bad_cast&){
charT a = '\0';
std::auto_ptr< const facet_def > f(create_facet_def(a));
num = date_time::find_match(f->get_short_weekday_names(),
f->get_long_weekday_names(),
(greg_weekday::max)() + 1, s); // greg_weekday spans 0..6, so increment is needed
// to form the array size which is needed by find_match
}
wd = greg_weekday(num); // weekdays numbered 0-6
return is;
}
} } //namespace gregorian
#endif
#endif

View File

@@ -0,0 +1,105 @@
#ifndef GREG_MONTH_HPP___
#define GREG_MONTH_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
#include "boost/date_time/date_defs.hpp"
#include "boost/shared_ptr.hpp"
#include "boost/date_time/compiler_config.hpp"
#include <stdexcept>
#include <string>
#include <map>
#include <algorithm>
#include <cctype>
namespace boost {
namespace gregorian {
typedef date_time::months_of_year months_of_year;
//bring enum values into the namespace
using date_time::Jan;
using date_time::Feb;
using date_time::Mar;
using date_time::Apr;
using date_time::May;
using date_time::Jun;
using date_time::Jul;
using date_time::Aug;
using date_time::Sep;
using date_time::Oct;
using date_time::Nov;
using date_time::Dec;
using date_time::NotAMonth;
using date_time::NumMonths;
//! Exception thrown if a greg_month is constructed with a value out of range
struct bad_month : public std::out_of_range
{
bad_month() : std::out_of_range(std::string("Month number is out of range 1..12")) {}
};
//! Build a policy class for the greg_month_rep
typedef CV::simple_exception_policy<unsigned short, 1, 12, bad_month> greg_month_policies;
//! A constrained range that implements the gregorian_month rules
typedef CV::constrained_value<greg_month_policies> greg_month_rep;
//! Wrapper class to represent months in gregorian based calendar
class BOOST_DATE_TIME_DECL greg_month : public greg_month_rep {
public:
typedef date_time::months_of_year month_enum;
typedef std::map<std::string, unsigned short> month_map_type;
typedef boost::shared_ptr<month_map_type> month_map_ptr_type;
//! Construct a month from the months_of_year enumeration
greg_month(month_enum theMonth) :
greg_month_rep(static_cast<greg_month_rep::value_type>(theMonth)) {}
//! Construct from a short value
greg_month(unsigned short theMonth) : greg_month_rep(theMonth) {}
//! Convert the value back to a short
operator unsigned short() const {return value_;}
//! Returns month as number from 1 to 12
unsigned short as_number() const {return value_;}
month_enum as_enum() const {return static_cast<month_enum>(value_);}
const char* as_short_string() const;
const char* as_long_string() const;
#ifndef BOOST_NO_STD_WSTRING
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
#endif // BOOST_NO_STD_WSTRING
//! Shared pointer to a map of Month strings (Names & Abbrev) & numbers
static month_map_ptr_type get_month_map_ptr();
/* parameterized as_*_string functions are intended to be called
* from a template function: "... as_short_string(charT c='\0');" */
const char* as_short_string(char) const
{
return as_short_string();
}
const char* as_long_string(char) const
{
return as_long_string();
}
#ifndef BOOST_NO_STD_WSTRING
const wchar_t* as_short_string(wchar_t) const
{
return as_short_wstring();
}
const wchar_t* as_long_string(wchar_t) const
{
return as_long_wstring();
}
#endif // BOOST_NO_STD_WSTRING
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,490 @@
#ifndef GREGORIAN_SERIALIZE_HPP___
#define GREGORIAN_SERIALIZE_HPP___
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2010-11-11 15:19:38 -0500 (Thu, 11 Nov 2010) $
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/parsers.hpp"
#include "boost/serialization/split_free.hpp"
#include "boost/serialization/nvp.hpp"
// macros to split serialize functions into save & load functions
// An expanded version is below for gregorian::date
// NOTE: these macros define template functions in the boost::serialization namespace.
// They must be expanded *outside* of any namespace
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_period)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_day)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_weekday)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::partial_date)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_before)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_after)
namespace boost {
namespace serialization {
/*! Method that does serialization for gregorian::date -- splits to load/save
*/
template<class Archive>
inline void serialize(Archive & ar,
::boost::gregorian::date & d,
const unsigned int file_version)
{
split_free(ar, d, file_version);
}
//! Function to save gregorian::date objects using serialization lib
/*! Dates are serialized into a string for transport and storage.
* While it would be more efficient to store the internal
* integer used to manipulate the dates, it is an unstable solution.
*/
template<class Archive>
void save(Archive & ar,
const ::boost::gregorian::date & d,
unsigned int /* version */)
{
std::string ds = to_iso_string(d);
ar & make_nvp("date", ds);
}
//! Function to load gregorian::date objects using serialization lib
/*! Dates are serialized into a string for transport and storage.
* While it would be more efficient to store the internal
* integer used to manipulate the dates, it is an unstable solution.
*/
template<class Archive>
void load(Archive & ar,
::boost::gregorian::date & d,
unsigned int /*version*/)
{
std::string ds;
ar & make_nvp("date", ds);
try{
d = ::boost::gregorian::from_undelimited_string(ds);
}catch(bad_lexical_cast&) {
gregorian::special_values sv = gregorian::special_value_from_string(ds);
if(sv == gregorian::not_special) {
throw; // no match found, rethrow original exception
}
else {
d = gregorian::date(sv);
}
}
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
::boost::gregorian::date* dp,
const unsigned int /*file_version*/)
{
// retrieve data from archive required to construct new
// invoke inplace constructor to initialize instance of date
::new(dp) ::boost::gregorian::date(::boost::gregorian::not_a_date_time);
}
/**** date_duration ****/
//! Function to save gregorian::date_duration objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::date_duration & dd,
unsigned int /*version*/)
{
typename gregorian::date_duration::duration_rep dr = dd.get_rep();
ar & make_nvp("date_duration", dr);
}
//! Function to load gregorian::date_duration objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
{
typename gregorian::date_duration::duration_rep dr(0);
ar & make_nvp("date_duration", dr);
dd = gregorian::date_duration(dr);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::date_duration* dd,
const unsigned int /*file_version*/)
{
::new(dd) gregorian::date_duration(gregorian::not_a_date_time);
}
/**** date_duration::duration_rep (most likely int_adapter) ****/
//! helper unction to save date_duration objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::date_duration::duration_rep & dr,
unsigned int /*version*/)
{
typename gregorian::date_duration::duration_rep::int_type it = dr.as_number();
ar & make_nvp("date_duration_duration_rep", it);
}
//! helper function to load date_duration objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int /*version*/)
{
typename gregorian::date_duration::duration_rep::int_type it(0);
ar & make_nvp("date_duration_duration_rep", it);
dr = gregorian::date_duration::duration_rep::int_type(it);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::date_duration::duration_rep* dr,
const unsigned int /*file_version*/)
{
::new(dr) gregorian::date_duration::duration_rep(0);
}
/**** date_period ****/
//! Function to save gregorian::date_period objects using serialization lib
/*! date_period objects are broken down into 2 parts for serialization:
* the begining date object and the end date object
*/
template<class Archive>
void save(Archive & ar, const gregorian::date_period& dp,
unsigned int /*version*/)
{
gregorian::date d1 = dp.begin();
gregorian::date d2 = dp.end();
ar & make_nvp("date_period_begin_date", d1);
ar & make_nvp("date_period_end_date", d2);
}
//! Function to load gregorian::date_period objects using serialization lib
/*! date_period objects are broken down into 2 parts for serialization:
* the begining date object and the end date object
*/
template<class Archive>
void load(Archive & ar, gregorian::date_period& dp, unsigned int /*version*/)
{
gregorian::date d1(gregorian::not_a_date_time);
gregorian::date d2(gregorian::not_a_date_time);
ar & make_nvp("date_period_begin_date", d1);
ar & make_nvp("date_period_end_date", d2);
dp = gregorian::date_period(d1,d2);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::date_period* dp,
const unsigned int /*file_version*/)
{
gregorian::date d(gregorian::not_a_date_time);
gregorian::date_duration dd(1);
::new(dp) gregorian::date_period(d,dd);
}
/**** greg_month ****/
//! Function to save gregorian::greg_month objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_month& gm,
unsigned int /*version*/)
{
unsigned short us = gm.as_number();
ar & make_nvp("greg_month", us);
}
//! Function to load gregorian::greg_month objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
{
unsigned short us;
ar & make_nvp("greg_month", us);
gm = gregorian::greg_month(us);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::greg_month* gm,
const unsigned int /*file_version*/)
{
::new(gm) gregorian::greg_month(1);
}
/**** greg_day ****/
//! Function to save gregorian::greg_day objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_day& gd,
unsigned int /*version*/)
{
unsigned short us = gd.as_number();
ar & make_nvp("greg_day", us);
}
//! Function to load gregorian::greg_day objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
{
unsigned short us;
ar & make_nvp("greg_day", us);
gd = gregorian::greg_day(us);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::greg_day* gd,
const unsigned int /*file_version*/)
{
::new(gd) gregorian::greg_day(1);
}
/**** greg_weekday ****/
//! Function to save gregorian::greg_weekday objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_weekday& gd,
unsigned int /*version*/)
{
unsigned short us = gd.as_number();
ar & make_nvp("greg_weekday", us);
}
//! Function to load gregorian::greg_weekday objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
{
unsigned short us;
ar & make_nvp("greg_weekday", us);
gd = gregorian::greg_weekday(us);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::greg_weekday* gd,
const unsigned int /*file_version*/)
{
::new(gd) gregorian::greg_weekday(1);
}
/**** date_generators ****/
/**** partial_date ****/
//! Function to save gregorian::partial_date objects using serialization lib
/*! partial_date objects are broken down into 2 parts for serialization:
* the day (typically greg_day) and month (typically greg_month) objects
*/
template<class Archive>
void save(Archive & ar, const gregorian::partial_date& pd,
unsigned int /*version*/)
{
gregorian::greg_day gd(pd.day());
gregorian::greg_month gm(pd.month().as_number());
ar & make_nvp("partial_date_day", gd);
ar & make_nvp("partial_date_month", gm);
}
//! Function to load gregorian::partial_date objects using serialization lib
/*! partial_date objects are broken down into 2 parts for serialization:
* the day (greg_day) and month (greg_month) objects
*/
template<class Archive>
void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
{
gregorian::greg_day gd(1);
gregorian::greg_month gm(1);
ar & make_nvp("partial_date_day", gd);
ar & make_nvp("partial_date_month", gm);
pd = gregorian::partial_date(gd,gm);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar, gregorian::partial_date* pd,
const unsigned int /*file_version*/)
{
gregorian::greg_month gm(1);
gregorian::greg_day gd(1);
::new(pd) gregorian::partial_date(gd,gm);
}
/**** nth_kday_of_month ****/
//! Function to save nth_day_of_the_week_in_month objects using serialization lib
/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
* serialization: the week number, the day of the week, and the month
*/
template<class Archive>
void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
unsigned int /*version*/)
{
typename gregorian::nth_kday_of_month::week_num wn(nkd.nth_week());
typename gregorian::nth_kday_of_month::day_of_week_type d(nkd.day_of_week().as_number());
typename gregorian::nth_kday_of_month::month_type m(nkd.month().as_number());
ar & make_nvp("nth_kday_of_month_week_num", wn);
ar & make_nvp("nth_kday_of_month_day_of_week", d);
ar & make_nvp("nth_kday_of_month_month", m);
}
//! Function to load nth_day_of_the_week_in_month objects using serialization lib
/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
* serialization: the week number, the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*version*/)
{
typename gregorian::nth_kday_of_month::week_num wn(gregorian::nth_kday_of_month::first);
typename gregorian::nth_kday_of_month::day_of_week_type d(gregorian::Monday);
typename gregorian::nth_kday_of_month::month_type m(gregorian::Jan);
ar & make_nvp("nth_kday_of_month_week_num", wn);
ar & make_nvp("nth_kday_of_month_day_of_week", d);
ar & make_nvp("nth_kday_of_month_month", m);
nkd = gregorian::nth_kday_of_month(wn,d,m);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
gregorian::nth_kday_of_month* nkd,
const unsigned int /*file_version*/)
{
// values used are not significant
::new(nkd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
gregorian::Monday,gregorian::Jan);
}
/**** first_kday_of_month ****/
//! Function to save first_day_of_the_week_in_month objects using serialization lib
/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
* serialization: the day of the week, and the month
*/
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
unsigned int /*version*/)
{
typename gregorian::first_kday_of_month::day_of_week_type d(fkd.day_of_week().as_number());
typename gregorian::first_kday_of_month::month_type m(fkd.month().as_number());
ar & make_nvp("first_kday_of_month_day_of_week", d);
ar & make_nvp("first_kday_of_month_month", m);
}
//! Function to load first_day_of_the_week_in_month objects using serialization lib
/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
* serialization: the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*version*/)
{
typename gregorian::first_kday_of_month::day_of_week_type d(gregorian::Monday);
typename gregorian::first_kday_of_month::month_type m(gregorian::Jan);
ar & make_nvp("first_kday_of_month_day_of_week", d);
ar & make_nvp("first_kday_of_month_month", m);
fkd = gregorian::first_kday_of_month(d,m);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
gregorian::first_kday_of_month* fkd,
const unsigned int /*file_version*/)
{
// values used are not significant
::new(fkd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
}
/**** last_kday_of_month ****/
//! Function to save last_day_of_the_week_in_month objects using serialization lib
/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
* serialization: the day of the week, and the month
*/
template<class Archive>
void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
unsigned int /*version*/)
{
typename gregorian::last_kday_of_month::day_of_week_type d(lkd.day_of_week().as_number());
typename gregorian::last_kday_of_month::month_type m(lkd.month().as_number());
ar & make_nvp("last_kday_of_month_day_of_week", d);
ar & make_nvp("last_kday_of_month_month", m);
}
//! Function to load last_day_of_the_week_in_month objects using serialization lib
/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
* serialization: the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*version*/)
{
typename gregorian::last_kday_of_month::day_of_week_type d(gregorian::Monday);
typename gregorian::last_kday_of_month::month_type m(gregorian::Jan);
ar & make_nvp("last_kday_of_month_day_of_week", d);
ar & make_nvp("last_kday_of_month_month", m);
lkd = gregorian::last_kday_of_month(d,m);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
gregorian::last_kday_of_month* lkd,
const unsigned int /*file_version*/)
{
// values used are not significant
::new(lkd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
}
/**** first_kday_before ****/
//! Function to save first_day_of_the_week_before objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_before& fkdb,
unsigned int /*version*/)
{
typename gregorian::first_kday_before::day_of_week_type d(fkdb.day_of_week().as_number());
ar & make_nvp("first_kday_before_day_of_week", d);
}
//! Function to load first_day_of_the_week_before objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*version*/)
{
typename gregorian::first_kday_before::day_of_week_type d(gregorian::Monday);
ar & make_nvp("first_kday_before_day_of_week", d);
fkdb = gregorian::first_kday_before(d);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
gregorian::first_kday_before* fkdb,
const unsigned int /*file_version*/)
{
// values used are not significant
::new(fkdb) gregorian::first_kday_before(gregorian::Monday);
}
/**** first_kday_after ****/
//! Function to save first_day_of_the_week_after objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_after& fkda,
unsigned int /*version*/)
{
typename gregorian::first_kday_after::day_of_week_type d(fkda.day_of_week().as_number());
ar & make_nvp("first_kday_after_day_of_week", d);
}
//! Function to load first_day_of_the_week_after objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*version*/)
{
typename gregorian::first_kday_after::day_of_week_type d(gregorian::Monday);
ar & make_nvp("first_kday_after_day_of_week", d);
fkda = gregorian::first_kday_after(d);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & ar,
gregorian::first_kday_after* fkda,
const unsigned int /*file_version*/)
{
// values used are not significant
::new(fkda) gregorian::first_kday_after(gregorian::Monday);
}
} // namespace serialization
} // namespace boost
#endif

View File

@@ -0,0 +1,66 @@
#ifndef GREG_WEEKDAY_HPP___
#define GREG_WEEKDAY_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
#include "boost/date_time/date_defs.hpp"
#include "boost/date_time/compiler_config.hpp"
#include <stdexcept>
#include <string>
namespace boost {
namespace gregorian {
//bring enum values into the namespace
using date_time::Sunday;
using date_time::Monday;
using date_time::Tuesday;
using date_time::Wednesday;
using date_time::Thursday;
using date_time::Friday;
using date_time::Saturday;
//! Exception that flags that a weekday number is incorrect
struct bad_weekday : public std::out_of_range
{
bad_weekday() : std::out_of_range(std::string("Weekday is out of range 0..6")) {}
};
typedef CV::simple_exception_policy<unsigned short, 0, 6, bad_weekday> greg_weekday_policies;
typedef CV::constrained_value<greg_weekday_policies> greg_weekday_rep;
//! Represent a day within a week (range 0==Sun to 6==Sat)
class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
public:
typedef boost::date_time::weekdays weekday_enum;
greg_weekday(unsigned short day_of_week_num) :
greg_weekday_rep(day_of_week_num)
{}
unsigned short as_number() const {return value_;}
const char* as_short_string() const;
const char* as_long_string() const;
#ifndef BOOST_NO_STD_WSTRING
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
#endif // BOOST_NO_STD_WSTRING
weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,53 @@
#ifndef GREG_YEAR_HPP___
#define GREG_YEAR_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
namespace boost {
namespace gregorian {
//! Exception type for gregorian year
struct bad_year : public std::out_of_range
{
bad_year() :
std::out_of_range(std::string("Year is out of valid range: 1400..10000"))
{}
};
//! Policy class that declares error handling gregorian year type
typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies;
//! Generated representation for gregorian year
typedef CV::constrained_value<greg_year_policies> greg_year_rep;
//! Represent a day of the month (range 1900 - 10000)
/*! This small class allows for simple conversion an integer value into
a year for the gregorian calendar. This currently only allows a
range of 1900 to 10000. Both ends of the range are a bit arbitrary
at the moment, but they are the limits of current testing of the
library. As such they may be increased in the future.
*/
class greg_year : public greg_year_rep {
public:
greg_year(unsigned short year) : greg_year_rep(year) {}
operator unsigned short() const {return value_;}
private:
};
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,33 @@
#ifndef DATE_TIME_GREG_YMD_HPP__
#define DATE_TIME_GREG_YMD_HPP__
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/year_month_day.hpp"
#include "boost/date_time/special_defs.hpp"
#include "boost/date_time/gregorian/greg_day.hpp"
#include "boost/date_time/gregorian/greg_year.hpp"
#include "boost/date_time/gregorian/greg_month.hpp"
namespace boost {
namespace gregorian {
typedef date_time::year_month_day_base<greg_year,
greg_month,
greg_day> greg_year_month_day;
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,38 @@
#ifndef GREGORIAN_HPP__
#define GREGORIAN_HPP__
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
/*! @file gregorian.hpp
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.
*/
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/conversion.hpp"
#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
#include "boost/date_time/gregorian/formatters_limited.hpp"
#else
#include "boost/date_time/gregorian/formatters.hpp"
#endif
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
#include "boost/date_time/gregorian/greg_facet.hpp"
#else
#include "boost/date_time/gregorian/gregorian_io.hpp"
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
#include "boost/date_time/gregorian/parsers.hpp"
#endif

View File

@@ -0,0 +1,784 @@
#ifndef DATE_TIME_GREGORIAN_IO_HPP__
#define DATE_TIME_GREGORIAN_IO_HPP__
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $
*/
#include <locale>
#include <iostream>
#include <iterator> // i/ostreambuf_iterator
#include <boost/io/ios_state.hpp>
#include <boost/date_time/date_facet.hpp>
#include <boost/date_time/period_parser.hpp>
#include <boost/date_time/period_formatter.hpp>
#include <boost/date_time/special_values_parser.hpp>
#include <boost/date_time/special_values_formatter.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/gregorian/conversion.hpp> // to_tm will be needed in the facets
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 <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date& d) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), d);
else {
//instantiate a custom facet for dealing with dates since the user
//has not put one in the stream so far. This is for efficiency
//since we would always need to reconstruct for every date
//if the locale did not already exist. Of course this will be overridden
//if the user imbues at some later point. With the default settings
//for the facet the resulting format will be the same as the
//std::time_facet settings.
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), d);
}
return os;
}
//! input operator for date
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date& d)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, d);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, d);
}
}
catch(...) {
// mask tells us what exceptions are turned on
std::ios_base::iostate exception_mask = is.exceptions();
// if the user wants exceptions on failbit, we'll rethrow our
// date_time exception & set the failbit
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {} // ignore this one
throw; // rethrow original exception
}
else {
// if the user want's to fail quietly, we simply set the failbit
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_duration& dd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), dd);
}
return os;
}
//! input operator for date_duration
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date_duration& dd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_period& dp) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dp);
else {
//instantiate a custom facet for dealing with date periods since the user
//has not put one in the stream so far. This is for efficiency
//since we would always need to reconstruct for every time period
//if the local did not already exist. Of course this will be overridden
//if the user imbues at some later point. With the default settings
//for the facet the resulting format will be the same as the
//std::time_facet settings.
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), dp);
}
return os;
}
//! input operator for date_period
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date_period& dp)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dp);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dp);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
/********** small gregorian types **********/
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_month& gm) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gm);
else {
custom_date_facet* f = new custom_date_facet();//-> 10/1074199752/32 because year & day not initialized in put(...)
//custom_date_facet* f = new custom_date_facet("%B");
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), gm);
}
return os;
}
//! input operator for greg_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_month& m)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, m);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, m);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_weekday& gw) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gw);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), gw);
}
return os;
}
//! input operator for greg_weekday
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_weekday& wd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, wd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, wd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
//NOTE: output operator for greg_day was not necessary
//! input operator for greg_day
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_day& gd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
//NOTE: output operator for greg_year was not necessary
//! input operator for greg_year
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_year& gy)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gy);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gy);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
/********** date generator types **********/
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::partial_date& pd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), pd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), pd);
}
return os;
}
//! input operator for partial_date
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, partial_date& pd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, pd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::nth_day_of_the_week_in_month& nkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), nkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), nkd);
}
return os;
}
//! input operator for nth_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
nth_day_of_the_week_in_month& nday)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, nday);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, nday);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_in_month& fkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fkd);
}
return os;
}
//! input operator for first_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_in_month& fkd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::last_day_of_the_week_in_month& lkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), lkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), lkd);
}
return os;
}
//! input operator for last_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
last_day_of_the_week_in_month& lkd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, lkd);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, lkd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_after& fda) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc())) {
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fda);
}
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fda);
}
return os;
}
//! input operator for first_day_of_the_week_after
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_after& fka)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fka);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fka);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_before& fdb) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc())) {
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fdb);
}
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fdb);
}
return os;
}
//! input operator for first_day_of_the_week_before
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_before& fkb)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkb);
}
else {
date_input_facet* f = new date_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkb);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
} } // namespaces
#endif // DATE_TIME_GREGORIAN_IO_HPP__

View File

@@ -0,0 +1,109 @@
#ifndef _GREGORIAN_TYPES_HPP__
#define _GREGORIAN_TYPES_HPP__
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
/*! @file gregorian_types.hpp
Single file header that defines most of the types for the gregorian
date-time system.
*/
#include "boost/date_time/date.hpp"
#include "boost/date_time/period.hpp"
#include "boost/date_time/gregorian/greg_calendar.hpp"
#include "boost/date_time/gregorian/greg_duration.hpp"
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include "boost/date_time/gregorian/greg_duration_types.hpp"
#endif
#include "boost/date_time/gregorian/greg_date.hpp"
#include "boost/date_time/date_generators.hpp"
#include "boost/date_time/date_clock_device.hpp"
#include "boost/date_time/date_iterator.hpp"
#include "boost/date_time/adjust_functors.hpp"
namespace boost {
//! Gregorian date system based on date_time components
/*! This date system defines a full complement of types including
* a date, date_duration, date_period, day_clock, and a
* day_iterator.
*/
namespace gregorian {
//! Date periods for the gregorian system
/*!\ingroup date_basics
*/
typedef date_time::period<date, date_duration> date_period;
//! A unifying date_generator base type
/*! A unifying date_generator base type for:
* partial_date, nth_day_of_the_week_in_month,
* first_day_of_the_week_in_month, and last_day_of_the_week_in_month
*/
typedef date_time::year_based_generator<date> year_based_generator;
//! A date generation object type
typedef date_time::partial_date<date> partial_date;
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;
//! A clock to get the current day from the local computer
/*!\ingroup date_basics
*/
typedef date_time::day_clock<date> day_clock;
//! Base date_iterator type for gregorian types.
/*!\ingroup date_basics
*/
typedef date_time::date_itr_base<date> date_iterator;
//! A day level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::day_functor<date>,
date> day_iterator;
//! A week level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::week_functor<date>,
date> week_iterator;
//! A month level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::month_functor<date>,
date> month_iterator;
//! A year level iterator
/*!\ingroup date_basics
*/
typedef date_time::date_itr<date_time::year_functor<date>,
date> year_iterator;
// bring in these date_generator functions from date_time namespace
using date_time::days_until_weekday;
using date_time::days_before_weekday;
using date_time::next_weekday;
using date_time::previous_weekday;
} } //namespace gregorian
#endif

View File

@@ -0,0 +1,91 @@
#ifndef GREGORIAN_PARSERS_HPP___
#define GREGORIAN_PARSERS_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/date_parsing.hpp"
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/parse_format_base.hpp"
#include <string>
#include <sstream>
namespace boost {
namespace gregorian {
//! Return special_value from string argument
/*! Return special_value from string argument. If argument is
* not one of the special value names (defined in src/gregorian/names.hpp),
* return 'not_special' */
BOOST_DATE_TIME_DECL special_values special_value_from_string(const std::string& s);
//! Deprecated: Use from_simple_string
inline date from_string(std::string s) {
return date_time::parse_date<date>(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)
inline date from_simple_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_iso);
}
//! From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted)
inline date from_us_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_us);
}
//! From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted)
inline date from_uk_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
}
//! From iso type date string where with order year-month-day eg: 20020125
inline date from_undelimited_string(std::string s) {
return date_time::parse_undelimited_date<date>(s);
}
//! From iso type date string where with order year-month-day eg: 20020125
inline date date_from_iso_string(const std::string& s) {
return date_time::parse_undelimited_date<date>(s);
}
#if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
//! Stream should hold a date in the form of: 2002-1-25. Month number, abbrev, or name are accepted
/* Arguments passed in by-value for convertability of char[]
* to iterator_type. Calls to from_stream_type are by-reference
* since conversion is already done */
template<class iterator_type>
inline date from_stream(iterator_type beg, iterator_type end) {
if(beg == end)
{
return date(not_a_date_time);
}
typedef typename std::iterator_traits<iterator_type>::value_type value_type;
return date_time::from_stream_type<date>(beg, end, value_type());
}
#endif //BOOST_NO_STD_ITERATOR_TRAITS
#if (defined(_MSC_VER) && (_MSC_VER < 1300))
// This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
#else
//! Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25])
inline date_period date_period_from_string(const std::string& s){
return date_time::from_simple_string_type<date,char>(s);
}
# if !defined(BOOST_NO_STD_WSTRING)
//! Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25])
inline date_period date_period_from_wstring(const std::wstring& s){
return date_time::from_simple_string_type<date,wchar_t>(s);
}
# endif // BOOST_NO_STD_WSTRING
#endif
} } //namespace gregorian
#endif