update boost on linux
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define _DATE_TIME_ADJUST_FUNCTORS_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* 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
|
||||
@@ -14,26 +14,21 @@
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
|
||||
//! Functor to iterate a fixed number of days
|
||||
template<class date_type>
|
||||
class day_functor
|
||||
class day_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
day_functor(int f) : f_(f) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type&) const
|
||||
{
|
||||
// why is 'd' a parameter???
|
||||
// fix compiler warnings
|
||||
d.year();
|
||||
return duration_type(f_);
|
||||
}
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
duration_type get_neg_offset(const date_type&) const
|
||||
{
|
||||
// fix compiler warnings
|
||||
d.year();
|
||||
return duration_type(-f_);
|
||||
}
|
||||
private:
|
||||
@@ -43,7 +38,7 @@ namespace date_time {
|
||||
|
||||
//! Provides calculation to find next nth month given a date
|
||||
/*! This adjustment function provides the logic for 'month-based'
|
||||
* advancement on a ymd based calendar. The policy it uses
|
||||
* advancement on a ymd based calendar. The policy it uses
|
||||
* to handle the non existant end of month days is to back
|
||||
* up to the last day of the month. Also, if the starting
|
||||
* date is the last day of a month, this functor will attempt
|
||||
@@ -51,7 +46,7 @@ namespace date_time {
|
||||
|
||||
*/
|
||||
template<class date_type>
|
||||
class month_functor
|
||||
class month_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
@@ -60,7 +55,7 @@ namespace date_time {
|
||||
typedef typename cal_type::day_type day_type;
|
||||
|
||||
month_functor(int f) : f_(f), origDayOfMonth_(0) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
ymd_type ymd(d.year_month_day());
|
||||
if (origDayOfMonth_ == 0) {
|
||||
@@ -71,11 +66,9 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
|
||||
typedef typename wrap_int2::int_type int_type;
|
||||
wrap_int2 wi(ymd.month);
|
||||
//calc the year wrap around, add() returns 0 or 1 if wrapped
|
||||
int_type year = wi.add(static_cast<int_type>(f_));
|
||||
year = static_cast<int_type>(year + ymd.year); //calculate resulting year
|
||||
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.add(f_)));
|
||||
// std::cout << "trace wi: " << wi.as_int() << std::endl;
|
||||
// std::cout << "trace year: " << year << std::endl;
|
||||
//find the last day for the new month
|
||||
@@ -91,7 +84,7 @@ namespace date_time {
|
||||
return date_type(year, wi.as_int(), dayOfMonth) - d;
|
||||
}
|
||||
//! Returns a negative duration_type
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
ymd_type ymd(d.year_month_day());
|
||||
if (origDayOfMonth_ == 0) {
|
||||
@@ -102,11 +95,9 @@ namespace date_time {
|
||||
}
|
||||
}
|
||||
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
|
||||
typedef typename wrap_int2::int_type int_type;
|
||||
wrap_int2 wi(ymd.month);
|
||||
//calc the year wrap around, add() returns 0 or 1 if wrapped
|
||||
int_type year = wi.subtract(static_cast<int_type>(f_));
|
||||
year = static_cast<int_type>(year + ymd.year); //calculate resulting year
|
||||
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.subtract(f_)));
|
||||
//find the last day for the new month
|
||||
day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
|
||||
//original was the end of month -- force to last day of month
|
||||
@@ -127,24 +118,19 @@ namespace date_time {
|
||||
|
||||
//! Functor to iterate a over weeks
|
||||
template<class date_type>
|
||||
class week_functor
|
||||
class week_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
week_functor(int f) : f_(f) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type&) const
|
||||
{
|
||||
// why is 'd' a parameter???
|
||||
// fix compiler warnings
|
||||
d.year();
|
||||
return duration_type(f_*calendar_type::days_in_week());
|
||||
return duration_type(f_*static_cast<int>(calendar_type::days_in_week()));
|
||||
}
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
duration_type get_neg_offset(const date_type&) const
|
||||
{
|
||||
// fix compiler warnings
|
||||
d.year();
|
||||
return duration_type(-f_*calendar_type::days_in_week());
|
||||
return duration_type(-f_*static_cast<int>(calendar_type::days_in_week()));
|
||||
}
|
||||
private:
|
||||
int f_;
|
||||
@@ -152,17 +138,17 @@ namespace date_time {
|
||||
|
||||
//! Functor to iterate by a year adjusting for leap years
|
||||
template<class date_type>
|
||||
class year_functor
|
||||
class year_functor
|
||||
{
|
||||
public:
|
||||
//typedef typename date_type::year_type year_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
year_functor(int f) : _mf(f * 12) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
return _mf.get_offset(d);
|
||||
}
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
return _mf.get_neg_offset(d);
|
||||
}
|
||||
@@ -170,7 +156,7 @@ namespace date_time {
|
||||
month_functor<date_type> _mf;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} }//namespace date_time
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/c_time.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -42,12 +43,14 @@ namespace date_time {
|
||||
}
|
||||
date_duration_type dd = t.date() - time_t_start_day;
|
||||
time_duration_type td = t.time_of_day();
|
||||
std::time_t t2 = static_cast<std::time_t>(dd.days())*86400 +
|
||||
static_cast<std::time_t>(td.hours())*3600 +
|
||||
static_cast<std::time_t>(td.minutes())*60 +
|
||||
td.seconds();
|
||||
uint64_t t2 = static_cast<uint64_t>(dd.days())*86400 +
|
||||
static_cast<uint64_t>(td.hours())*3600 +
|
||||
static_cast<uint64_t>(td.minutes())*60 +
|
||||
td.seconds();
|
||||
// detect y2038 issue and throw instead of proceed with bad time
|
||||
std::time_t tv = boost::numeric_cast<std::time_t>(t2);
|
||||
std::tm tms, *tms_ptr;
|
||||
tms_ptr = c_time::localtime(&t2, &tms);
|
||||
tms_ptr = c_time::localtime(&tv, &tms);
|
||||
date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900),
|
||||
static_cast<unsigned short>(tms_ptr->tm_mon + 1),
|
||||
static_cast<unsigned short>(tms_ptr->tm_mday));
|
||||
|
||||
@@ -165,5 +165,10 @@ namespace std {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NULLPTR)
|
||||
# define BOOST_DATE_TIME_NULLPTR 0
|
||||
#else
|
||||
# define BOOST_DATE_TIME_NULLPTR nullptr
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace date_time {
|
||||
{
|
||||
return days_;
|
||||
}
|
||||
special_values as_special() const
|
||||
{
|
||||
return days_.as_special();
|
||||
}
|
||||
bool is_special()const
|
||||
{
|
||||
return days_.is_special();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "boost/date_time/iso_format.hpp"
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include <boost/io/ios_state.hpp>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -51,6 +52,7 @@ namespace date_time {
|
||||
}
|
||||
case month_as_integer:
|
||||
{
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "boost/date_time/iso_format.hpp"
|
||||
#include "boost/date_time/date_names_put.hpp"
|
||||
#include "boost/date_time/parse_format_base.hpp"
|
||||
#include <boost/io/ios_state.hpp>
|
||||
//#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -56,8 +57,8 @@ namespace date_time {
|
||||
}
|
||||
case month_as_integer:
|
||||
{
|
||||
charT fill_char = '0';
|
||||
os << std::setw(2) << std::setfill(fill_char) << month.as_number();
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -132,8 +133,8 @@ namespace date_time {
|
||||
ostream_type& os,
|
||||
const facet_type& f)
|
||||
{
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
std::ostreambuf_iterator<charT> oitr(os);
|
||||
charT fill_char = '0';
|
||||
switch (f.date_order()) {
|
||||
case ymd_order_iso: {
|
||||
os << ymd.year;
|
||||
@@ -144,7 +145,7 @@ namespace date_time {
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
}
|
||||
os << std::setw(2) << std::setfill(fill_char)
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
break;
|
||||
}
|
||||
@@ -153,7 +154,7 @@ namespace date_time {
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
}
|
||||
os << std::setw(2) << std::setfill(fill_char)
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.month_sep_char(oitr);
|
||||
@@ -162,7 +163,7 @@ namespace date_time {
|
||||
break;
|
||||
}
|
||||
case ymd_order_dmy: {
|
||||
os << std::setw(2) << std::setfill(fill_char)
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace date_time {
|
||||
//! Base class for all generators that take a year and produce a date.
|
||||
/*! This class is a base class for polymorphic function objects that take
|
||||
a year and produce a concrete date.
|
||||
@param date_type The type representing a date. This type must
|
||||
@tparam date_type The type representing a date. This type must
|
||||
export a calender_type which defines a year_type.
|
||||
*/
|
||||
template<class date_type>
|
||||
@@ -307,7 +307,7 @@ namespace date_time {
|
||||
/*! Useful generator functor for finding holidays and daylight savings
|
||||
* Get the last day of the month and then calculate the difference
|
||||
* to the last previous day.
|
||||
* @param date_type A date class that exports day_of_week, month_type, etc.
|
||||
* @tparam date_type A date class that exports day_of_week, month_type, etc.
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace boost {
|
||||
* @param dst_start_offset Time offset within day for dst boundary
|
||||
* @param dst_end_day Ending day of dst for the given locality
|
||||
* @param dst_end_offset Time offset within day given in dst for dst boundary
|
||||
* @param dst_length lenght of dst adjusment
|
||||
* @param dst_length_minutes length of dst adjusment
|
||||
* @retval The time is either ambiguous, invalid, in dst, or not in dst
|
||||
*/
|
||||
static time_is_dst_result
|
||||
@@ -104,14 +104,14 @@ namespace boost {
|
||||
const time_duration_type& dst_start_offset,
|
||||
const date_type& dst_end_day,
|
||||
const time_duration_type& dst_end_offset,
|
||||
const time_duration_type& dst_length_minutes)
|
||||
const time_duration_type& dst_length)
|
||||
{
|
||||
unsigned int start_minutes =
|
||||
dst_start_offset.hours() * 60 + dst_start_offset.minutes();
|
||||
unsigned int end_minutes =
|
||||
dst_end_offset.hours() * 60 + dst_end_offset.minutes();
|
||||
long length_minutes =
|
||||
dst_length_minutes.hours() * 60 + dst_length_minutes.minutes();
|
||||
unsigned int start_minutes = static_cast<unsigned>(
|
||||
dst_start_offset.hours() * 60 + dst_start_offset.minutes());
|
||||
unsigned int end_minutes = static_cast<unsigned>(
|
||||
dst_end_offset.hours() * 60 + dst_end_offset.minutes());
|
||||
long length_minutes = static_cast<long>(
|
||||
dst_length.hours() * 60 + dst_length.minutes());
|
||||
|
||||
return local_is_dst(current_day, time_of_day,
|
||||
dst_start_day, start_minutes,
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace date_time {
|
||||
//! Canonical form for a class that provides day rule calculation
|
||||
/*! This class is used to generate specific sets of dst rules
|
||||
*
|
||||
*@param spec Provides a specifiction of the function object types used
|
||||
*@tparam spec Provides a specifiction of the function object types used
|
||||
* to generate start and end days of daylight savings as well
|
||||
* as the date type.
|
||||
*/
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
|
||||
#if defined(BOOST_HAS_FTIME) // skip this file if no FILETIME
|
||||
|
||||
#if defined(BOOST_USE_WINDOWS_H)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/time.hpp>
|
||||
#include <boost/date_time/date_defs.hpp>
|
||||
@@ -31,85 +27,6 @@ namespace boost {
|
||||
|
||||
namespace date_time {
|
||||
|
||||
namespace winapi {
|
||||
|
||||
#if !defined(BOOST_USE_WINDOWS_H)
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct FILETIME
|
||||
{
|
||||
boost::uint32_t dwLowDateTime;
|
||||
boost::uint32_t dwHighDateTime;
|
||||
};
|
||||
struct SYSTEMTIME
|
||||
{
|
||||
boost::uint16_t wYear;
|
||||
boost::uint16_t wMonth;
|
||||
boost::uint16_t wDayOfWeek;
|
||||
boost::uint16_t wDay;
|
||||
boost::uint16_t wHour;
|
||||
boost::uint16_t wMinute;
|
||||
boost::uint16_t wSecond;
|
||||
boost::uint16_t wMilliseconds;
|
||||
};
|
||||
|
||||
__declspec(dllimport) void __stdcall GetSystemTimeAsFileTime(FILETIME* lpFileTime);
|
||||
__declspec(dllimport) int __stdcall FileTimeToLocalFileTime(const FILETIME* lpFileTime, FILETIME* lpLocalFileTime);
|
||||
__declspec(dllimport) void __stdcall GetSystemTime(SYSTEMTIME* lpSystemTime);
|
||||
__declspec(dllimport) int __stdcall SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, FILETIME* lpFileTime);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // defined(BOOST_USE_WINDOWS_H)
|
||||
|
||||
typedef FILETIME file_time;
|
||||
typedef SYSTEMTIME system_time;
|
||||
|
||||
inline void get_system_time_as_file_time(file_time& ft)
|
||||
{
|
||||
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
|
||||
// Some runtime library implementations expect local times as the norm for ctime.
|
||||
file_time ft_utc;
|
||||
GetSystemTimeAsFileTime(&ft_utc);
|
||||
FileTimeToLocalFileTime(&ft_utc, &ft);
|
||||
#elif defined(BOOST_HAS_GETSYSTEMTIMEASFILETIME)
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
#else
|
||||
system_time st;
|
||||
GetSystemTime(&st);
|
||||
SystemTimeToFileTime(&st, &ft);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* The function converts file_time into number of microseconds elapsed since 1970-Jan-01
|
||||
*
|
||||
* \note Only dates after 1970-Jan-01 are supported. Dates before will be wrapped.
|
||||
*
|
||||
* \note The function is templated on the FILETIME type, so that
|
||||
* it can be used with both native FILETIME and the ad-hoc
|
||||
* boost::date_time::winapi::file_time type.
|
||||
*/
|
||||
template< typename FileTimeT >
|
||||
inline boost::uint64_t file_time_to_microseconds(FileTimeT const& ft)
|
||||
{
|
||||
/* shift is difference between 1970-Jan-01 & 1601-Jan-01
|
||||
* in 100-nanosecond intervals */
|
||||
const uint64_t shift = 116444736000000000ULL; // (27111902 << 32) + 3577643008
|
||||
|
||||
union {
|
||||
FileTimeT as_file_time;
|
||||
uint64_t as_integer; // 100-nanos since 1601-Jan-01
|
||||
} caster;
|
||||
caster.as_file_time = ft;
|
||||
|
||||
caster.as_integer -= shift; // filetime is now 100-nanos since 1970-Jan-01
|
||||
return (caster.as_integer / 10); // truncate to microseconds
|
||||
}
|
||||
|
||||
} // namespace winapi
|
||||
|
||||
//! Create a time object from an initialized FILETIME struct.
|
||||
/*!
|
||||
* Create a time object from an initialized FILETIME struct.
|
||||
@@ -119,7 +36,7 @@ namespace winapi {
|
||||
*
|
||||
* \note The function is templated on the FILETIME type, so that
|
||||
* it can be used with both native FILETIME and the ad-hoc
|
||||
* boost::date_time::winapi::file_time type.
|
||||
* boost::detail::winapi::FILETIME_ type.
|
||||
*/
|
||||
template< typename TimeT, typename FileTimeT >
|
||||
inline
|
||||
@@ -132,20 +49,17 @@ TimeT time_from_ftime(const FileTimeT& ft)
|
||||
// https://svn.boost.org/trac/boost/ticket/2523
|
||||
// Since this function can be called with arbitrary times, including ones that
|
||||
// are before 1970-Jan-01, we'll have to cast the time a bit differently,
|
||||
// than it is done in the file_time_to_microseconds function. This allows to
|
||||
// than it is done in the microsec_clock::file_time_to_microseconds function. This allows to
|
||||
// avoid integer wrapping for dates before 1970-Jan-01.
|
||||
union {
|
||||
FileTimeT as_file_time;
|
||||
uint64_t as_integer; // 100-nanos since 1601-Jan-01
|
||||
} caster;
|
||||
caster.as_file_time = ft;
|
||||
|
||||
uint64_t sec = caster.as_integer / 10000000UL;
|
||||
uint32_t sub_sec = (caster.as_integer % 10000000UL) // 100-nanoseconds since the last second
|
||||
// 100-nanos since 1601-Jan-01
|
||||
uint64_t ft_as_integer = (static_cast< uint64_t >(ft.dwHighDateTime) << 32) | static_cast< uint64_t >(ft.dwLowDateTime);
|
||||
uint64_t sec = ft_as_integer / 10000000UL;
|
||||
uint32_t sub_sec = static_cast< uint32_t >(ft_as_integer % 10000000UL) // 100-nanoseconds since the last second
|
||||
#if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
|
||||
/ 10; // microseconds since the last second
|
||||
/ 10U; // microseconds since the last second
|
||||
#else
|
||||
* 100; // nanoseconds since the last second
|
||||
* 100U; // nanoseconds since the last second
|
||||
#endif
|
||||
|
||||
// split sec into usable chunks: days, hours, minutes, & seconds
|
||||
|
||||
@@ -659,8 +659,6 @@ class format_date_parser
|
||||
string_type format_str,
|
||||
match_results& mr) const
|
||||
{
|
||||
bool use_current_char = false;
|
||||
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
@@ -701,12 +699,7 @@ class format_date_parser
|
||||
}
|
||||
else { //skip past chars in format and in buffer
|
||||
itr++;
|
||||
if (use_current_char) {
|
||||
use_current_char = false;
|
||||
}
|
||||
else {
|
||||
sitr++;
|
||||
}
|
||||
sitr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace gregorian {
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE 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_;}
|
||||
greg_day(value_type day_of_month) : greg_day_rep(day_of_month) {}
|
||||
value_type as_number() const {return value_;}
|
||||
operator value_type() const {return value_;}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#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>
|
||||
#include <boost/io/ios_state.hpp>
|
||||
|
||||
//This file is basically commented out if locales are not supported
|
||||
#ifndef BOOST_DATE_TIME_NO_LOCALE
|
||||
@@ -75,9 +76,9 @@ namespace gregorian {
|
||||
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();
|
||||
else { // default to numeric
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << m.as_number();
|
||||
}
|
||||
|
||||
return os;
|
||||
@@ -142,7 +143,8 @@ namespace gregorian {
|
||||
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() << ' '
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << pd.day() << ' '
|
||||
<< pd.month().as_short_string() ;
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace gregorian {
|
||||
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) {}
|
||||
greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
|
||||
//! Convert the value back to a short
|
||||
operator unsigned short() const {return value_;}
|
||||
operator value_type() const {return value_;}
|
||||
//! Returns month as number from 1 to 12
|
||||
unsigned short as_number() const {return value_;}
|
||||
value_type 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;
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace gregorian {
|
||||
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(value_type day_of_week_num) :
|
||||
greg_weekday_rep(day_of_week_num)
|
||||
{}
|
||||
|
||||
unsigned short as_number() const {return value_;}
|
||||
value_type as_number() const {return value_;}
|
||||
const char* as_short_string() const;
|
||||
const char* as_long_string() const;
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
|
||||
@@ -21,26 +21,26 @@ namespace gregorian {
|
||||
struct BOOST_SYMBOL_VISIBLE bad_year : public std::out_of_range
|
||||
{
|
||||
bad_year() :
|
||||
std::out_of_range(std::string("Year is out of valid range: 1400..10000"))
|
||||
std::out_of_range(std::string("Year is out of valid range: 1400..9999"))
|
||||
{}
|
||||
};
|
||||
//! Policy class that declares error handling gregorian year type
|
||||
typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies;
|
||||
typedef CV::simple_exception_policy<unsigned short, 1400, 9999, 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)
|
||||
//! Represent a year (range 1400 - 9999)
|
||||
/*! 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
|
||||
range of 1400 to 9999. 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 BOOST_SYMBOL_VISIBLE greg_year : public greg_year_rep {
|
||||
public:
|
||||
greg_year(unsigned short year) : greg_year_rep(year) {}
|
||||
operator unsigned short() const {return value_;}
|
||||
greg_year(value_type year) : greg_year_rep(year) {}
|
||||
operator value_type() const {return value_;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, d);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, d);
|
||||
@@ -138,14 +138,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, dd);
|
||||
@@ -202,14 +202,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dp);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, dp);
|
||||
@@ -261,14 +261,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, m);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, m);
|
||||
@@ -318,14 +318,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, wd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, wd);
|
||||
@@ -359,14 +359,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, gd);
|
||||
@@ -400,14 +400,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gy);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, gy);
|
||||
@@ -458,14 +458,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, pd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, pd);
|
||||
@@ -515,14 +515,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, nday);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, nday);
|
||||
@@ -573,14 +573,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, fkd);
|
||||
@@ -631,14 +631,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, lkd);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, lkd);
|
||||
@@ -690,14 +690,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fka);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, fka);
|
||||
@@ -749,14 +749,14 @@ namespace gregorian {
|
||||
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;
|
||||
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
|
||||
|
||||
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);
|
||||
if(std::has_facet<date_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkb);
|
||||
}
|
||||
else {
|
||||
date_input_facet* f = new date_input_facet();
|
||||
date_input_facet_local* f = new date_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, fkb);
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace date_time {
|
||||
can be used in the creation of date systems or just to perform calculations.
|
||||
All the methods of this class are static functions, so the intent is to
|
||||
never create instances of this class.
|
||||
@param ymd_type_ Struct type representing the year, month, day. The ymd_type must
|
||||
@tparam ymd_type_ Struct type representing the year, month, day. The ymd_type must
|
||||
define a of types for the year, month, and day. These types need to be
|
||||
arithmetic types.
|
||||
@param date_int_type_ Underlying type for the date count. Must be an arithmetic type.
|
||||
@tparam date_int_type_ Underlying type for the date count. Must be an arithmetic type.
|
||||
*/
|
||||
template<typename ymd_type_, typename date_int_type_>
|
||||
class BOOST_SYMBOL_VISIBLE gregorian_calendar_base {
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
# include <ostream>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
// conditional expression is constant
|
||||
#pragma warning(disable: 4127)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
@@ -136,9 +142,7 @@ public:
|
||||
}
|
||||
bool operator==(const int& rhs) const
|
||||
{
|
||||
// quiets compiler warnings
|
||||
bool is_signed = std::numeric_limits<int_type>::is_signed;
|
||||
if(!is_signed)
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
{
|
||||
if(is_neg_inf(value_) && rhs == 0)
|
||||
{
|
||||
@@ -153,9 +157,7 @@ public:
|
||||
}
|
||||
bool operator!=(const int& rhs) const
|
||||
{
|
||||
// quiets compiler warnings
|
||||
bool is_signed = std::numeric_limits<int_type>::is_signed;
|
||||
if(!is_signed)
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
{
|
||||
if(is_neg_inf(value_) && rhs == 0)
|
||||
{
|
||||
@@ -171,8 +173,7 @@ public:
|
||||
bool operator<(const int& rhs) const
|
||||
{
|
||||
// quiets compiler warnings
|
||||
bool is_signed = std::numeric_limits<int_type>::is_signed;
|
||||
if(!is_signed)
|
||||
if(!std::numeric_limits<int_type>::is_signed)
|
||||
{
|
||||
if(is_neg_inf(value_) && rhs == 0)
|
||||
{
|
||||
@@ -414,18 +415,10 @@ private:
|
||||
//! Assumes at least 'this' or 'rhs' is a special value
|
||||
int_adapter mult_div_specials(const int_adapter& rhs)const
|
||||
{
|
||||
int min_value;
|
||||
// quiets compiler warnings
|
||||
bool is_signed = std::numeric_limits<int_type>::is_signed;
|
||||
if(is_signed) {
|
||||
min_value = 0;
|
||||
}
|
||||
else {
|
||||
min_value = 1;// there is no zero with unsigned
|
||||
}
|
||||
if(this->is_nan() || rhs.is_nan()) {
|
||||
return int_adapter<int_type>(not_a_number());
|
||||
}
|
||||
BOOST_CONSTEXPR_OR_CONST int min_value = std::numeric_limits<int_type>::is_signed ? 0 : 1;
|
||||
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < min_value)) {
|
||||
return int_adapter<int_type>(pos_infinity());
|
||||
}
|
||||
@@ -443,18 +436,10 @@ private:
|
||||
//! Assumes 'this' is a special value
|
||||
int_adapter mult_div_specials(const int& rhs) const
|
||||
{
|
||||
int min_value;
|
||||
// quiets compiler warnings
|
||||
bool is_signed = std::numeric_limits<int_type>::is_signed;
|
||||
if(is_signed) {
|
||||
min_value = 0;
|
||||
}
|
||||
else {
|
||||
min_value = 1;// there is no zero with unsigned
|
||||
}
|
||||
if(this->is_nan()) {
|
||||
return int_adapter<int_type>(not_a_number());
|
||||
}
|
||||
BOOST_CONSTEXPR_OR_CONST int min_value = std::numeric_limits<int_type>::is_signed ? 0 : 1;
|
||||
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < 0)) {
|
||||
return int_adapter<int_type>(pos_infinity());
|
||||
}
|
||||
@@ -504,6 +489,8 @@ private:
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -154,7 +154,6 @@ namespace local_time {
|
||||
}
|
||||
private:
|
||||
time_zone_names zone_names_;
|
||||
bool has_dst_;
|
||||
time_duration_type base_utc_offset_;
|
||||
dst_adjustment_offsets dst_offsets_;
|
||||
boost::shared_ptr<dst_calc_rule> dst_calc_rules_;
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
//This file basically becomes a noop if locales are not properly supported
|
||||
#if (defined(BOOST_NO_STD_LOCALE) \
|
||||
|| (BOOST_WORKAROUND( BOOST_MSVC, < 1300)) \
|
||||
|| (BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 )) ) )
|
||||
|| (BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 )) ) \
|
||||
|| (BOOST_WORKAROUND( BOOST_XLCPP_ZOS, BOOST_TESTED_AT( 0x42010000 )) ) /* <cctype> "shadows" the locale enabled overloads from <locale> */ \
|
||||
)
|
||||
#define BOOST_DATE_TIME_NO_LOCALE
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/c_time.hpp>
|
||||
#include <boost/date_time/time_clock.hpp>
|
||||
#include <boost/date_time/filetime_functions.hpp>
|
||||
#if defined(BOOST_HAS_FTIME)
|
||||
#include <boost/winapi/time.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
|
||||
|
||||
@@ -85,10 +87,19 @@ namespace date_time {
|
||||
std::time_t t = tv.tv_sec;
|
||||
boost::uint32_t sub_sec = tv.tv_usec;
|
||||
#elif defined(BOOST_HAS_FTIME)
|
||||
winapi::file_time ft;
|
||||
winapi::get_system_time_as_file_time(ft);
|
||||
uint64_t micros = winapi::file_time_to_microseconds(ft); // it will not wrap, since ft is the current time
|
||||
// and cannot be before 1970-Jan-01
|
||||
boost::winapi::FILETIME_ ft;
|
||||
boost::winapi::GetSystemTimeAsFileTime(&ft);
|
||||
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
|
||||
// Some runtime library implementations expect local times as the norm for ctime functions.
|
||||
{
|
||||
boost::winapi::FILETIME_ local_ft;
|
||||
boost::winapi::FileTimeToLocalFileTime(&ft, &local_ft);
|
||||
ft = local_ft;
|
||||
}
|
||||
#endif
|
||||
|
||||
boost::uint64_t micros = file_time_to_microseconds(ft); // it will not wrap, since ft is the current time
|
||||
// and cannot be before 1970-Jan-01
|
||||
std::time_t t = static_cast<std::time_t>(micros / 1000000UL); // seconds since epoch
|
||||
// microseconds -- static casts suppress warnings
|
||||
boost::uint32_t sub_sec = static_cast<boost::uint32_t>(micros % 1000000UL);
|
||||
@@ -115,6 +126,26 @@ namespace date_time {
|
||||
|
||||
return time_type(d,td);
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_FTIME)
|
||||
/*!
|
||||
* The function converts file_time into number of microseconds elapsed since 1970-Jan-01
|
||||
*
|
||||
* \note Only dates after 1970-Jan-01 are supported. Dates before will be wrapped.
|
||||
*/
|
||||
static boost::uint64_t file_time_to_microseconds(boost::winapi::FILETIME_ const& ft)
|
||||
{
|
||||
// shift is difference between 1970-Jan-01 & 1601-Jan-01
|
||||
// in 100-nanosecond units
|
||||
const boost::uint64_t shift = 116444736000000000ULL; // (27111902 << 32) + 3577643008
|
||||
|
||||
// 100-nanos since 1601-Jan-01
|
||||
boost::uint64_t ft_as_integer = (static_cast< boost::uint64_t >(ft.dwHighDateTime) << 32) | static_cast< boost::uint64_t >(ft.dwLowDateTime);
|
||||
|
||||
ft_as_integer -= shift; // filetime is now 100-nanos since 1970-Jan-01
|
||||
return (ft_as_integer / 10U); // truncate to microseconds
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -114,17 +114,18 @@ namespace boost { namespace date_time {
|
||||
{
|
||||
m_range_option = option;
|
||||
}
|
||||
void delimiter_strings(const string_type& ,
|
||||
const string_type& ,
|
||||
const string_type& ,
|
||||
const string_type& )
|
||||
{
|
||||
m_period_separator;
|
||||
m_period_start_delimeter;
|
||||
m_open_range_end_delimeter;
|
||||
m_closed_range_end_delimeter;
|
||||
}
|
||||
|
||||
//! Change the delimiter strings
|
||||
void delimiter_strings(const string_type& separator,
|
||||
const string_type& start_delim,
|
||||
const string_type& open_end_delim,
|
||||
const string_type& closed_end_delim)
|
||||
{
|
||||
m_period_separator = separator;
|
||||
m_period_start_delimeter = start_delim;
|
||||
m_open_range_end_delimeter = open_end_delim;
|
||||
m_closed_range_end_delimeter = closed_end_delim;
|
||||
}
|
||||
|
||||
//! Generic code to output a period -- no matter the period type.
|
||||
/*! This generic code will output any period using a facet to
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/posix_time/ptime.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_duration.hpp>
|
||||
#include <boost/date_time/filetime_functions.hpp>
|
||||
@@ -21,21 +22,18 @@ namespace boost {
|
||||
|
||||
namespace posix_time {
|
||||
|
||||
|
||||
//! Function that converts a time_t into a ptime.
|
||||
inline
|
||||
ptime from_time_t(std::time_t t)
|
||||
{
|
||||
ptime start(gregorian::date(1970,1,1));
|
||||
return start + seconds(static_cast<long>(t));
|
||||
return ptime(gregorian::date(1970,1,1)) + seconds(static_cast<long>(t));
|
||||
}
|
||||
|
||||
//! Function that converts a ptime into a time_t
|
||||
inline
|
||||
std::time_t to_time_t(ptime pt)
|
||||
{
|
||||
time_duration dur = pt - ptime(gregorian::date(1970,1,1));
|
||||
return std::time_t(dur.total_seconds());
|
||||
return (pt - ptime(gregorian::date(1970,1,1))).total_seconds();
|
||||
}
|
||||
|
||||
//! Convert a time to a tm structure truncating any fractional seconds
|
||||
@@ -43,9 +41,9 @@ namespace posix_time {
|
||||
std::tm to_tm(const boost::posix_time::ptime& t) {
|
||||
std::tm timetm = boost::gregorian::to_tm(t.date());
|
||||
boost::posix_time::time_duration td = t.time_of_day();
|
||||
timetm.tm_hour = td.hours();
|
||||
timetm.tm_min = td.minutes();
|
||||
timetm.tm_sec = td.seconds();
|
||||
timetm.tm_hour = static_cast<int>(td.hours());
|
||||
timetm.tm_min = static_cast<int>(td.minutes());
|
||||
timetm.tm_sec = static_cast<int>(td.seconds());
|
||||
timetm.tm_isdst = -1; // -1 used when dst info is unknown
|
||||
return timetm;
|
||||
}
|
||||
@@ -54,9 +52,9 @@ namespace posix_time {
|
||||
std::tm to_tm(const boost::posix_time::time_duration& td) {
|
||||
std::tm timetm;
|
||||
std::memset(&timetm, 0, sizeof(timetm));
|
||||
timetm.tm_hour = date_time::absolute_value(td.hours());
|
||||
timetm.tm_min = date_time::absolute_value(td.minutes());
|
||||
timetm.tm_sec = date_time::absolute_value(td.seconds());
|
||||
timetm.tm_hour = static_cast<int>(date_time::absolute_value(td.hours()));
|
||||
timetm.tm_min = static_cast<int>(date_time::absolute_value(td.minutes()));
|
||||
timetm.tm_sec = static_cast<int>(date_time::absolute_value(td.seconds()));
|
||||
timetm.tm_isdst = -1; // -1 used when dst info is unknown
|
||||
return timetm;
|
||||
}
|
||||
@@ -82,7 +80,7 @@ namespace posix_time {
|
||||
*
|
||||
* \note The function is templated on the FILETIME type, so that
|
||||
* it can be used with both native FILETIME and the ad-hoc
|
||||
* boost::date_time::winapi::file_time type.
|
||||
* boost::detail::winapi::FILETIME_ type.
|
||||
*/
|
||||
template< typename TimeT, typename FileTimeT >
|
||||
inline
|
||||
|
||||
@@ -9,42 +9,54 @@
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_config.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace posix_time {
|
||||
|
||||
//! Allows expression of durations as an hour count
|
||||
//! The argument must be an integral type
|
||||
/*! \ingroup time_basics
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE hours : public time_duration
|
||||
{
|
||||
public:
|
||||
explicit hours(long h) :
|
||||
time_duration(static_cast<hour_type>(h),0,0)
|
||||
template <typename T>
|
||||
explicit hours(T const& h,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(numeric_cast<hour_type>(h), 0, 0)
|
||||
{}
|
||||
};
|
||||
|
||||
//! Allows expression of durations as a minute count
|
||||
//! The argument must be an integral type
|
||||
/*! \ingroup time_basics
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE minutes : public time_duration
|
||||
{
|
||||
public:
|
||||
explicit minutes(long m) :
|
||||
time_duration(0,static_cast<min_type>(m),0)
|
||||
template <typename T>
|
||||
explicit minutes(T const& m,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(0, numeric_cast<min_type>(m),0)
|
||||
{}
|
||||
};
|
||||
|
||||
//! Allows expression of durations as a seconds count
|
||||
//! The argument must be an integral type
|
||||
/*! \ingroup time_basics
|
||||
*/
|
||||
class BOOST_SYMBOL_VISIBLE seconds : public time_duration
|
||||
{
|
||||
public:
|
||||
explicit seconds(long s) :
|
||||
time_duration(0,0,static_cast<sec_type>(s))
|
||||
template <typename T>
|
||||
explicit seconds(T const& s,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
time_duration(0,0, numeric_cast<sec_type>(s))
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -70,12 +82,8 @@ namespace posix_time {
|
||||
typedef date_time::subsecond_duration<time_duration,1000000000> nanosec;
|
||||
typedef date_time::subsecond_duration<time_duration,1000000000> nanoseconds;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
} }//namespace posix_time
|
||||
|
||||
|
||||
|
||||
@@ -74,13 +74,13 @@ namespace posix_time {
|
||||
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
|
||||
if (strm_sentry) {
|
||||
try {
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
|
||||
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
|
||||
if(std::has_facet<time_input_facet>(is.getloc())) {
|
||||
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, pt);
|
||||
if(std::has_facet<time_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, pt);
|
||||
}
|
||||
else {
|
||||
time_input_facet* f = new time_input_facet();
|
||||
time_input_facet_local* f = new time_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, pt);
|
||||
@@ -141,13 +141,13 @@ namespace posix_time {
|
||||
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
|
||||
if (strm_sentry) {
|
||||
try {
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
|
||||
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
|
||||
if(std::has_facet<time_input_facet>(is.getloc())) {
|
||||
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, tp);
|
||||
if(std::has_facet<time_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, tp);
|
||||
}
|
||||
else {
|
||||
time_input_facet* f = new time_input_facet();
|
||||
time_input_facet_local* f = new time_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, tp);
|
||||
@@ -205,13 +205,13 @@ namespace posix_time {
|
||||
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
|
||||
if (strm_sentry) {
|
||||
try {
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
|
||||
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
|
||||
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
|
||||
if(std::has_facet<time_input_facet>(is.getloc())) {
|
||||
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, td);
|
||||
if(std::has_facet<time_input_facet_local>(is.getloc())) {
|
||||
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, td);
|
||||
}
|
||||
else {
|
||||
time_input_facet* f = new time_input_facet();
|
||||
time_input_facet_local* f = new time_input_facet_local();
|
||||
std::locale l = std::locale(is.getloc(), f);
|
||||
is.imbue(l);
|
||||
f->get(sit, str_end, is, td);
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/date_time/gregorian/greg_serialize.hpp"
|
||||
#include "boost/numeric/conversion/cast.hpp"
|
||||
#include "boost/serialization/split_free.hpp"
|
||||
#include "boost/serialization/nvp.hpp"
|
||||
|
||||
#include "boost/serialization/version.hpp"
|
||||
|
||||
// macros to split serialize functions into save & load functions
|
||||
// NOTE: these macros define template functions in the boost::serialization namespace.
|
||||
@@ -22,6 +23,14 @@ BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::ptime)
|
||||
BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_duration)
|
||||
BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_period)
|
||||
|
||||
// Define versions for serialization compatibility
|
||||
// alows the unit tests to make an older version to check compatibility
|
||||
#ifndef BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION
|
||||
#define BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION 1
|
||||
#endif
|
||||
|
||||
BOOST_CLASS_VERSION(boost::posix_time::time_duration, BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION)
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
@@ -33,10 +42,23 @@ namespace serialization {
|
||||
* types are hour_type, min_type, sec_type, and fractional_seconds_type
|
||||
* as defined in the time_duration class
|
||||
*/
|
||||
template<class TimeResTraitsSize, class Archive>
|
||||
void save_td(Archive& ar, const posix_time::time_duration& td)
|
||||
{
|
||||
TimeResTraitsSize h = boost::numeric_cast<TimeResTraitsSize>(td.hours());
|
||||
TimeResTraitsSize m = boost::numeric_cast<TimeResTraitsSize>(td.minutes());
|
||||
TimeResTraitsSize s = boost::numeric_cast<TimeResTraitsSize>(td.seconds());
|
||||
posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
|
||||
ar & make_nvp("time_duration_hours", h);
|
||||
ar & make_nvp("time_duration_minutes", m);
|
||||
ar & make_nvp("time_duration_seconds", s);
|
||||
ar & make_nvp("time_duration_fractional_seconds", fs);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void save(Archive & ar,
|
||||
const posix_time::time_duration& td,
|
||||
unsigned int /*version*/)
|
||||
unsigned int version)
|
||||
{
|
||||
// serialize a bool so we know how to read this back in later
|
||||
bool is_special = td.is_special();
|
||||
@@ -46,14 +68,13 @@ void save(Archive & ar,
|
||||
ar & make_nvp("sv_time_duration", s);
|
||||
}
|
||||
else {
|
||||
posix_time::time_duration::hour_type h = td.hours();
|
||||
posix_time::time_duration::min_type m = td.minutes();
|
||||
posix_time::time_duration::sec_type s = td.seconds();
|
||||
posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
|
||||
ar & make_nvp("time_duration_hours", h);
|
||||
ar & make_nvp("time_duration_minutes", m);
|
||||
ar & make_nvp("time_duration_seconds", s);
|
||||
ar & make_nvp("time_duration_fractional_seconds", fs);
|
||||
// Write support for earlier versions allows for upgrade compatibility testing
|
||||
// See load comments for version information
|
||||
if (version == 0) {
|
||||
save_td<int32_t>(ar, td);
|
||||
} else {
|
||||
save_td<int64_t>(ar, td);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +83,24 @@ void save(Archive & ar,
|
||||
* types are hour_type, min_type, sec_type, and fractional_seconds_type
|
||||
* as defined in the time_duration class
|
||||
*/
|
||||
template<class TimeResTraitsSize, class Archive>
|
||||
void load_td(Archive& ar, posix_time::time_duration& td)
|
||||
{
|
||||
TimeResTraitsSize h(0);
|
||||
TimeResTraitsSize m(0);
|
||||
TimeResTraitsSize s(0);
|
||||
posix_time::time_duration::fractional_seconds_type fs(0);
|
||||
ar & make_nvp("time_duration_hours", h);
|
||||
ar & make_nvp("time_duration_minutes", m);
|
||||
ar & make_nvp("time_duration_seconds", s);
|
||||
ar & make_nvp("time_duration_fractional_seconds", fs);
|
||||
td = posix_time::time_duration(h, m, s, fs);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar,
|
||||
posix_time::time_duration & td,
|
||||
unsigned int /*version*/)
|
||||
unsigned int version)
|
||||
{
|
||||
bool is_special = false;
|
||||
ar & make_nvp("is_special", is_special);
|
||||
@@ -76,15 +111,25 @@ void load(Archive & ar,
|
||||
td = posix_time::time_duration(sv);
|
||||
}
|
||||
else {
|
||||
posix_time::time_duration::hour_type h(0);
|
||||
posix_time::time_duration::min_type m(0);
|
||||
posix_time::time_duration::sec_type s(0);
|
||||
posix_time::time_duration::fractional_seconds_type fs(0);
|
||||
ar & make_nvp("time_duration_hours", h);
|
||||
ar & make_nvp("time_duration_minutes", m);
|
||||
ar & make_nvp("time_duration_seconds", s);
|
||||
ar & make_nvp("time_duration_fractional_seconds", fs);
|
||||
td = posix_time::time_duration(h,m,s,fs);
|
||||
// Version "0" (Boost 1.65.1 or earlier, which used int32_t for day/hour/minute/second and
|
||||
// therefore suffered from the year 2038 issue.)
|
||||
// Version "0.5" (Boost 1.66.0 changed to std::time_t but did not increase the version;
|
||||
// it was missed in the original change, all code reviews, and there were no
|
||||
// static assertions to protect the code; further std::time_t can be 32-bit
|
||||
// or 64-bit so it reduced portability. This makes 1.66.0 hard to handle...)
|
||||
// Version "1" (Boost 1.67.0 or later uses int64_t and is properly versioned)
|
||||
|
||||
// If the size of any of these items changes, a new version is needed.
|
||||
BOOST_STATIC_ASSERT(sizeof(posix_time::time_duration::hour_type) == sizeof(boost::int64_t));
|
||||
BOOST_STATIC_ASSERT(sizeof(posix_time::time_duration::min_type) == sizeof(boost::int64_t));
|
||||
BOOST_STATIC_ASSERT(sizeof(posix_time::time_duration::sec_type) == sizeof(boost::int64_t));
|
||||
BOOST_STATIC_ASSERT(sizeof(posix_time::time_duration::fractional_seconds_type) == sizeof(boost::int64_t));
|
||||
|
||||
if (version == 0) {
|
||||
load_td<int32_t>(ar, td);
|
||||
} else {
|
||||
load_td<int64_t>(ar, td);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,9 @@ namespace boost { namespace date_time {
|
||||
{
|
||||
public:
|
||||
typedef std::basic_string<charT> string_type;
|
||||
//typedef std::basic_stringstream<charT> stringstream_type;
|
||||
typedef std::basic_stringstream<charT> stringstream_type;
|
||||
typedef std::istreambuf_iterator<charT> stream_itr_type;
|
||||
//typedef typename string_type::const_iterator const_itr;
|
||||
//typedef typename date_type::year_type year_type;
|
||||
//typedef typename date_type::month_type month_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
//typedef typename date_type::day_of_week_type day_of_week_type;
|
||||
//typedef typename date_type::day_type day_type;
|
||||
typedef string_parse_tree<charT> parse_tree_type;
|
||||
typedef typename parse_tree_type::parse_match_result_type match_results;
|
||||
typedef std::vector<std::basic_string<charT> > collection_type;
|
||||
@@ -101,11 +96,37 @@ namespace boost { namespace date_time {
|
||||
m_sv_strings = parse_tree_type(phrases, static_cast<int>(not_a_date_time));
|
||||
}
|
||||
|
||||
/* Does not return a special_value because if the parsing fails,
|
||||
* the return value will always be not_a_date_time
|
||||
* (mr.current_match retains its default value of -1 on a failed
|
||||
* parse and that casts to not_a_date_time). */
|
||||
//! Sets match_results.current_match to the corresponding special_value or -1
|
||||
//! The parser is expensive to create, and not thread-safe so it cannot be static
|
||||
//! therefore given a string, determine if it is likely to be a special value.
|
||||
//! A negative response is a definite no, whereas a positive is only likely and
|
||||
//! match() should be called and return value checked.
|
||||
//! \param[in] str the string to check
|
||||
//! \returns false if it is definitely not a special value
|
||||
static bool likely(const string_type& str)
|
||||
{
|
||||
if (!str.empty()) {
|
||||
switch (str[0]) {
|
||||
// See string definitions at the end of this class..
|
||||
case '+':
|
||||
case '-':
|
||||
case 'n':
|
||||
case 'm':
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Given an input iterator, attempt to match it to a known special value
|
||||
//! \param[in] sitr the start iterator
|
||||
//! \param[in] str_end the end iterator
|
||||
//! \param[out] mr the match result:
|
||||
//! mr.current_match is set to the corresponding special_value or -1
|
||||
//! \returns whether something matched
|
||||
bool match(stream_itr_type& sitr,
|
||||
stream_itr_type& str_end,
|
||||
match_results& mr) const
|
||||
@@ -114,18 +135,6 @@ namespace boost { namespace date_time {
|
||||
m_sv_strings.match(sitr, str_end, mr, level);
|
||||
return (mr.current_match != match_results::PARSE_ERROR);
|
||||
}
|
||||
/*special_values match(stream_itr_type& sitr,
|
||||
stream_itr_type& str_end,
|
||||
match_results& mr) const
|
||||
{
|
||||
unsigned int level = 0;
|
||||
m_sv_strings.match(sitr, str_end, mr, level);
|
||||
if(mr.current_match == match_results::PARSE_ERROR) {
|
||||
throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
|
||||
}
|
||||
return static_cast<special_values>(mr.current_match);
|
||||
}*/
|
||||
|
||||
|
||||
private:
|
||||
parse_tree_type m_sv_strings;
|
||||
|
||||
@@ -25,7 +25,7 @@ struct parse_match_result
|
||||
{
|
||||
parse_match_result() :
|
||||
match_depth(0),
|
||||
current_match(-1)// -1 is match_not-found value
|
||||
current_match(PARSE_ERROR)
|
||||
{}
|
||||
typedef std::basic_string<charT> string_type;
|
||||
string_type remaining() const
|
||||
@@ -33,7 +33,7 @@ struct parse_match_result
|
||||
if (match_depth == cache.size()) {
|
||||
return string_type();
|
||||
}
|
||||
if (current_match == -1) {
|
||||
if (current_match == PARSE_ERROR) {
|
||||
return cache;
|
||||
}
|
||||
//some of the cache was used return the rest
|
||||
@@ -56,7 +56,7 @@ struct parse_match_result
|
||||
string_type cache;
|
||||
unsigned short match_depth;
|
||||
short current_match;
|
||||
enum PARSE_STATE { PARSE_ERROR= -1 };
|
||||
enum PARSE_STATE { PARSE_ERROR = -1 };
|
||||
};
|
||||
|
||||
//for debug -- really only char streams...
|
||||
@@ -99,7 +99,8 @@ struct string_parse_tree
|
||||
* (Sun=0, Mon=1, ...) were a starting_point of one starts the
|
||||
* numbering at one (Jan=1, Feb=2, ...). The default is zero,
|
||||
* negative vaules are not allowed */
|
||||
string_parse_tree(collection_type names, unsigned int starting_point=0)
|
||||
string_parse_tree(collection_type names, unsigned int starting_point=0) :
|
||||
m_value(parse_match_result_type::PARSE_ERROR)
|
||||
{
|
||||
// iterate thru all the elements and build the tree
|
||||
unsigned short index = 0;
|
||||
@@ -113,7 +114,7 @@ struct string_parse_tree
|
||||
}
|
||||
|
||||
|
||||
string_parse_tree(short value = -1) :
|
||||
string_parse_tree(short value = parse_match_result_type::PARSE_ERROR) :
|
||||
m_value(value)
|
||||
{}
|
||||
ptree_coll m_next_chars;
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/time_defs.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/date_time/time_defs.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -27,8 +29,8 @@ namespace date_time {
|
||||
This design allows the subclass duration types to provide custom
|
||||
construction policies or other custom features not provided here.
|
||||
|
||||
@param T The subclass type
|
||||
@param rep_type The time resolution traits for this duration type.
|
||||
@tparam T The subclass type
|
||||
@tparam rep_type The time resolution traits for this duration type.
|
||||
*/
|
||||
template<class T, typename rep_type>
|
||||
class BOOST_SYMBOL_VISIBLE time_duration : private
|
||||
@@ -262,7 +264,7 @@ namespace date_time {
|
||||
|
||||
//! Template for instantiating derived adjusting durations
|
||||
/* These templates are designed to work with multiples of
|
||||
* 10 for frac_of_second and resoultion adjustment
|
||||
* 10 for frac_of_second and resolution adjustment
|
||||
*/
|
||||
template<class base_duration, boost::int64_t frac_of_second>
|
||||
class BOOST_SYMBOL_VISIBLE subsecond_duration : public base_duration
|
||||
@@ -278,14 +280,15 @@ namespace date_time {
|
||||
BOOST_STATIC_CONSTANT(boost::int64_t, adjustment_ratio = (traits_type::ticks_per_second >= frac_of_second ? traits_type::ticks_per_second / frac_of_second : frac_of_second / traits_type::ticks_per_second));
|
||||
|
||||
public:
|
||||
explicit subsecond_duration(boost::int64_t ss) :
|
||||
// The argument (ss) must be an integral type
|
||||
template <typename T>
|
||||
explicit subsecond_duration(T const& ss,
|
||||
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
|
||||
base_duration(impl_type(traits_type::ticks_per_second >= frac_of_second ? ss * adjustment_ratio : ss / adjustment_ratio))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
|
||||
@@ -866,6 +866,7 @@ namespace date_time {
|
||||
break;
|
||||
// %s is the same as %S%f so we drop through into %f
|
||||
}
|
||||
/* Falls through. */
|
||||
case 'f':
|
||||
{
|
||||
// check for decimal, check special_values if missing
|
||||
@@ -1088,9 +1089,12 @@ namespace date_time {
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
case 'e':
|
||||
{
|
||||
try {
|
||||
t_day = this->m_parser.parse_day_of_month(sitr, stream_end);
|
||||
t_day = (*itr == 'd') ?
|
||||
this->m_parser.parse_day_of_month(sitr, stream_end) :
|
||||
this->m_parser.parse_var_day_of_month(sitr, stream_end);
|
||||
}
|
||||
catch(std::out_of_range&) { // base class for exception bad_day_of_month
|
||||
match_results mr;
|
||||
@@ -1136,6 +1140,7 @@ namespace date_time {
|
||||
// %s is the same as %S%f so we drop through into %f if we are
|
||||
// not at the end of the stream
|
||||
}
|
||||
/* Falls through. */
|
||||
case 'f':
|
||||
{
|
||||
// check for decimal, check SV if missing
|
||||
@@ -1227,7 +1232,7 @@ namespace date_time {
|
||||
|
||||
date_type d(not_a_date_time);
|
||||
if (day_of_year > 0) {
|
||||
d = date_type(static_cast<unsigned short>(t_year-1),12,31) + date_duration_type(day_of_year);
|
||||
d = date_type(static_cast<unsigned short>(t_year),1,1) + date_duration_type(day_of_year-1);
|
||||
}
|
||||
else {
|
||||
d = date_type(t_year, t_month, t_day);
|
||||
@@ -1250,7 +1255,7 @@ namespace date_time {
|
||||
if((c == '-' || c == '+') && (*sitr != c)) { // was the first character consumed?
|
||||
mr.cache += c;
|
||||
}
|
||||
this->m_sv_parser.match(sitr, stream_end, mr);
|
||||
(void)this->m_sv_parser.match(sitr, stream_end, mr);
|
||||
if(mr.current_match == match_results::PARSE_ERROR) {
|
||||
std::string tmp = convert_string_type<char_type, char>(mr.cache);
|
||||
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + tmp + "'"));
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "boost/tokenizer.hpp"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
#include "boost/date_time/date_parsing.hpp"
|
||||
#include "boost/date_time/special_values_parser.hpp"
|
||||
#include "boost/cstdint.hpp"
|
||||
#include <iostream>
|
||||
|
||||
@@ -302,6 +303,25 @@ namespace date_time {
|
||||
{
|
||||
typedef typename time_type::time_duration_type time_duration;
|
||||
typedef typename time_type::date_type date_type;
|
||||
typedef special_values_parser<date_type, std::string::value_type> svp_type;
|
||||
|
||||
// given to_iso_string can produce a special value string
|
||||
// then from_iso_string should be able to read a special value string
|
||||
// the special_values_parser is expensive to set up and not thread-safe
|
||||
// so it cannot be static, so we need to be careful about when we use it
|
||||
if (svp_type::likely(s)) {
|
||||
typedef typename svp_type::stringstream_type ss_type;
|
||||
typedef typename svp_type::stream_itr_type itr_type;
|
||||
typedef typename svp_type::match_results mr_type;
|
||||
svp_type p; // expensive
|
||||
mr_type mr;
|
||||
ss_type ss(s);
|
||||
itr_type itr(ss);
|
||||
itr_type end;
|
||||
if (p.match(itr, end, mr)) {
|
||||
return time_type(static_cast<special_values>(mr.current_match));
|
||||
}
|
||||
}
|
||||
|
||||
//split date/time on a unique delimiter char such as ' ' or 'T'
|
||||
std::string date_string, tod_string;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
#include <ctime>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/time_defs.hpp>
|
||||
#include <boost/date_time/int_adapter.hpp>
|
||||
@@ -60,6 +60,29 @@ namespace date_time {
|
||||
static bool is_adapted() { return true;}
|
||||
};
|
||||
|
||||
//
|
||||
// Note about var_type, which is used to define the variable that
|
||||
// stores hours, minutes, and seconds values:
|
||||
//
|
||||
// In Boost 1.65.1 and earlier var_type was boost::int32_t which suffers
|
||||
// the year 2038 problem. Binary serialization of posix_time uses
|
||||
// 32-bit values, and uses serialization version 0.
|
||||
//
|
||||
// In Boost 1.66.0 the var_type changed to std::time_t, however
|
||||
// binary serialization was not properly versioned, so on platforms
|
||||
// where std::time_t is 32-bits, it remains compatible, however on
|
||||
// platforms where std::time_t is 64-bits, binary serialization ingest
|
||||
// will be incompatible with previous versions. Furthermore, binary
|
||||
// serialized output from 1.66.0 will not be compatible with future
|
||||
// versions. Yes, it's a mess. Static assertions were not present
|
||||
// in the serialization code to protect against this possibility.
|
||||
//
|
||||
// In Boost 1.67.0 the var_type was changed to boost::int64_t,
|
||||
// ensuring the output size is 64 bits, and the serialization version
|
||||
// was bumped. Static assertions were added as well, protecting
|
||||
// future changes in this area.
|
||||
//
|
||||
|
||||
template<typename frac_sec_type,
|
||||
time_resolutions res,
|
||||
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
|
||||
@@ -68,7 +91,7 @@ namespace date_time {
|
||||
typename frac_sec_type::int_type resolution_adjust,
|
||||
#endif
|
||||
unsigned short frac_digits,
|
||||
typename var_type = boost::int32_t >
|
||||
typename var_type = boost::int64_t > // see note above
|
||||
class time_resolution_traits {
|
||||
public:
|
||||
typedef typename frac_sec_type::int_type fractional_seconds_type;
|
||||
@@ -120,14 +143,14 @@ namespace date_time {
|
||||
minutes = absolute_value(minutes);
|
||||
seconds = absolute_value(seconds);
|
||||
fs = absolute_value(fs);
|
||||
return (((((fractional_seconds_type(hours)*3600)
|
||||
+ (fractional_seconds_type(minutes)*60)
|
||||
+ seconds)*res_adjust()) + fs) * -1);
|
||||
return static_cast<tick_type>(((((fractional_seconds_type(hours)*3600)
|
||||
+ (fractional_seconds_type(minutes)*60)
|
||||
+ seconds)*res_adjust()) + fs) * -1);
|
||||
}
|
||||
|
||||
return (((fractional_seconds_type(hours)*3600)
|
||||
+ (fractional_seconds_type(minutes)*60)
|
||||
+ seconds)*res_adjust()) + fs;
|
||||
return static_cast<tick_type>((((fractional_seconds_type(hours)*3600)
|
||||
+ (fractional_seconds_type(minutes)*60)
|
||||
+ seconds)*res_adjust()) + fs);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <boost/config.hpp>
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include "boost/date_time/special_defs.hpp"
|
||||
|
||||
@@ -193,10 +194,15 @@ namespace date_time {
|
||||
const time_rep_type& rhs)
|
||||
{
|
||||
date_duration_type dd = lhs.day - rhs.day;
|
||||
time_duration_type td(dd.days()*24,0,0); //days * 24 hours
|
||||
time_duration_type td2 = lhs.time_of_day - rhs.time_of_day;
|
||||
return td+td2;
|
||||
// return time_rep_type(base.day-dd, base.time_of_day);
|
||||
if (BOOST_LIKELY(!dd.is_special())) {
|
||||
time_duration_type td(dd.days()*24,0,0); // days * 24 hours
|
||||
time_duration_type td2 = lhs.time_of_day - rhs.time_of_day;
|
||||
return td+td2;
|
||||
} else {
|
||||
time_duration_type td(dd.as_special());
|
||||
time_duration_type td2 = lhs.time_of_day - rhs.time_of_day;
|
||||
return td+td2;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace date_time {
|
||||
|
||||
//! Structure which holds the time offsets associated with daylight savings time
|
||||
/*!
|
||||
*@param time_duration_type A type used to represent the offset
|
||||
*@tparam time_duration_type A type used to represent the offset
|
||||
*/
|
||||
template<class time_duration_type>
|
||||
class dst_adjustment_offsets
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace date_time {
|
||||
* name: Pacific Standard Time and the abbreviated name: PST.
|
||||
* During daylight savings there are additional names:
|
||||
* Pacific Daylight Time and PDT.
|
||||
*@parm CharT Allows class to support different character types
|
||||
*@tparam CharT Allows class to support different character types
|
||||
*/
|
||||
template<class CharT>
|
||||
class time_zone_names_base
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <boost/date_time/time_zone_names.hpp>
|
||||
#include <boost/date_time/time_zone_base.hpp>
|
||||
#include <boost/date_time/time_parsing.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -170,8 +171,9 @@ namespace boost {
|
||||
/*! May throw bad_field_count exceptions */
|
||||
void load_from_stream(std::istream &in)
|
||||
{
|
||||
std::string buff;
|
||||
std::string buff;
|
||||
while( std::getline(in, buff)) {
|
||||
boost::trim_right(buff);
|
||||
parse_string(buff);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user