|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55511 - in sandbox/SOC/2008/calendar: boost/date_time boost/date_time/gregorian boost/date_time/local_time boost/date_time/posix_time libs/date_time libs/date_time/src libs/date_time/src/gregorian libs/date_time/test libs/date_time/test/gregorian libs/date_time/test/local_time libs/date_time/test/posix_time libs/date_time/xmldoc
From: chankwanting_at_[hidden]
Date: 2009-08-10 17:15:18
Author: ktchan
Date: 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
New Revision: 55511
URL: http://svn.boost.org/trac/boost/changeset/55511
Log:
Let's try this again. Start afresh with date_time from trunk.
Added:
sandbox/SOC/2008/calendar/libs/date_time/CMakeLists.txt (contents, props changed)
sandbox/SOC/2008/calendar/libs/date_time/module.cmake (contents, props changed)
sandbox/SOC/2008/calendar/libs/date_time/src/CMakeLists.txt (contents, props changed)
sandbox/SOC/2008/calendar/libs/date_time/test/CMakeLists.txt (contents, props changed)
sandbox/SOC/2008/calendar/libs/date_time/test/testfrmwk.hpp (contents, props changed)
Removed:
sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp
Text files modified:
sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp | 10
sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp | 22 +
sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp | 32 ++
sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp | 49 +++-
sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp | 27 +-
sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp | 441 +++++++++++++++++++--------------------
sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp | 42 +-
sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp | 103 ++++----
sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp | 32 +-
sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp | 213 ++++++++++--------
sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp | 174 ++++++++++++---
sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp | 32 +
sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp | 71 ++---
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp | 13
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp | 116 +++++++++
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp | 23 +
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp | 35 +-
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp | 6
sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp | 4
sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp | 15
sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp | 4
sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp | 6
sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp | 7
sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp | 54 ++--
sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp | 100 +++++++-
sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp | 69 ++++--
sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp | 29 +-
sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp | 4
sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp | 154 +++----------
sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp | 32 +-
sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp | 26 +-
sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp | 38 +-
sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp | 69 ++---
sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp | 92 ++++----
sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp | 12
sandbox/SOC/2008/calendar/boost/date_time/time.hpp | 13
sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp | 14 +
sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp | 53 ++--
sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp | 250 ++++++++++++++--------
sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp | 13
sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp | 54 ++--
sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp | 20 -
sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp | 36 +-
sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp | 36 +-
sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2 | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp | 16
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp | 20
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp | 266 ++++++++++++-----------
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp | 6
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp | 32 +-
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp | 51 +---
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp | 16
sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp | 6
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp | 30 +
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp | 8
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp | 16
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp | 12
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp | 16
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp | 53 +++-
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp | 6
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp | 6
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp | 48 +++
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp | 132 +++++-----
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp | 30 +-
sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp | 4
sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp | 2
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2 | 25 +
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml | 171 ++++++++++++++
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml | 8
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml | 6
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml | 8
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml | 2
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml | 4
sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml | 14
108 files changed, 2176 insertions(+), 1569 deletions(-)
Modified: sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
/*! @file c_local_time_adjustor.hpp
@@ -14,7 +14,9 @@
*/
#include <stdexcept>
-#include "boost/date_time/c_time.hpp"
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/c_time.hpp>
namespace boost {
namespace date_time {
@@ -35,14 +37,14 @@
date_type time_t_start_day(1970,1,1);
time_type time_t_start_time(time_t_start_day,time_duration_type(0,0,0));
if (t < time_t_start_time) {
- throw std::out_of_range("Cannot convert dates prior to Jan 1, 1970");
+ boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
}
date_duration_type dd = t.date() - time_t_start_day;
time_duration_type td = t.time_of_day();
std::time_t t2 = dd.days()*86400 + td.hours()*3600 + td.minutes()*60 + td.seconds();
std::tm tms, *tms_ptr;
tms_ptr = c_time::localtime(&t2, &tms);
- //tms_ptr = std::localtime(&t2);
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));
Modified: sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-06 15:12:17 +0000 (Thu, 06 Nov 2008) $
*/
@@ -14,10 +14,13 @@
Provide workarounds related to the ctime header
*/
-#include "boost/date_time/compiler_config.hpp"
#include <ctime>
-//Work around libraries that don't put time_t and time in namespace std
+#include <string> // to be able to convert from string literals to exceptions
+#include <stdexcept>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/compiler_config.hpp>
+//Work around libraries that don't put time_t and time in namespace std
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std { using ::time_t; using ::time; using ::localtime;
using ::tm; using ::gmtime; }
@@ -40,7 +43,10 @@
* user created std::tm struct whereas the regular functions use a
* staticly created struct and return a pointer to that. These wrapper
* functions require the user to create a std::tm struct and send in a
- * pointer to it. A pointer to the user created struct will be returned. */
+ * pointer to it. A pointer to the user created struct will be returned.
+ * All functions do proper checking of the C function results and throw
+ * exceptions on error. Therefore the functions will never return NULL.
+ */
struct c_time {
public:
#if defined(BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS)
@@ -50,6 +56,8 @@
{
// localtime_r() not in namespace std???
result = localtime_r(t, result);
+ if (!result)
+ boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
return result;
}
//! requires a pointer to a user created std::tm struct
@@ -58,6 +66,8 @@
{
// gmtime_r() not in namespace std???
result = gmtime_r(t, result);
+ if (!result)
+ boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
return result;
}
#else // BOOST_HAS_THREADS
@@ -71,6 +81,8 @@
static std::tm* localtime(const std::time_t* t, std::tm* result)
{
result = std::localtime(t);
+ if (!result)
+ boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
return result;
}
//! requires a pointer to a user created std::tm struct
@@ -78,6 +90,8 @@
static std::tm* gmtime(const std::time_t* t, std::tm* result)
{
result = std::gmtime(t);
+ if (!result)
+ boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
return result;
}
#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
Modified: sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,10 +5,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
- #include "boost/detail/workaround.hpp"
+#include <cstdlib>
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
// With boost release 1.33, date_time will be using a different,
// more flexible, IO system. This new system is not compatible with
@@ -26,7 +28,7 @@
// This file performs some local compiler configurations
-#include "boost/date_time/locale_config.hpp" //set up locale configurations
+#include <boost/date_time/locale_config.hpp> //set up locale configurations
//Set up a configuration parameter for platforms that have
//GetTimeOfDay
@@ -49,7 +51,7 @@
#endif
// include these types before we try to re-define them
-#include "boost/cstdint.hpp"
+#include <boost/cstdint.hpp>
//Define INT64_C for compilers that don't have it
#if (!defined(INT64_C))
@@ -85,12 +87,32 @@
#define BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
#endif
+// The macro marks up places where compiler complains for missing return statement or
+// uninitialized variables after calling to boost::throw_exception.
+// BOOST_UNREACHABLE_RETURN doesn't work since even compilers that support
+// unreachable statements detection emit such warnings.
+#if defined(_MSC_VER)
+// Use special MSVC extension to markup unreachable code
+# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) __assume(false)
+#elif !defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION)
+// Call to a non-returning function should suppress the warning
+# if defined(BOOST_NO_STDC_NAMESPACE)
+namespace std {
+ using ::abort;
+}
+# endif // defined(BOOST_NO_STDC_NAMESPACE)
+# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) std::abort()
+#else
+// For other poor compilers the specified expression is compiled. Usually, this would be a return statement.
+# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) x
+#endif
+
/* The following handles the definition of the necessary macros
* for dll building on Win32 platforms.
*
* For code that will be placed in the date_time .dll,
* it must be properly prefixed with BOOST_DATE_TIME_DECL.
- * The corresponding .cpp file must have BOOST_DATE_TIME_SOURCES
+ * The corresponding .cpp file must have BOOST_DATE_TIME_SOURCE
* defined before including its header. For examples see:
* greg_month.hpp & greg_month.cpp
*
Modified: sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,10 +6,15 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
+#include <exception>
+#include <stdexcept>
#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_base_of.hpp>
namespace boost {
@@ -38,21 +43,21 @@
public:
typedef typename value_policies::value_type value_type;
// typedef except_type exception_type;
- constrained_value(value_type value)
+ constrained_value(value_type value) : value_((min)())
{
assign(value);
- };
- constrained_value& operator=(value_type v)
- {
+ }
+ constrained_value& operator=(value_type v)
+ {
assign(v);
return *this;
- }
+ }
//! Return the max allowed value (traits method)
- static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();};
+ static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();}
//! Return the min allowed value (traits method)
- static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();};
+ static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
//! Coerce into the representation type
- operator value_type() const {return value_;};
+ operator value_type() const {return value_;}
protected:
value_type value_;
private:
@@ -69,7 +74,6 @@
return;
}
value_ = value;
-
}
};
@@ -78,13 +82,32 @@
rep_type max_value, class exception_type>
class simple_exception_policy
{
+ struct exception_wrapper : public exception_type
+ {
+ // In order to support throw_exception mechanism in the BOOST_NO_EXCEPTIONS mode,
+ // we'll have to provide a way to acquire std::exception from the exception being thrown.
+ // However, we cannot derive from it, since it would make it interceptable by this class,
+ // which might not be what the user wanted.
+ operator std::out_of_range () const
+ {
+ // TODO: Make the message more descriptive by using arguments to on_error
+ return std::out_of_range("constrained value boundary has been violated");
+ }
+ };
+
+ typedef typename mpl::if_<
+ is_base_of< std::exception, exception_type >,
+ exception_type,
+ exception_wrapper
+ >::type actual_exception_type;
+
public:
typedef rep_type value_type;
- static rep_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; };
- static rep_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value;};
+ static rep_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; }
+ static rep_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value; }
static void on_error(rep_type, rep_type, violation_enum)
{
- throw exception_type();
+ boost::throw_exception(actual_exception_type());
}
};
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,11 +6,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
#include <boost/operators.hpp>
+#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace date_time {
@@ -19,11 +20,12 @@
//! Duration type with date level resolution
template<class duration_rep_traits>
class date_duration : private
- boost::less_than_comparable<date_duration< duration_rep_traits>
- , boost::equality_comparable< date_duration< duration_rep_traits>
- , boost::addable< date_duration< duration_rep_traits>
- , boost::subtractable< date_duration< duration_rep_traits>
- > > > >
+ boost::less_than_comparable1< date_duration< duration_rep_traits >
+ , boost::equality_comparable1< date_duration< duration_rep_traits >
+ , boost::addable1< date_duration< duration_rep_traits >
+ , boost::subtractable1< date_duration< duration_rep_traits >
+ , boost::dividable2< date_duration< duration_rep_traits >, int
+ > > > > >
{
public:
typedef typename duration_rep_traits::int_type duration_rep_type;
@@ -80,40 +82,37 @@
* so this will not compile */
//! Subtract another duration -- result is signed
- date_duration operator-=(const date_duration& rhs)
+ date_duration& operator-=(const date_duration& rhs)
{
//days_ -= rhs.days_;
days_ = days_ - rhs.days_;
return *this;
}
//! Add a duration -- result is signed
- date_duration operator+=(const date_duration& rhs)
+ date_duration& operator+=(const date_duration& rhs)
{
days_ = days_ + rhs.days_;
return *this;
}
//! unary- Allows for dd = -date_duration(2); -> dd == -2
- date_duration operator-()const
+ date_duration operator-() const
{
return date_duration<duration_rep_traits>(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
- date_duration<duration_rep_traits> operator/=(int divisor)
+ date_duration& operator/=(int divisor)
{
days_ = days_ / divisor;
return *this;
}
- date_duration<duration_rep_traits> operator/(int divisor)
- {
- return date_duration<duration_rep_traits>(days_ / divisor);
- }
//! return sign information
bool is_negative() const
{
return days_ < 0;
}
+
private:
duration_rep days_;
};
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,28 +2,32 @@
#define _DATE_TIME_DATE_FACET__HPP___
/* Copyright (c) 2004-2005 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: Martin Andrian, Jeff Garland, Bart Garst
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-04 12:18:56 +0100 (Thu, 04 Jun 2009) $
*/
-
-#include "boost/algorithm/string/replace.hpp"
-#include "boost/date_time/period.hpp"
-#include "boost/date_time/special_values_formatter.hpp"
-#include "boost/date_time/period_formatter.hpp"
-#include "boost/date_time/period_parser.hpp"
-#include "boost/date_time/date_generator_formatter.hpp"
-#include "boost/date_time/date_generator_parser.hpp"
-#include "boost/date_time/format_date_parser.hpp"
+#include <locale>
#include <string>
#include <vector>
+#include <iterator> // ostreambuf_iterator
+#include <boost/throw_exception.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/period.hpp>
+#include <boost/date_time/special_defs.hpp>
+#include <boost/date_time/special_values_formatter.hpp>
+#include <boost/date_time/period_formatter.hpp>
+#include <boost/date_time/period_parser.hpp>
+#include <boost/date_time/date_generator_formatter.hpp>
+#include <boost/date_time/date_generator_parser.hpp>
+#include <boost/date_time/format_date_parser.hpp>
namespace boost { namespace date_time {
-
+
/*! Class that provides format based I/O facet for date types.
*
* This class allows the formatting of dates by using format string.
@@ -40,7 +44,7 @@
* Default weekday format == %a
*/
template <class date_type,
- class CharT,
+ class CharT,
class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
class date_facet : public std::locale::facet {
public:
@@ -77,9 +81,9 @@
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
-
- explicit date_facet(::size_t a_ref = 0)
- : std::locale::facet(a_ref),
+
+ explicit date_facet(::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
//m_format(standard_format_specifier)
m_format(default_date_format),
m_month_format(short_month_format),
@@ -88,22 +92,22 @@
explicit date_facet(const char_type* format_str,
const input_collection_type& short_names,
- ::size_t ref_count = 0)
- : std::locale::facet(ref_count),
+ ::size_t ref_count = 0)
+ : std::locale::facet(ref_count),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
- m_month_short_names(short_names)
+ m_month_short_names(short_names)
{}
-
- explicit date_facet(const char_type* format_str,
- period_formatter_type per_formatter = period_formatter_type(),
+
+ explicit date_facet(const char_type* format_str,
+ period_formatter_type per_formatter = period_formatter_type(),
special_values_formatter_type sv_formatter = special_values_formatter_type(),
date_gen_formatter_type dg_formatter = date_gen_formatter_type(),
::size_t ref_count = 0)
- : std::locale::facet(ref_count),
- m_format(format_str),
+ : std::locale::facet(ref_count),
+ m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_period_formatter(per_formatter),
@@ -127,11 +131,11 @@
void weekday_format(const char_type* const format_str) {
m_weekday_format = format_str;
}
-
+
void period_formatter(period_formatter_type per_formatter) {
m_period_formatter= per_formatter;
}
- void special_values_formatter(const special_values_formatter_type& svf)
+ void special_values_formatter(const special_values_formatter_type& svf)
{
m_special_values_formatter = svf;
}
@@ -160,24 +164,24 @@
m_date_gen_formatter.elements(new_strings, beg_pos);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const date_type& d) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const date_type& d) const
{
- if (d.is_special()) {
+ if (d.is_special()) {
return do_put_special(next, a_ios, fill_char, d.as_special());
}
//The following line of code required the date to support a to_tm function
return do_put_tm(next, a_ios, fill_char, to_tm(d), m_format);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const duration_type& dd) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const duration_type& dd) const
{
- if (dd.is_special()) {
+ if (dd.is_special()) {
return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
}
@@ -195,164 +199,148 @@
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const month_type& m) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const month_type& m) const
{
- //if (d.is_special()) {
+ //if (d.is_special()) {
// return do_put_special(next, a_ios, fill_char, d.as_special());
//}
//The following line of code required the date to support a to_tm function
- tm dtm;
- init_tm(dtm);
- dtm.tm_mon = m -1;
+ std::tm dtm = {};
+ dtm.tm_mon = m - 1;
return do_put_tm(next, a_ios, fill_char, dtm, m_month_format);
}
//! puts the day of month
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const day_type& day) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const day_type& day) const
{
- tm dtm;
- init_tm(dtm);
+ std::tm dtm = {};
dtm.tm_mday = day.as_number();
char_type tmp[3] = {'%','d'};
string_type temp_format(tmp);
return do_put_tm(next, a_ios, fill_char, dtm, temp_format);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const day_of_week_type& dow) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const day_of_week_type& dow) const
{
- //if (d.is_special()) {
+ //if (d.is_special()) {
// return do_put_special(next, a_ios, fill_char, d.as_special());
//}
//The following line of code required the date to support a to_tm function
- tm dtm;
- init_tm(dtm);
+ std::tm dtm = {};
dtm.tm_wday = dow;
return do_put_tm(next, a_ios, fill_char, dtm, m_weekday_format);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const period_type& p) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const period_type& p) const
{
return m_period_formatter.put_period(next, a_ios, fill_char, p, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const partial_date_type& pd) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const partial_date_type& pd) const
{
return m_date_gen_formatter.put_partial_date(next, a_ios, fill_char, pd, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const nth_kday_type& nkd) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const nth_kday_type& nkd) const
{
return m_date_gen_formatter.put_nth_kday(next, a_ios, fill_char, nkd, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const first_kday_type& fkd) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const first_kday_type& fkd) const
{
return m_date_gen_formatter.put_first_kday(next, a_ios, fill_char, fkd, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const last_kday_type& lkd) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const last_kday_type& lkd) const
{
return m_date_gen_formatter.put_last_kday(next, a_ios, fill_char, lkd, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const kday_before_type& fkb) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const kday_before_type& fkb) const
{
return m_date_gen_formatter.put_kday_before(next, a_ios, fill_char, fkb, *this);
}
- OutItrT put(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
- const kday_after_type& fka) const
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const kday_after_type& fka) const
{
return m_date_gen_formatter.put_kday_after(next, a_ios, fill_char, fka, *this);
}
-
+
protected:
- //! Helper function to initialize all fields in a tm struct
- tm init_tm(tm& tm_value) const
- {
- tm_value.tm_sec = 0; /* seconds */
- tm_value.tm_min = 0; /* minutes */
- tm_value.tm_hour = 0; /* hours */
- tm_value.tm_mday = 0; /* day of the month */
- tm_value.tm_mon = 0; /* month */
- tm_value.tm_year = 0; /* year */
- tm_value.tm_wday = 0; /* day of the week */
- tm_value.tm_yday = 0; /* day in the year */
- tm_value.tm_isdst = 0; /* daylight saving time */
- return tm_value;
- }
- virtual OutItrT do_put_special(OutItrT next,
- std::ios_base& /*a_ios*/,
- char_type /*fill_char*/,
- const boost::date_time::special_values sv) const
+ virtual OutItrT do_put_special(OutItrT next,
+ std::ios_base& /*a_ios*/,
+ char_type /*fill_char*/,
+ const boost::date_time::special_values sv) const
{
m_special_values_formatter.put_special(next, sv);
return next;
}
- virtual OutItrT do_put_tm(OutItrT next,
- std::ios_base& a_ios,
- char_type fill_char,
+ virtual OutItrT do_put_tm(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
const tm& tm_value,
- string_type a_format) const
+ string_type a_format) const
{
// update format string with custom names
if (m_weekday_long_names.size()) {
- boost::algorithm::replace_all(a_format,
- long_weekday_format,
+ boost::algorithm::replace_all(a_format,
+ long_weekday_format,
m_weekday_long_names[tm_value.tm_wday]);
}
if (m_weekday_short_names.size()) {
- boost::algorithm::replace_all(a_format,
- short_weekday_format,
+ boost::algorithm::replace_all(a_format,
+ short_weekday_format,
m_weekday_short_names[tm_value.tm_wday]);
}
if (m_month_long_names.size()) {
- boost::algorithm::replace_all(a_format,
- long_month_format,
+ boost::algorithm::replace_all(a_format,
+ long_month_format,
m_month_long_names[tm_value.tm_mon]);
}
if (m_month_short_names.size()) {
- boost::algorithm::replace_all(a_format,
- short_month_format,
+ boost::algorithm::replace_all(a_format,
+ short_month_format,
m_month_short_names[tm_value.tm_mon]);
}
// use time_put facet to create final string
- return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
- fill_char,
+ const char_type* p_format = a_format.c_str();
+ return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
+ fill_char,
&tm_value,
- &*a_format.begin(),
- &*a_format.begin()+a_format.size());
+ p_format,
+ p_format + a_format.size());
}
protected:
string_type m_format;
@@ -371,51 +359,51 @@
template <class date_type, class CharT, class OutItrT>
std::locale::id date_facet<date_type, CharT, OutItrT>::id;
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
- date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
{'%', 'x' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
- date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
{'%', 'Y', '%', 'm', '%', 'd' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
- date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_facet<date_type, CharT, OutItrT>::char_type
- date_facet<date_type, CharT, OutItrT>::default_date_format[9] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::default_date_format[9] =
{'%','Y','-','%','b','-','%','d'};
//! Input facet
template <class date_type,
- class CharT,
+ class CharT,
class InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
class date_input_facet : public std::locale::facet {
public:
@@ -429,7 +417,7 @@
typedef std::basic_string<CharT> string_type;
typedef CharT char_type;
typedef boost::date_time::period_parser<date_type, CharT> period_parser_type;
- typedef boost::date_time::special_values_parser<date_type,CharT> special_values_parser_type;
+ typedef boost::date_time::special_values_parser<date_type,CharT> special_values_parser_type;
typedef std::vector<std::basic_string<CharT> > input_collection_type;
typedef format_date_parser<date_type, CharT> format_date_parser_type;
// date_generators stuff goes here
@@ -453,9 +441,9 @@
static const char_type iso_format_extended_specifier[9];
static const char_type default_date_format[9]; // YYYY-Mon-DD
static std::locale::id id;
-
- explicit date_input_facet(::size_t a_ref = 0)
- : std::locale::facet(a_ref),
+
+ explicit date_input_facet(::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
m_format(default_date_format),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
@@ -465,8 +453,8 @@
{}
explicit date_input_facet(const string_type& format_str,
- ::size_t a_ref = 0)
- : std::locale::facet(a_ref),
+ ::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
@@ -513,7 +501,7 @@
void year_format(const char_type* const format_str) {
m_year_format = format_str;
}
-
+
void period_parser(period_parser_type per_parser) {
m_period_parser = per_parser;
}
@@ -549,7 +537,7 @@
const string_type& before,
const string_type& after,
const string_type& of)
-
+
{
m_date_gen_parser.element_strings(first,second,third,fourth,fifth,last,before,after,of);
}
@@ -559,68 +547,68 @@
m_sv_parser = sv_parser;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& /*a_ios*/,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
date_type& d) const
{
d = m_parser.parse_date(from, to, m_format, m_sv_parser);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& /*a_ios*/,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
month_type& m) const
{
m = m_parser.parse_month(from, to, m_month_format);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& /*a_ios*/,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
day_of_week_type& wd) const
{
wd = m_parser.parse_weekday(from, to, m_weekday_format);
return from;
}
//! Expects 1 or 2 digit day range: 1-31
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& /*a_ios*/,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
day_type& d) const
{
d = m_parser.parse_var_day_of_month(from, to);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& /*a_ios*/,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
year_type& y) const
{
y = m_parser.parse_year(from, to, m_year_format);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
duration_type& dd) const
{
// skip leading whitespace
- while(std::isspace(*from) && from != to) { ++from; }
-
- /* num_get.get() will always consume the first character if it
- * is a sign indicator (+/-). Special value strings may begin
+ while(std::isspace(*from) && from != to) { ++from; }
+
+ /* num_get.get() will always consume the first character if it
+ * is a sign indicator (+/-). Special value strings may begin
* with one of these signs so we'll need a copy of it
* in case num_get.get() fails. */
- char_type c = '\0';
+ char_type c = '\0';
// TODO Are these characters somewhere in the locale?
- if(*from == '-' || *from == '+') {
+ if(*from == '-' || *from == '+') {
c = *from;
}
typedef std::num_get<CharT, InItrT> num_get;
typename duration_type::duration_rep_type val = 0;
std::ios_base::iostate err = std::ios_base::goodbit;
-
+
if (std::has_facet<num_get>(a_ios.getloc())) {
from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
}
@@ -638,67 +626,68 @@
}
m_sv_parser.match(from, to, mr);
if(mr.current_match == match_results::PARSE_ERROR) {
- throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return from); // should never reach
}
- dd = duration_type(static_cast<special_values>(mr.current_match));
+ dd = duration_type(static_cast<special_values>(mr.current_match));
}
else {
dd = duration_type(val);
}
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
period_type& p) const
{
- p = m_period_parser.get_period(from, to, a_ios, p, duration_type::unit(), *this);
+ p = m_period_parser.get_period(from, to, a_ios, p, duration_type::unit(), *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
nth_kday_type& nkd) const
{
nkd = m_date_gen_parser.get_nth_kday_type(from, to, a_ios, *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
partial_date_type& pd) const
{
pd = m_date_gen_parser.get_partial_date_type(from, to, a_ios, *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
first_kday_type& fkd) const
{
fkd = m_date_gen_parser.get_first_kday_type(from, to, a_ios, *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
last_kday_type& lkd) const
{
lkd = m_date_gen_parser.get_last_kday_type(from, to, a_ios, *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
kday_before_type& fkb) const
{
fkb = m_date_gen_parser.get_kday_before_type(from, to, a_ios, *this);
return from;
}
- InItrT get(InItrT& from,
- InItrT& to,
- std::ios_base& a_ios,
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
kday_after_type& fka) const
{
fka = m_date_gen_parser.get_kday_after_type(from, to, a_ios, *this);
@@ -721,52 +710,52 @@
template <class date_type, class CharT, class OutItrT>
std::locale::id date_input_facet<date_type, CharT, OutItrT>::id;
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::four_digit_year_format[3] = {'%','Y'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::two_digit_year_format[3] = {'%','y'};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
- date_input_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
{'%', 'x' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
- date_input_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
{'%', 'Y', '%', 'm', '%', 'd' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
- date_input_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
- template <class date_type, class CharT, class OutItrT>
- const typename date_input_facet<date_type, CharT, OutItrT>::char_type
- date_input_facet<date_type, CharT, OutItrT>::default_date_format[9] =
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::default_date_format[9] =
{'%','Y','-','%','b','-','%','d'};
} } // namespaces
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 19:04:15 +0000 (Thu, 13 Nov 2008) $
*/
#include <iostream>
@@ -63,6 +63,7 @@
//! Default format elements used
date_generator_formatter()
{
+ phrase_strings.reserve(number_of_phrase_elements);
phrase_strings.push_back(string_type(first_string));
phrase_strings.push_back(string_type(second_string));
phrase_strings.push_back(string_type(third_string));
@@ -75,25 +76,26 @@
}
//! Constructor that allows for a custom set of phrase elements
- date_generator_formatter(const string_type& first,
- const string_type& second,
- const string_type& third,
- const string_type& fourth,
- const string_type& fifth,
- const string_type& last,
- const string_type& before,
- const string_type& after,
- const string_type& of)
+ date_generator_formatter(const string_type& first_str,
+ const string_type& second_str,
+ const string_type& third_str,
+ const string_type& fourth_str,
+ const string_type& fifth_str,
+ const string_type& last_str,
+ const string_type& before_str,
+ const string_type& after_str,
+ const string_type& of_str)
{
- phrase_strings.push_back(string_type(first_string));
- phrase_strings.push_back(string_type(second_string));
- phrase_strings.push_back(string_type(third_string));
- phrase_strings.push_back(string_type(fourth_string));
- phrase_strings.push_back(string_type(fifth_string));
- phrase_strings.push_back(string_type(last_string));
- phrase_strings.push_back(string_type(before_string));
- phrase_strings.push_back(string_type(after_string));
- phrase_strings.push_back(string_type(of_string));
+ phrase_strings.reserve(number_of_phrase_elements);
+ phrase_strings.push_back(first_str);
+ phrase_strings.push_back(second_str);
+ phrase_strings.push_back(third_str);
+ phrase_strings.push_back(fourth_str);
+ phrase_strings.push_back(fifth_str);
+ phrase_strings.push_back(last_str);
+ phrase_strings.push_back(before_str);
+ phrase_strings.push_back(after_str);
+ phrase_strings.push_back(of_str);
}
//! Replace the set of phrase elements with those contained in new_strings
@@ -148,7 +150,7 @@
facet.put(next, a_ios, a_fill, nkd.month());
return next;
}
-
+
//! Put a first_day_of_the_week_in_month => "first weekday of month"
template<class facet_type>
OutItrT put_first_kday(OutItrT next, std::ios_base& a_ios,
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,15 +7,17 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-
-#include "boost/date_time/string_parse_tree.hpp"
-#include "boost/date_time/date_generators.hpp"
-#include "boost/date_time/format_date_parser.hpp"
#include <string>
#include <vector>
+#include <iterator> // istreambuf_iterator
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/string_parse_tree.hpp>
+#include <boost/date_time/date_generators.hpp>
+#include <boost/date_time/format_date_parser.hpp>
namespace boost { namespace date_time {
@@ -66,10 +68,10 @@
static const char_type last_string[5];
static const char_type before_string[8];
static const char_type after_string[6];
- static const char_type of_string[3];
-
+ static const char_type of_string[3];
+
enum phrase_elements {first=0, second, third, fourth, fifth, last,
- before, after, of, number_of_phrase_elements};
+ before, after, of, number_of_phrase_elements};
//! Creates a date_generator_parser with the default set of "element_strings"
date_generator_parser()
@@ -96,7 +98,7 @@
const string_type& after_str,
const string_type& of_str)
{
- element_strings(first_str, second_str, third_str, fourth_str, fifth_str,
+ element_strings(first_str, second_str, third_str, fourth_str, fifth_str,
last_str, before_str, after_str, of_str);
}
@@ -128,19 +130,18 @@
{
m_element_strings = parse_tree_type(col, this->first); // enum first
}
-
//! returns partial_date parsed from stream
template<class facet_type>
partial_date_type
- get_partial_date_type(stream_itr_type& sitr,
+ get_partial_date_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
day_type d(1);
month_type m(1);
facet.get(sitr, stream_end, a_ios, d);
@@ -152,18 +153,18 @@
//! returns nth_kday_of_week parsed from stream
template<class facet_type>
nth_kday_type
- get_nth_kday_type(stream_itr_type& sitr,
+ get_nth_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
typename nth_kday_type::week_num wn;
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
-
+
match_results mr = m_element_strings.match(sitr, stream_end);
switch(mr.current_match) {
case first : { wn = nth_kday_type::first; break; }
@@ -173,98 +174,98 @@
case fifth : { wn = nth_kday_type::fifth; break; }
default:
{
- throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
- break;
+ boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(wn = nth_kday_type::first);
}
} // week num
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
-
+
return nth_kday_type(wn, wd, m);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
first_kday_type
- get_first_kday_type(stream_itr_type& sitr,
+ get_first_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
-
+
extract_element(sitr, stream_end, first); // "first" element
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
-
-
+
+
return first_kday_type(wd, m);
}
//! returns last_kday_of_week parsed from stream
template<class facet_type>
last_kday_type
- get_last_kday_type(stream_itr_type& sitr,
+ get_last_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
-
+
extract_element(sitr, stream_end, last); // "last" element
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
-
-
+
+
return last_kday_type(wd, m);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
kday_before_type
- get_kday_before_type(stream_itr_type& sitr,
+ get_kday_before_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
day_of_week_type wd(0); // no default constructor
-
+
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, before);// "before" element
-
+
return kday_before_type(wd);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
kday_after_type
- get_kday_after_type(stream_itr_type& sitr,
+ get_kday_after_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
- std::ios_base& a_ios,
+ std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
day_of_week_type wd(0); // no default constructor
-
+
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, after); // "after" element
-
+
return kday_after_type(wd);
}
@@ -277,13 +278,13 @@
typename date_generator_parser::phrase_elements ele) const
{
// skip leading whitespace
- while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
match_results mr = m_element_strings.match(sitr, stream_end);
if(mr.current_match != ele) {
- throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
}
}
-
+
};
template<class date_type, class CharT>
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,16 +6,18 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-08 17:54:38 +0000 (Sat, 08 Nov 2008) $
*/
/*! @file date_generators.hpp
Definition and implementation of date algorithm templates
*/
+
#include <stdexcept>
#include <sstream>
-#include "boost/date_time/date.hpp"
-#include "boost/date_time/compiler_config.hpp"
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/date.hpp>
+#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace date_time {
@@ -99,13 +101,11 @@
date_type get_date(year_type y) const
{
if((day_ == 29) && (month_ == 2) && !(calendar_type::is_leap_year(y))) {
- std::stringstream ss("");
+ std::ostringstream ss;
ss << "No Feb 29th in given year of " << y << ".";
- throw std::invalid_argument(ss.str());
- //return date_type(1,1,1); // should never reach
- } else {
- return date_type(y, month_, day_);
+ boost::throw_exception(std::invalid_argument(ss.str()));
}
+ return date_type(y, month_, day_);
}
date_type operator()(year_type y) const
{
@@ -141,7 +141,7 @@
* Dec-31 == "365" */
virtual std::string to_string() const
{
- std::stringstream ss;
+ std::ostringstream ss;
date_type d(2004, month_, day_);
unsigned short c = d.day_of_year();
c--; // numbered 0-365 while day_of_year is 1 based...
@@ -154,6 +154,9 @@
};
+ //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
+ BOOST_DATE_TIME_DECL const char* nth_as_str(int n);
+
//! Useful generator functor for finding holidays
/*! Based on the idea in Cal. Calc. for finding holidays that are
* the 'first Monday of September'. When instantiated with
@@ -229,7 +232,7 @@
/*! Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April. */
virtual std::string to_string() const
{
- std::stringstream ss;
+ std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< static_cast<int>(wn_) << '.'
@@ -242,9 +245,6 @@
day_of_week_type dow_;
};
- //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
- BOOST_DATE_TIME_DECL const char* nth_as_str(int n);
-
//! Useful generator functor for finding holidays and daylight savings
/*! Similar to nth_kday_of_month, but requires less paramters
* \ingroup date_alg
@@ -275,7 +275,7 @@
d = d + one_day;
}
return d;
- }
+ }
// added for streaming
month_type month() const
{
@@ -289,7 +289,7 @@
/*! Returns a string formatted as "M4.1.0" ==> 1st Sunday in April. */
virtual std::string to_string() const
{
- std::stringstream ss;
+ std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< 1 << '.'
@@ -350,7 +350,7 @@
/*! Returns a string formatted as "M4.5.0" ==> last Sunday in April. */
virtual std::string to_string() const
{
- std::stringstream ss;
+ std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< 5 << '.'
Modified: sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,22 +2,22 @@
#define _DATE_TIME_DATE_PARSING_HPP___
/* Copyright (c) 2002,2003,2005 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
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-01 10:51:34 +0100 (Mon, 01 Jun 2009) $
*/
-#include "boost/tokenizer.hpp"
-#include "boost/lexical_cast.hpp"
-#include "boost/date_time/compiler_config.hpp"
-#include "boost/date_time/parse_format_base.hpp"
#include <string>
#include <iterator>
#include <algorithm>
+#include <boost/tokenizer.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/parse_format_base.hpp>
-#if defined(BOOST_NO_STD_LOCALE)
+#if defined(BOOST_DATE_TIME_NO_LOCALE)
#include <cctype> // ::tolower(int)
#else
#include <locale> // std::tolower(char, locale)
@@ -29,43 +29,43 @@
//! A function to replace the std::transform( , , ,tolower) construct
/*! This function simply takes a string, and changes all the characters
* in that string to lowercase (according to the default system locale).
- * In the event that a compiler does not support locales, the old
+ * In the event that a compiler does not support locales, the old
* C style tolower() is used.
*/
inline
- std::string
- convert_to_lower(const std::string& inp) {
- std::string tmp;
- unsigned i = 0;
-#if defined(BOOST_NO_STD_LOCALE)
- while(i < inp.length()) {
- tmp += static_cast<char>(std::tolower(inp.at(i++)));
+ std::string
+ convert_to_lower(std::string inp)
+ {
+#if !defined(BOOST_DATE_TIME_NO_LOCALE)
+ const std::locale loc(std::locale::classic());
+#endif
+ std::string::size_type i = 0, n = inp.length();
+ for (; i < n; ++i) {
+ inp[i] =
+#if defined(BOOST_DATE_TIME_NO_LOCALE)
+ static_cast<char>(std::tolower(inp[i]));
#else
- static const std::locale loc(std::locale::classic());
- while(i < inp.length()) {
// tolower and others were brought in to std for borland >= v564
// in compiler_config.hpp
- std::string::value_type c(inp.at(i++));
- tmp += std::tolower(c, loc);
+ std::tolower(inp[i], loc);
#endif
-
- }
- return tmp;
}
-
+ return inp;
+ }
+
//! Helper function for parse_date.
/* Used by-value parameter because we change the string and may
* want to preserve the original argument */
template<class month_type>
- unsigned short
- month_str_to_ushort(std::string s) {
+ inline unsigned short
+ month_str_to_ushort(std::string const& s) {
if((s.at(0) >= '0') && (s.at(0) <= '9')) {
return boost::lexical_cast<unsigned short>(s);
- }
+ }
else {
- s = convert_to_lower(s);
+ std::string str = convert_to_lower(s);
typename month_type::month_map_ptr_type ptr = month_type::get_month_map_ptr();
- typename month_type::month_map_type::iterator iter = ptr->find(s);
+ typename month_type::month_map_type::iterator iter = ptr->find(str);
if(iter != ptr->end()) { // required for STLport
return iter->second;
}
@@ -74,44 +74,45 @@
}
//! Find index of a string in either of 2 arrays
- /*! find_match searches both arrays for a match to 's'. Indexing of the
- * arrays is from 0 to 'limit'. The index of the match is returned.
+ /*! find_match searches both arrays for a match to 's'. Both arrays
+ * must contain 'size' elements. The index of the match is returned.
+ * If no match is found, 'size' is returned.
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
- * 'limit' can be sent in with: greg_month::max(),
- * greg_weekday::max() or date_time::NumSpecialValues */
+ * 'size' can be sent in with: (greg_month::max)() (which 12),
+ * (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues */
template<class charT>
- short find_match(const charT* const* short_names,
- const charT* const* long_names,
- short limit,
+ short find_match(const charT* const* short_names,
+ const charT* const* long_names,
+ short size,
const std::basic_string<charT>& s) {
- for(short i = 0; i <= limit; ++i){
+ for(short i = 0; i < size; ++i){
if(short_names[i] == s || long_names[i] == s){
return i;
}
}
- return static_cast<short>(limit + 1); // not-found, return a value out of range
+ return size; // not-found, return a value out of range
}
-
+
//! Generic function to parse a delimited date (eg: 2002-02-10)
/*! Accepted formats are: "2003-02-10" or " 2003-Feb-10" or
- * "2003-Feburary-10"
- * The order in which the Month, Day, & Year appear in the argument
- * string can be accomodated by passing in the appropriate ymd_order_spec
+ * "2003-Feburary-10"
+ * The order in which the Month, Day, & Year appear in the argument
+ * string can be accomodated by passing in the appropriate ymd_order_spec
*/
template<class date_type>
date_type
parse_date(const std::string& s, int order_spec = ymd_order_iso) {
- std::string spec_str("");
+ std::string spec_str;
if(order_spec == ymd_order_iso) {
spec_str = "ymd";
- }
+ }
else if(order_spec == ymd_order_dmy) {
spec_str = "dmy";
- }
+ }
else { // (order_spec == ymd_order_us)
spec_str = "mdy";
}
-
+
typedef typename date_type::year_type year_type;
typedef typename date_type::month_type month_type;
unsigned pos = 0;
@@ -128,21 +129,21 @@
const char sep_char[] = {',','-','.',' ','/','\0'};
char_separator_type sep(sep_char);
tokenizer tok(s,sep);
- for(tokenizer_iterator beg=tok.begin();
- beg!=tok.end() && pos < spec_str.size();
+ for(tokenizer_iterator beg=tok.begin();
+ beg!=tok.end() && pos < spec_str.size();
++beg, ++pos) {
switch(spec_str.at(pos)) {
- case 'y':
+ case 'y':
{
year = boost::lexical_cast<unsigned short>(*beg);
break;
}
- case 'm':
+ case 'm':
{
month = month_str_to_ushort<month_type>(*beg);
break;
}
- case 'd':
+ case 'd':
{
day = boost::lexical_cast<unsigned short>(*beg);
break;
@@ -151,7 +152,7 @@
}
return date_type(year, month, day);
}
-
+
//! Generic function to parse undelimited date (eg: 20020201)
template<class date_type>
date_type
@@ -161,16 +162,16 @@
typedef typename date_type::year_type year_type;
//typename date_type::ymd_type ymd((year_type::min)(),1,1);
unsigned short y = 0, m = 0, d = 0;
-
- /* The two bool arguments state that parsing will not wrap
- * (only the first 8 characters will be parsed) and partial
- * strings will not be parsed.
+
+ /* The two bool arguments state that parsing will not wrap
+ * (only the first 8 characters will be parsed) and partial
+ * strings will not be parsed.
* Ex:
* "2005121" will parse 2005 & 12, but not the "1" */
boost::offset_separator osf(offsets, offsets+3, false, false);
-
- typedef typename boost::tokenizer<boost::offset_separator,
- std::basic_string<char>::const_iterator,
+
+ typedef typename boost::tokenizer<boost::offset_separator,
+ std::basic_string<char>::const_iterator,
std::basic_string<char> > tokenizer_type;
tokenizer_type tok(s, osf);
for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) {
@@ -184,34 +185,34 @@
}
return date_type(y,m,d);
}
-
+
//! Helper function for 'date gregorian::from_stream()'
/*! Creates a string from the iterators that reference the
- * begining & end of a char[] or string. All elements are
+ * begining & end of a char[] or string. All elements are
* used in output string */
template<class date_type, class iterator_type>
- inline
+ inline
date_type
- from_stream_type(iterator_type& beg,
- iterator_type& end,
- char)
+ from_stream_type(iterator_type& beg,
+ iterator_type const& end,
+ char)
{
- std::stringstream ss("");
+ std::ostringstream ss;
while(beg != end) {
ss << *beg++;
}
return parse_date<date_type>(ss.str());
}
-
+
//! Helper function for 'date gregorian::from_stream()'
/*! Returns the first string found in the stream referenced by the
* begining & end iterators */
template<class date_type, class iterator_type>
- inline
+ inline
date_type
- from_stream_type(iterator_type& beg,
- iterator_type& end,
- std::string)
+ from_stream_type(iterator_type& beg,
+ iterator_type const& /* end */,
+ std::string const&)
{
return parse_date<date_type>(*beg);
}
@@ -220,22 +221,30 @@
* parse_date<>()? In the mean time this gets us started... */
//! Helper function for 'date gregorian::from_stream()'
/*! Creates a string from the iterators that reference the
- * begining & end of a wstring. All elements are
+ * begining & end of a wstring. All elements are
* used in output string */
template<class date_type, class iterator_type>
- inline
- date_type from_stream_type(iterator_type& beg,
- iterator_type& end,
- wchar_t)
+ inline
+ date_type from_stream_type(iterator_type& beg,
+ iterator_type const& end,
+ wchar_t)
{
- std::stringstream ss("");
- while(beg != end) {
+ std::ostringstream ss;
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
- ss << std::use_facet<std::ctype<wchar_t> >(std::locale()).narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
+ std::locale loc;
+ std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
+ while(beg != end) {
+ ss << fac.narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
+ }
#else
- ss << ss.narrow(*beg++, 'X');
-#endif
+ while(beg != end) {
+ char c = 'X'; // 'X' will cause exception to be thrown
+ const wchar_t wc = *beg++;
+ if (wc >= 0 && wc <= 127)
+ c = static_cast< char >(wc);
+ ss << c;
}
+#endif
return parse_date<date_type>(ss.str());
}
#ifndef BOOST_NO_STD_WSTRING
@@ -243,21 +252,29 @@
/*! Creates a string from the first wstring found in the stream
* referenced by the begining & end iterators */
template<class date_type, class iterator_type>
- inline
+ inline
date_type
- from_stream_type(iterator_type& beg,
- iterator_type& end,
- std::wstring) {
+ from_stream_type(iterator_type& beg,
+ iterator_type const& /* end */,
+ std::wstring const&) {
std::wstring ws = *beg;
- std::stringstream ss("");
+ std::ostringstream ss;
std::wstring::iterator wsb = ws.begin(), wse = ws.end();
- while(wsb != wse) {
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
- ss << std::use_facet<std::ctype<wchar_t> >(std::locale()).narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
+ std::locale loc;
+ std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
+ while(wsb != wse) {
+ ss << fac.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
+ }
#else
- ss << ss.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
-#endif
+ while(wsb != wse) {
+ char c = 'X'; // 'X' will cause exception to be thrown
+ const wchar_t wc = *wsb++;
+ if (wc >= 0 && wc <= 127)
+ c = static_cast< char >(wc);
+ ss << c;
}
+#endif
return parse_date<date_type>(ss.str());
}
#endif // BOOST_NO_STD_WSTRING
@@ -266,30 +283,30 @@
#else
//! function called by wrapper functions: date_period_from_(w)string()
template<class date_type, class charT>
- period<date_type, typename date_type::duration_type>
+ period<date_type, typename date_type::duration_type>
from_simple_string_type(const std::basic_string<charT>& s){
typedef typename std::basic_string<charT>::traits_type traits_type;
typedef typename boost::char_separator<charT, traits_type> char_separator;
- typedef typename boost::tokenizer<char_separator,
- typename std::basic_string<charT>::const_iterator,
+ typedef typename boost::tokenizer<char_separator,
+ typename std::basic_string<charT>::const_iterator,
std::basic_string<charT> > tokenizer;
const charT sep_list[4] = {'[','/',']','\0'};
char_separator sep(sep_list);
tokenizer tokens(s, sep);
- typename tokenizer::iterator tok_it = tokens.begin();
+ typename tokenizer::iterator tok_it = tokens.begin();
std::basic_string<charT> date_string = *tok_it;
// get 2 string iterators and generate a date from them
- typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
- date_string_end = date_string.end();
+ typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
+ date_string_end = date_string.end();
typedef typename std::iterator_traits<typename std::basic_string<charT>::iterator>::value_type value_type;
date_type d1 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
date_string = *(++tok_it); // next token
- date_string_start = date_string.begin(), date_string_end = date_string.end();
+ date_string_start = date_string.begin(), date_string_end = date_string.end();
date_type d2 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
- return period<date_type, typename date_type::duration_type>(d1, d2);
+ return period<date_type, typename date_type::duration_type>(d1, d2);
}
#endif
-
+
} } //namespace date_time
Modified: sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,70 +6,162 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-04 11:07:42 +0100 (Thu, 04 Jun 2009) $
*/
/*! @file filetime_functions.hpp
- * Function(s) for converting between a FILETIME structure and a
+ * Function(s) for converting between a FILETIME structure and a
* time object. This file is only available on systems that have
* BOOST_HAS_FTIME defined.
*/
#include <boost/date_time/compiler_config.hpp>
+
#if defined(BOOST_HAS_FTIME) // skip this file if no FILETIME
-#include <windows.h>
+
+#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>
namespace boost {
+
namespace date_time {
+namespace winapi {
- //! Create a time object from an initialized FILETIME struct.
- /*! Create a time object from an initialized FILETIME struct.
- * A FILETIME struct holds 100-nanosecond units (0.0000001). When
- * built with microsecond resolution the FILETIME's sub second value
- * will be truncated. Nanosecond resolution has no truncation. */
- template<class time_type>
- inline
- time_type time_from_ftime(const FILETIME& ft){
- typedef typename time_type::date_type date_type;
- typedef typename time_type::date_duration_type date_duration_type;
- typedef typename time_type::time_duration_type time_duration_type;
-
- /* OFFSET is difference between 1970-Jan-01 & 1601-Jan-01
- * in 100-nanosecond intervals */
- uint64_t c1 = 27111902UL;
- uint64_t c2 = 3577643008UL; // issues warning without 'UL'
- const uint64_t OFFSET = (c1 << 32) + c2;
- const long sec_pr_day = 86400; // seconds per day
-
- uint64_t filetime = ft.dwHighDateTime;
- filetime <<= 32;
- filetime += ft.dwLowDateTime;
- filetime -= OFFSET; // filetime is now 100-nanos since 1970-Jan-01
-
- uint64_t sec = filetime / 10000000;
-#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
- uint64_t sub_sec = (filetime % 10000000) * 100; // nanoseconds
+#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_NO_GETSYSTEMTIMEASFILETIME)
+ system_time st;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ft);
+#else
+ GetSystemTimeAsFileTime(&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.
+ * A FILETIME struct holds 100-nanosecond units (0.0000001). When
+ * built with microsecond resolution the file_time's sub second value
+ * will be truncated. Nanosecond resolution has no truncation.
+ *
+ * \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 TimeT, typename FileTimeT >
+inline
+TimeT time_from_ftime(const FileTimeT& ft)
+{
+ typedef typename TimeT::date_type date_type;
+ typedef typename TimeT::date_duration_type date_duration_type;
+ typedef typename TimeT::time_duration_type time_duration_type;
+
+ // 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
+ // 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
+#if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
+ / 10; // microseconds since the last second
#else
- uint64_t sub_sec = (filetime % 10000000) / 10; // truncate to microseconds
+ * 100; // nanoseconds since the last second
#endif
// split sec into usable chunks: days, hours, minutes, & seconds
- long _d = sec / sec_pr_day;
- long tmp = sec % sec_pr_day;
- long _h = tmp / 3600; // sec_pr_hour
+ const uint32_t sec_per_day = 86400; // seconds per day
+ uint32_t days = static_cast< uint32_t >(sec / sec_per_day);
+ uint32_t tmp = static_cast< uint32_t >(sec % sec_per_day);
+ uint32_t hours = tmp / 3600; // sec_per_hour
tmp %= 3600;
- long _m = tmp / 60; // sec_pr_min
+ uint32_t minutes = tmp / 60; // sec_per_min
tmp %= 60;
- long _s = tmp; // seconds
+ uint32_t seconds = tmp; // seconds
- date_duration_type dd(_d);
- date_type d = date_type(1970, Jan, 01) + dd;
- return time_type(d, time_duration_type(_h, _m, _s, sub_sec));
- }
+ date_duration_type dd(days);
+ date_type d = date_type(1601, Jan, 01) + dd;
+ return TimeT(d, time_duration_type(hours, minutes, seconds, sub_sec));
+}
}} // boost::date_time
Modified: sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-05-31 13:03:41 +0100 (Sun, 31 May 2009) $
*/
@@ -17,7 +17,20 @@
#include "boost/date_time/special_values_parser.hpp"
#include <string>
#include <vector>
+#include <sstream>
+#include <iterator>
+#ifndef BOOST_NO_STDC_NAMESPACE
+# include <cctype>
+#else
+# include <ctype.h>
+#endif
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std {
+ using ::isspace;
+ using ::isdigit;
+}
+#endif
namespace boost { namespace date_time {
//! Helper function for parsing fixed length strings into integers
@@ -57,7 +70,7 @@
}
try {
i = boost::lexical_cast<int_type>(mr.cache);
- }catch(bad_lexical_cast blc){
+ }catch(bad_lexical_cast&){
// we want to return -1 if the cast fails so nothing to do here
}
return i;
@@ -87,19 +100,19 @@
inline
int_type
var_string_to_int(std::istreambuf_iterator<charT>& itr,
- std::istreambuf_iterator<charT>& /* stream_end */,
+ const std::istreambuf_iterator<charT>& stream_end,
unsigned int max_length)
{
typedef std::basic_string<charT> string_type;
unsigned int j = 0;
string_type s;
- while ((j < max_length) && std::isdigit(*itr)) {
+ while (itr != stream_end && (j < max_length) && std::isdigit(*itr)) {
s += (*itr);
- itr++;
- j++;
+ ++itr;
+ ++j;
}
int_type i = -1;
- if(s.length() != 0) {
+ if(!s.empty()) {
i = boost::lexical_cast<int_type>(s);
}
return i;
@@ -139,7 +152,7 @@
{
public:
typedef std::basic_string<charT> string_type;
- typedef std::basic_ostringstream<charT> stringstream_type;
+ typedef std::basic_istringstream<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;
@@ -216,8 +229,7 @@
const string_type& format_str,
const special_values_parser<date_type,charT>& sv_parser) const
{
- stringstream_type ss;
- ss << value;
+ stringstream_type ss(value);
stream_itr_type sitr(ss);
stream_itr_type stream_end;
return parse_date(sitr, stream_end, format_str, sv_parser);
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,72 +2,65 @@
#define _GREGORIAN__CONVERSION_HPP___
/* Copyright (c) 2004-2005 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
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-04 12:29:04 +0100 (Thu, 04 Jun 2009) $
*/
-#include <exception>
-#include "boost/date_time/gregorian/gregorian_types.hpp"
-#include "boost/date_time/c_time.hpp"
-#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
-# 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 // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
-#else
-# include <sstream>
-# include "boost/date_time/gregorian/gregorian_io.hpp"
-#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+#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)
+ std::tm to_tm(const date& d)
{
- if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){
-#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
- std::string s("tm unable to handle date value of " + to_simple_string(d));
- throw std::out_of_range(s);
-#else
- std::stringstream ss;
- ss << "tm unable to handle date value of " << d;
- throw std::out_of_range(ss.str());
-#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+ 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::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone
boost::gregorian::date::ymd_type ymd = d.year_month_day();
- datetm.tm_year = ymd.year-1900;
- datetm.tm_mon = ymd.month-1;
+ 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_hour = datetm.tm_min = datetm.tm_sec = 0;
+ 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)
+ 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),
+ 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
-
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,13 +6,14 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-#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"
+#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 {
@@ -55,7 +56,7 @@
: date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
{
if (gregorian_calendar::end_of_month_day(y, m) < d) {
- throw bad_day_of_month(std::string("Day of month is not valid for year"));
+ boost::throw_exception(bad_day_of_month(std::string("Day of month is not valid for year")));
}
}
//! Constructor from a ymd_type structure
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,33 +6,129 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-#include "boost/date_time/date_duration.hpp"
-#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
-#include "boost/date_time/date_duration_types.hpp"
-#endif
-#include "boost/date_time/int_adapter.hpp"
-
+#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
*/
- typedef date_time::date_duration<date_duration_rep> date_duration;
+ 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
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,15 +5,15 @@
* 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-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 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.hpp"
-#include "boost/date_time/date_duration_types.hpp"
+#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 {
@@ -27,7 +27,16 @@
typedef date_time::months_duration<greg_durations_config> months;
typedef date_time::years_duration<greg_durations_config> years;
- typedef date_time::weeks_duration<date_time::duration_traits_adapted> weeks;
+
+ 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
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,18 +6,21 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-22 13:40:54 +0000 (Sat, 22 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"
-#include <string>
-#include <exception>
//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 {
@@ -281,22 +284,22 @@
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::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 bc){
- std::cout << "Month exception caught" << std::endl;
+ catch(std::bad_cast&){
charT a = '\0';
- const facet_def* f = create_facet_def(a);
+ 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);
- delete(f);
+ (greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size,
+ // which is needed by find_match
}
- num += 1; // months numbered 1-12
+ ++num; // months numbered 1-12
m = greg_month(num);
return is;
@@ -323,19 +326,19 @@
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)(), s);
+ (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 bc){
- //std::cout << "Weekday exception caught" << std::endl;
+ catch(std::bad_cast&){
charT a = '\0';
- const facet_def* f = create_facet_def(a);
+ 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)(), s);
- delete(f);
+ (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
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
@@ -72,10 +72,10 @@
ar & make_nvp("date", ds);
try{
d = ::boost::gregorian::from_undelimited_string(ds);
- }catch(bad_lexical_cast be) {
+ }catch(bad_lexical_cast&) {
gregorian::special_values sv = gregorian::special_value_from_string(ds);
if(sv == gregorian::not_special) {
- throw(be); // no match found, rethrow original exception
+ throw; // no match found, rethrow original exception
}
else {
d = gregorian::date(sv);
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-06-24 09:35:07 +0100 (Tue, 24 Jun 2008) $
*/
#include "boost/date_time/constrained_value.hpp"
@@ -31,7 +31,7 @@
//! 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 os out of range 0..6")) {}
+ 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;
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,13 +6,20 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-#include "boost/date_time/date_facet.hpp"
-#include "boost/io/ios_state.hpp"
-#include <iostream>
#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 {
Modified: sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,7 +3,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-07-13 01:15:30 +0100 (Sun, 13 Jul 2008) $
*/
#ifndef NO_BOOST_DATE_TIME_INLINE
@@ -14,7 +14,7 @@
namespace boost {
namespace date_time {
//! Return the day of the week (0==Sunday, 1==Monday, etc)
- /*! Converts a the year-month-day into a day of the week number
+ /*! Converts a year-month-day into a day of the week number
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
Modified: sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
@@ -14,7 +14,9 @@
#include "boost/limits.hpp" //work around compilers without limits
#include "boost/date_time/special_defs.hpp"
#include "boost/date_time/locale_config.hpp"
-#include <iostream>
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+# include <ostream>
+#endif
namespace boost {
namespace date_time {
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,7 +5,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-05-31 15:24:25 +0100 (Sun, 31 May 2009) $
*/
@@ -18,9 +18,8 @@
//! Function that creates a tm struct from a local_date_time
inline
-tm to_tm(const local_date_time& lt) {
- tm lt_tm;
- lt_tm = posix_time::to_tm(lt.local_time());
+std::tm to_tm(const local_date_time& lt) {
+ std::tm lt_tm = posix_time::to_tm(lt.local_time());
if(lt.is_dst()){
lt_tm.tm_isdst = 1;
}
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,18 +5,20 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-
-#include "boost/date_time/time.hpp"
-#include "boost/date_time/posix_time/posix_time.hpp" //todo remove?
-#include "boost/shared_ptr.hpp"
-#include "boost/date_time/dst_rules.hpp"
-#include "boost/date_time/time_zone_base.hpp"
-#include "boost/date_time/special_defs.hpp"
#include <string>
+#include <iomanip>
#include <sstream>
+#include <stdexcept>
+#include <boost/shared_ptr.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/time.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp> //todo remove?
+#include <boost/date_time/dst_rules.hpp>
+#include <boost/date_time/time_zone_base.hpp>
+#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace local_time {
@@ -24,19 +26,19 @@
//! simple exception for reporting when STD or DST cannot be determined
struct ambiguous_result : public std::logic_error
{
- ambiguous_result (std::string _msg="") :
- std::logic_error(std::string("Daylight Savings Results are ambiguous: " + _msg)) {}
+ ambiguous_result (std::string const& msg = std::string()) :
+ std::logic_error(std::string("Daylight Savings Results are ambiguous: " + msg)) {}
};
//! simple exception for when time label given cannot exist
struct time_label_invalid : public std::logic_error
{
- time_label_invalid (std::string _msg="") :
- std::logic_error(std::string("Time label given is invalid: " + _msg)) {}
+ time_label_invalid (std::string const& msg = std::string()) :
+ std::logic_error(std::string("Time label given is invalid: " + msg)) {}
};
struct dst_not_valid: public std::logic_error
{
- dst_not_valid(std::string _msg="") :
- std::logic_error(std::string("is_dst flag does not match resulting dst for time label given: " + _msg)) {}
+ dst_not_valid(std::string const& msg = std::string()) :
+ std::logic_error(std::string("is_dst flag does not match resulting dst for time label given: " + msg)) {}
};
//TODO: I think these should be in local_date_time_base and not
@@ -110,17 +112,17 @@
// ambig occurs at end, invalid at start
if(result == invalid_time_label){
// Ex: 2:15am local on trans-in day in nyc, dst_flag irrelevant
- std::stringstream ss;
+ std::ostringstream ss;
ss << "time given: " << d << ' ' << td;
- throw time_label_invalid(ss.str());
+ boost::throw_exception(time_label_invalid(ss.str()));
}
else if(result != ambiguous && in_dst != dst_flag){
// is dst_flag accurate?
// Ex: false flag in NYC in June
- std::stringstream ss;
- ss << "flag given: " << (dst_flag ? "dst=true" : "dst=false")
- << ", dst calculated: " << (in_dst ? "dst=true" : "dst=false");
- throw dst_not_valid(ss.str());
+ std::ostringstream ss;
+ ss.setf(std::ios_base::boolalpha);
+ ss << "flag given: dst=" << dst_flag << ", dst calculated: dst=" << in_dst;
+ boost::throw_exception(dst_not_valid(ss.str()));
}
// everything checks out and conversion to utc already done
@@ -146,9 +148,9 @@
time_is_dst_result result = check_dst(d, td, tz);
if(result == ambiguous) {
if(calc_option == EXCEPTION_ON_ERROR){
- std::stringstream ss;
+ std::ostringstream ss;
ss << "time given: " << d << ' ' << td;
- throw ambiguous_result(ss.str());
+ boost::throw_exception(ambiguous_result(ss.str()));
}
else{ // NADT on error
this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
@@ -156,9 +158,9 @@
}
else if(result == invalid_time_label){
if(calc_option == EXCEPTION_ON_ERROR){
- std::stringstream ss;
+ std::ostringstream ss;
ss << "time given: " << d << ' ' << td;
- throw time_label_invalid(ss.str());
+ boost::throw_exception(time_label_invalid(ss.str()));
}
else{ // NADT on error
this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
@@ -278,7 +280,7 @@
std::string to_string() const
{
//TODO is this a temporary function ???
- std::stringstream ss;
+ std::ostringstream ss;
if(this->is_special()){
ss << utc_time();
return ss.str();
@@ -497,7 +499,7 @@
std::string zone_as_offset(const time_duration_type& td,
const std::string& separator) const
{
- std::stringstream ss;
+ std::ostringstream ss;
if(td.is_negative()) {
// a negative duration is represented as "-[h]h:mm"
// we require two digits for the hour. A positive duration
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,15 +5,18 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 19:04:15 +0000 (Thu, 13 Nov 2008) $
*/
+#include <locale>
#include <iostream>
-#include "boost/date_time/local_time/local_date_time.hpp"
-#include "boost/date_time/local_time/posix_time_zone.hpp"
-#include "boost/date_time/time_facet.hpp"
-#include "boost/date_time/string_convert.hpp"
-#include "boost/io/ios_state.hpp"
+#include <iterator> // i/ostreambuf_iterator
+#include <boost/io/ios_state.hpp>
+#include <boost/date_time/time_facet.hpp>
+#include <boost/date_time/string_convert.hpp>
+#include <boost/date_time/local_time/local_date_time.hpp>
+#include <boost/date_time/local_time/posix_time_zone.hpp>
+#include <boost/date_time/local_time/conversion.hpp> // to_tm will be needed in the facets
namespace boost {
namespace local_time {
@@ -23,7 +26,7 @@
typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,wchar_t> wlocal_time_input_facet;
typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,char> local_time_input_facet;
-
+
//! operator<< for local_date_time - see local_time docs for formatting details
template<class CharT, class TraitsT>
inline
@@ -35,7 +38,7 @@
typedef date_time::time_facet<time_type, CharT> custom_time_facet;
typedef std::time_put<CharT> std_time_facet;
std::ostreambuf_iterator<CharT> oitr(os);
-
+
if(std::has_facet<custom_time_facet>(os.getloc())) {
std::use_facet<custom_time_facet>(os.getloc()).put(oitr,
os,
@@ -60,7 +63,7 @@
operator>>(std::basic_istream<CharT, Traits>& is, local_date_time& ldt)
{
boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename local_date_time::utc_time_type utc_time_type;
@@ -69,7 +72,7 @@
// intermediate objects
std::basic_string<CharT> tz_str;
utc_time_type pt(not_a_date_time);
-
+
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_local_time(sit, str_end, is, pt, tz_str);
@@ -92,27 +95,92 @@
ldt = local_date_time(pt.date(), pt.time_of_day(), tz_ptr, local_date_time::EXCEPTION_ON_ERROR);
}
}
- catch(...) {
+ 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); }
+ 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);
- }
-
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ //! output operator for local_time_period
+ template <class CharT, class TraitsT>
+ inline
+ std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ const boost::local_time::local_time_period& p) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::time_facet<local_date_time, CharT> custom_facet;
+ typedef std::time_put<CharT> std_time_facet;
+ std::ostreambuf_iterator<CharT> oitr(os);
+ if (std::has_facet<custom_facet>(os.getloc())) {
+ std::use_facet<custom_facet>(os.getloc()).put(oitr, os, os.fill(), p);
+ }
+ else {
+ //instantiate a custom facet for dealing with 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 as some later point.
+ custom_facet* f = new custom_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(oitr, os, os.fill(), p);
+ }
+ return os;
+ }
+
+ //! input operator for local_time_period
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, boost::local_time::local_time_period& tp)
+ {
+ 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::time_input_facet<local_date_time, CharT> time_input_facet;
+
+ 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);
+ }
+ else {
+ time_input_facet* f = new time_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, tp);
+ }
+ }
+ 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 // BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,20 +5,21 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-26 15:12:17 +0000 (Wed, 26 Nov 2008) $
*/
#include <string>
#include <sstream>
-#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/time_zone_names.hpp"
-#include "boost/date_time/time_zone_base.hpp"
-#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
-#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/string_convert.hpp"
-#include "boost/date_time/time_parsing.hpp"
-#include "boost/tokenizer.hpp"
#include <stdexcept>
+#include <boost/tokenizer.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/time_zone_names.hpp>
+#include <boost/date_time/time_zone_base.hpp>
+#include <boost/date_time/local_time/dst_transition_day_rules.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/string_convert.hpp>
+#include <boost/date_time/time_parsing.hpp>
namespace boost{
namespace local_time{
@@ -26,12 +27,14 @@
//! simple exception for UTC and Daylight savings start/end offsets
struct bad_offset : public std::out_of_range
{
- bad_offset(std::string _msg="") : std::out_of_range(std::string("Offset out of range: " + _msg)) {}
+ bad_offset(std::string const& msg = std::string()) :
+ std::out_of_range(std::string("Offset out of range: " + msg)) {}
};
//! simple exception for UTC daylight savings adjustment
struct bad_adjustment : public std::out_of_range
{
- bad_adjustment(std::string _msg="") : std::out_of_range(std::string("Adjustment out of range: " + _msg)) {}
+ bad_adjustment(std::string const& msg = std::string()) :
+ std::out_of_range(std::string("Adjustment out of range: " + msg)) {}
};
typedef boost::date_time::dst_adjustment_offsets<boost::posix_time::time_duration> dst_adjustment_offsets;
@@ -86,7 +89,13 @@
dst_offsets_(posix_time::hours(0),posix_time::hours(0),posix_time::hours(0)),
dst_calc_rules_()
{
+#ifdef __HP_aCC
+ // Work around bug in aC++ compiler: see QXCR1000880488 in the
+ // HP bug tracking system
+ const char_type sep_chars[2] = {',',0};
+#else
const char_type sep_chars[2] = {','};
+#endif
char_separator_type sep(sep_chars);
tokenizer_type tokens(s, sep);
tokenizer_iterator_type it = tokens.begin();
@@ -231,7 +240,7 @@
void calc_zone(const string_type& obj){
const char_type empty_string[2] = {'\0'};
stringstream_type ss(empty_string);
- typename string_type::const_iterator sit = obj.begin();
+ typename string_type::const_pointer sit = obj.c_str(), obj_end = sit + obj.size();
string_type l_std_zone_abbrev, l_dst_zone_abbrev;
// get 'std' name/abbrev
@@ -242,37 +251,37 @@
ss.str(empty_string);
// get UTC offset
- if(sit != obj.end()){
+ if(sit != obj_end){
// get duration
- while(sit != obj.end() && !std::isalpha(*sit)){
- ss << *sit++;
+ while(sit != obj_end && !std::isalpha(*sit)){
+ ss << *sit++;
}
base_utc_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
ss.str(empty_string);
// base offset must be within range of -12 hours to +12 hours
if(base_utc_offset_ < time_duration_type(-12,0,0) ||
- base_utc_offset_ > time_duration_type(12,0,0))
+ base_utc_offset_ > time_duration_type(12,0,0))
{
- throw bad_offset(posix_time::to_simple_string(base_utc_offset_));
+ boost::throw_exception(bad_offset(posix_time::to_simple_string(base_utc_offset_)));
}
}
// get DST data if given
- if(sit != obj.end()){
+ if(sit != obj_end){
has_dst_ = true;
// get 'dst' name/abbrev
- while(sit != obj.end() && std::isalpha(*sit)){
+ while(sit != obj_end && std::isalpha(*sit)){
ss << *sit++;
}
l_dst_zone_abbrev = ss.str();
ss.str(empty_string);
// get DST offset if given
- if(sit != obj.end()){
+ if(sit != obj_end){
// get duration
- while(sit != obj.end() && !std::isalpha(*sit)){
+ while(sit != obj_end && !std::isalpha(*sit)){
ss << *sit++;
}
dst_offsets_.dst_adjust_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
@@ -286,7 +295,7 @@
if(dst_offsets_.dst_adjust_ <= time_duration_type(-24,0,0) ||
dst_offsets_.dst_adjust_ >= time_duration_type(24,0,0))
{
- throw bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_));
+ boost::throw_exception(bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_)));
}
}
// full names not extracted so abbrevs used in their place
@@ -294,7 +303,13 @@
}
void calc_rules(const string_type& start, const string_type& end){
+#ifdef __HP_aCC
+ // Work around bug in aC++ compiler: see QXCR1000880488 in the
+ // HP bug tracking system
+ const char_type sep_chars[2] = {'/',0};
+#else
const char_type sep_chars[2] = {'/'};
+#endif
char_separator_type sep(sep_chars);
tokenizer_type st_tok(start, sep);
tokenizer_type et_tok(end, sep);
@@ -328,7 +343,7 @@
if(dst_offsets_.dst_start_offset_ < time_duration_type(0,0,0) ||
dst_offsets_.dst_start_offset_ >= time_duration_type(24,0,0))
{
- throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_start_offset_));
+ boost::throw_exception(bad_offset(posix_time::to_simple_string(dst_offsets_.dst_start_offset_)));
}
// ending offset
@@ -343,7 +358,7 @@
if(dst_offsets_.dst_end_offset_ < time_duration_type(0,0,0) ||
dst_offsets_.dst_end_offset_ >= time_duration_type(24,0,0))
{
- throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_end_offset_));
+ boost::throw_exception(bad_offset(posix_time::to_simple_string(dst_offsets_.dst_end_offset_)));
}
}
@@ -354,7 +369,13 @@
void M_func(const string_type& s, const string_type& e){
typedef gregorian::nth_kday_of_month nkday;
unsigned short sm=0,sw=0,sd=0,em=0,ew=0,ed=0; // start/end month,week,day
+#ifdef __HP_aCC
+ // Work around bug in aC++ compiler: see QXCR1000880488 in the
+ // HP bug tracking system
+ const char_type sep_chars[3] = {'M','.',0};
+#else
const char_type sep_chars[3] = {'M','.'};
+#endif
char_separator_type sep(sep_chars);
tokenizer_type stok(s, sep), etok(e, sep);
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,16 +6,20 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
/*! @file local_time_adjustor.hpp
Time adjustment calculations for local times
*/
-#include "boost/date_time/date_generators.hpp"
-#include "boost/date_time/dst_rules.hpp"
#include <stdexcept>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/date_generators.hpp>
+#include <boost/date_time/dst_rules.hpp>
+#include <boost/date_time/time_defs.hpp> // boost::date_time::dst_flags
+#include <boost/date_time/special_defs.hpp> // not_a_date_time
namespace boost {
namespace date_time {
@@ -109,7 +113,7 @@
time_is_dst_result dst_flag =
dst_rules::local_is_dst(initial.date(), initial.time_of_day());
switch(dst_flag) {
- case is_in_dst: return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
+ case is_in_dst: return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
case is_not_in_dst: return utc_offset_rules::utc_to_local_base_offset();
case invalid_time_label:return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
case ambiguous: {
@@ -125,15 +129,15 @@
}
}
}//case
- //TODO better excpetion type
- throw std::out_of_range("Unreachable case");
-
+ //TODO better exception type
+ boost::throw_exception(std::out_of_range("Unreachable case"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_duration_type(not_a_date_time)); // should never reach
}
//! Get the offset to UTC given a local time
static time_duration_type local_to_utc_offset(const time_type& t,
date_time::dst_flags dst=date_time::calculate)
- {
+ {
switch (dst) {
case is_dst:
return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
@@ -146,13 +150,14 @@
case is_in_dst: return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
case is_not_in_dst: return utc_offset_rules::local_to_utc_base_offset();
case ambiguous: return utc_offset_rules::local_to_utc_base_offset();
- case invalid_time_label: throw std::out_of_range("Time label invalid");
+ case invalid_time_label: break;
}
- }
- throw std::out_of_range("Time label invalid");
+ }
+ boost::throw_exception(std::out_of_range("Time label invalid"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_duration_type(not_a_date_time)); // should never reach
}
-
+
private:
};
Modified: sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 20:01:18 +0000 (Thu, 13 Nov 2008) $
*/
#include "boost/date_time/dst_rules.hpp"
@@ -66,7 +66,7 @@
if (y < 2007) return Apr;
return Mar;
}
- static day_of_week_type end_day(year_type y) {return Sunday;}
+ static day_of_week_type end_day(year_type) {return Sunday;}
static month_type end_month(year_type y)
{
if (y < 2007) return Oct;
Modified: sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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-04-16 19:36:30 +0100 (Wed, 16 Apr 2008) $
+ * $Date: 2009-06-04 12:35:44 +0100 (Thu, 04 Jun 2009) $
*/
@@ -14,22 +14,19 @@
This file contains a high resolution time clock implementation.
*/
+#include <boost/cstdint.hpp>
+#include <boost/shared_ptr.hpp>
#include <boost/detail/workaround.hpp>
-#include "boost/date_time/c_time.hpp"
-#include "boost/date_time/time_clock.hpp"
-#include "boost/cstdint.hpp"
-#include "boost/shared_ptr.hpp"
-
-#ifdef BOOST_HAS_FTIME
-#include <windows.h>
-#endif
+#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>
#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
namespace boost {
namespace date_time {
-
//! A clock providing microsecond level resolution
/*! A high precision clock that measures the local time
* at a resolution up to microseconds and adjusts to the
@@ -41,6 +38,10 @@
template<class time_type>
class microsec_clock
{
+ private:
+ //! Type for the function used to convert time_t to tm
+ typedef std::tm* (*time_converter)(const std::time_t*, std::tm*);
+
public:
typedef typename time_type::date_type date_type;
typedef typename time_type::time_duration_type time_duration_type;
@@ -49,7 +50,8 @@
//! return a local time object for the given zone, based on computer clock
//JKG -- looks like we could rewrite this against universal_time
template<class time_zone_type>
- static time_type local_time(shared_ptr<time_zone_type> tz_ptr) {
+ static time_type local_time(shared_ptr<time_zone_type> tz_ptr)
+ {
typedef typename time_type::utc_time_type utc_time_type;
typedef second_clock<utc_time_type> second_clock;
// we'll need to know the utc_offset this machine has
@@ -62,137 +64,57 @@
return time_type(utc_time, tz_ptr);
}
-
- private:
- // we want this enum available for both platforms yet still private
- enum TZ_FOR_CREATE { LOCAL, GMT };
-
- public:
-
-#ifdef BOOST_HAS_GETTIMEOFDAY
- //! Return the local time based on computer clock settings
- static time_type local_time() {
- return create_time(LOCAL);
+ //! Returns the local time based on computer clock settings
+ static time_type local_time()
+ {
+ return create_time(&c_time::localtime);
}
- //! Get the current day in universal date as a ymd_type
+ //! Returns the UTC time based on computer settings
static time_type universal_time()
{
- return create_time(GMT);
+ return create_time(&c_time::gmtime);
}
private:
- static time_type create_time(TZ_FOR_CREATE tz) {
+ static time_type create_time(time_converter converter)
+ {
+#ifdef BOOST_HAS_GETTIMEOFDAY
timeval tv;
gettimeofday(&tv, 0); //gettimeofday does not support TZ adjust on Linux.
std::time_t t = tv.tv_sec;
- boost::uint32_t fs = tv.tv_usec;
- std::tm curr, *curr_ptr = 0;
- if (tz == LOCAL) {
- curr_ptr = c_time::localtime(&t, &curr);
- } else {
- curr_ptr = c_time::gmtime(&t, &curr);
- }
- date_type d(curr_ptr->tm_year + 1900,
- curr_ptr->tm_mon + 1,
- curr_ptr->tm_mday);
- //The following line will adjusts the fractional second tick in terms
- //of the current time system. For example, if the time system
- //doesn't support fractional seconds then res_adjust returns 0
- //and all the fractional seconds return 0.
- int adjust = resolution_traits_type::res_adjust()/1000000;
-
- time_duration_type td(curr_ptr->tm_hour,
- curr_ptr->tm_min,
- curr_ptr->tm_sec,
- fs*adjust);
- return time_type(d,td);
-
- }
-#endif // BOOST_HAS_GETTIMEOFDAY
-
-#ifdef BOOST_HAS_FTIME
- //! Return the local time based on computer clock settings
- static time_type local_time() {
- FILETIME ft;
- #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
- // Some runtime library implementations expect local times as the norm for ctime.
- FILETIME ft_utc;
- GetSystemTimeAsFileTime(&ft_utc);
- FileTimeToLocalFileTime(&ft_utc,&ft);
- #elif defined(BOOST_NO_GETSYSTEMTIMEASFILETIME)
- SYSTEMTIME st;
- GetSystemTime( &st );
- SystemTimeToFileTime( &st, &ft );
- #else
- GetSystemTimeAsFileTime(&ft);
- #endif
- return create_time(ft, LOCAL);
- }
-
- //! Return the UTC time based on computer settings
- static time_type universal_time() {
- FILETIME ft;
- #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
- // Some runtime library implementations expect local times as the norm for ctime.
- FILETIME ft_utc;
- GetSystemTimeAsFileTime(&ft_utc);
- FileTimeToLocalFileTime(&ft_utc,&ft);
- #elif defined(BOOST_NO_GETSYSTEMTIMEASFILETIME)
- SYSTEMTIME st;
- GetSystemTime( &st );
- SystemTimeToFileTime( &st, &ft );
- #else
- GetSystemTimeAsFileTime(&ft);
- #endif
- return create_time(ft, GMT);
- }
-
- private:
- static time_type create_time(FILETIME& ft, TZ_FOR_CREATE tz) {
- // offset is difference (in 100-nanoseconds) from
- // 1970-Jan-01 to 1601-Jan-01
- boost::uint64_t c1 = 27111902;
- boost::uint64_t c2 = 3577643008UL; // 'UL' removes compiler warnings
- const boost::uint64_t OFFSET = (c1 << 32) + c2;
-
- boost::uint64_t filetime = ft.dwHighDateTime;
- filetime = filetime << 32;
- filetime += ft.dwLowDateTime;
- filetime -= OFFSET;
- // filetime now holds 100-nanoseconds since 1970-Jan-01
-
+ 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
+ std::time_t t = static_cast<std::time_t>(micros / 1000000UL); // seconds since epoch
// microseconds -- static casts supress warnings
- boost::uint32_t sub_sec = static_cast<boost::uint32_t>((filetime % 10000000) / 10);
+ boost::uint32_t sub_sec = static_cast<boost::uint32_t>(micros % 1000000UL);
+#else
+#error Internal Boost.DateTime error: BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK is defined, however neither gettimeofday nor FILETIME support is detected.
+#endif
- std::time_t t = static_cast<time_t>(filetime / 10000000); // seconds since epoch
-
- std::tm curr, *curr_ptr = 0;
- if (tz == LOCAL) {
- curr_ptr = c_time::localtime(&t, &curr);
- }
- else {
- curr_ptr = c_time::gmtime(&t, &curr);
- }
+ std::tm curr;
+ std::tm* curr_ptr = converter(&t, &curr);
date_type d(curr_ptr->tm_year + 1900,
curr_ptr->tm_mon + 1,
curr_ptr->tm_mday);
- //The following line will adjusts the fractional second tick in terms
+ //The following line will adjust the fractional second tick in terms
//of the current time system. For example, if the time system
//doesn't support fractional seconds then res_adjust returns 0
//and all the fractional seconds return 0.
- int adjust = static_cast<int>(resolution_traits_type::res_adjust()/1000000);
+ int adjust = static_cast< int >(resolution_traits_type::res_adjust() / 1000000);
time_duration_type td(curr_ptr->tm_hour,
curr_ptr->tm_min,
curr_ptr->tm_sec,
sub_sec * adjust);
- //st.wMilliseconds * adjust);
- return time_type(d,td);
+ return time_type(d,td);
}
-#endif // BOOST_HAS_FTIME
};
Modified: sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,11 +7,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 20:01:18 +0000 (Thu, 13 Nov 2008) $
*/
-#include "boost/date_time/string_parse_tree.hpp"
-#include "boost/date_time/string_convert.hpp"
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/string_parse_tree.hpp>
+#include <boost/date_time/string_convert.hpp>
namespace boost { namespace date_time {
@@ -32,7 +33,7 @@
* where the date format is controlled by the date facet
*/
template<class date_type, typename CharT>
- class period_parser {
+ class period_parser {
public:
typedef std::basic_string<CharT> string_type;
typedef CharT char_type;
@@ -41,7 +42,7 @@
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;
-
+
static const char_type default_period_separator[2];
static const char_type default_period_start_delimeter[2];
static const char_type default_period_open_range_end_delimeter[2];
@@ -50,12 +51,12 @@
enum period_range_option { AS_OPEN_RANGE, AS_CLOSED_RANGE };
//! Constructor that sets up period parser options
- period_parser(period_range_option range_option = AS_CLOSED_RANGE,
- const char_type* const period_separator = default_period_separator,
+ period_parser(period_range_option range_opt = AS_CLOSED_RANGE,
+ const char_type* const period_separator = default_period_separator,
const char_type* const period_start_delimeter = default_period_start_delimeter,
const char_type* const period_open_range_end_delimeter = default_period_open_range_end_delimeter,
const char_type* const period_closed_range_end_delimeter = default_period_closed_range_end_delimeter)
- : m_range_option(range_option)
+ : m_range_option(range_opt)
{
delimiters.push_back(string_type(period_separator));
delimiters.push_back(string_type(period_start_delimeter));
@@ -119,13 +120,13 @@
period_type get_period(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
- const period_type& p,
+ const period_type& /* p */,
const duration_type& dur_unit,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+
typedef typename period_type::point_type point_type;
point_type p1(not_a_date_time), p2(not_a_date_time);
@@ -144,14 +145,14 @@
else {
consume_delim(sitr, stream_end, delimiters[OPEN_END]); // end delim
}
-
+
return period_type(p1, p2);
}
-
+
private:
collection_type delimiters;
- period_range_option m_range_option;
-
+ period_range_option m_range_option;
+
enum delim_ids { SEPARATOR, START, OPEN_END, CLOSED_END };
//! throws ios_base::failure if delimiter and parsed data do not match
@@ -170,7 +171,8 @@
++sitr;
}
if(s != delim) {
- throw std::ios_base::failure("Parse failed. Expected '" + convert_string_type<char_type,char>(delim) + "' but found '" + convert_string_type<char_type,char>(s) + "'");
+ boost::throw_exception(std::ios_base::failure("Parse failed. Expected '"
+ + convert_string_type<char_type,char>(delim) + "' but found '" + convert_string_type<char_type,char>(s) + "'"));
}
}
};
Modified: sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-05-31 15:24:25 +0100 (Sun, 31 May 2009) $
*/
#include "boost/date_time/posix_time/ptime.hpp"
@@ -22,7 +22,7 @@
//! Function that converts a time_t into a ptime.
inline
- ptime from_time_t(std::time_t t)
+ ptime from_time_t(std::time_t t)
{
ptime start(gregorian::date(1970,1,1));
return start + seconds(static_cast<long>(t));
@@ -42,14 +42,8 @@
//! Convert a time_duration to a tm structure truncating any fractional seconds and zeroing fields for date components
inline
std::tm to_tm(const boost::posix_time::time_duration& td) {
- std::tm timetm;
- timetm.tm_year = 0;
- timetm.tm_mon = 0;
- timetm.tm_mday = 0;
- timetm.tm_wday = 0;
- timetm.tm_yday = 0;
-
- timetm.tm_hour = date_time::absolute_value(td.hours());
+ std::tm 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_isdst = -1; // -1 used when dst info is unknown
@@ -72,14 +66,18 @@
* built with microsecond resolution the FILETIME's sub second value
* will be truncated. Nanosecond resolution has no truncation.
*
- * Note ftime is part of the Win32 API, so it is not portable to non-windows
+ * \note FILETIME is part of the Win32 API, so it is not portable to non-windows
* platforms.
+ *
+ * \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<class time_type>
+ template< typename TimeT, typename FileTimeT >
inline
- time_type from_ftime(const FILETIME& ft)
+ TimeT from_ftime(const FileTimeT& ft)
{
- return boost::date_time::time_from_ftime<time_type>(ft);
+ return boost::date_time::time_from_ftime<TimeT>(ft);
}
#endif // BOOST_HAS_FTIME
Modified: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,22 +2,22 @@
#define POSIX_TIME_CONFIG_HPP___
/* Copyright (c) 2002,2003,2005 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
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-04 12:52:06 +0100 (Thu, 04 Jun 2009) $
*/
-#include "boost/date_time/time_duration.hpp"
-#include "boost/date_time/time_resolution_traits.hpp"
-#include "boost/date_time/gregorian/gregorian_types.hpp"
-#include "boost/date_time/wrapping_int.hpp"
-#include "boost/limits.hpp"
-#include "boost/date_time/compiler_config.hpp"
-#include "boost/cstdint.hpp"
-#include <cmath>
#include <cstdlib> //for MCW 7.2 std::abs(long long)
+#include <boost/limits.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/config/no_tr1/cmath.hpp>
+#include <boost/date_time/time_duration.hpp>
+#include <boost/date_time/time_resolution_traits.hpp>
+#include <boost/date_time/gregorian/gregorian_types.hpp>
+#include <boost/date_time/wrapping_int.hpp>
+#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace posix_time {
@@ -30,7 +30,7 @@
#define BOOST_DATE_TIME_HAS_MILLISECONDS
#define BOOST_DATE_TIME_HAS_MICROSECONDS
#define BOOST_DATE_TIME_HAS_NANOSECONDS
- typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
+ typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
1000000000, 9 > time_res_traits;
#else
// set up conditional test compilations
@@ -38,14 +38,14 @@
#define BOOST_DATE_TIME_HAS_MICROSECONDS
#undef BOOST_DATE_TIME_HAS_NANOSECONDS
typedef date_time::time_resolution_traits<
- boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
+ boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
1000000, 6 > time_res_traits;
// #undef BOOST_DATE_TIME_HAS_MILLISECONDS
// #undef BOOST_DATE_TIME_HAS_MICROSECONDS
// #undef BOOST_DATE_TIME_HAS_NANOSECONDS
-// typedef date_time::time_resolution_traits<boost::int64_t, boost::date_time::tenth,
+// typedef date_time::time_resolution_traits<boost::int64_t, boost::date_time::tenth,
// 10, 0 > time_res_traits;
#endif
@@ -82,8 +82,8 @@
//Give duration access to ticks constructor -- hide from users
friend class date_time::time_duration<time_duration, time_res_traits>;
private:
- explicit time_duration(impl_type ticks) :
- date_time::time_duration<time_duration, time_res_traits>(ticks)
+ explicit time_duration(impl_type tick_count) :
+ date_time::time_duration<time_duration, time_res_traits>(tick_count)
{}
};
@@ -134,7 +134,7 @@
}
};
- class posix_time_system_config
+ class posix_time_system_config
{
public:
typedef simple_time_rep time_rep_type;
@@ -143,7 +143,7 @@
typedef time_duration time_duration_type;
typedef time_res_traits::tick_type int_type;
typedef time_res_traits resolution_traits;
-#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
#else
BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000000);
#endif
@@ -151,7 +151,7 @@
#else
- class millisec_posix_time_system_config
+ class millisec_posix_time_system_config
{
public:
typedef boost::int64_t time_rep_type;
@@ -162,7 +162,7 @@
typedef time_res_traits::tick_type int_type;
typedef time_res_traits::impl_type impl_type;
typedef time_res_traits resolution_traits;
-#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
#else
BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000);
#endif
Modified: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,17 +6,19 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 19:04:15 +0000 (Thu, 13 Nov 2008) $
*/
-#include "boost/date_time/time_facet.hpp"
-#include "boost/date_time/period_formatter.hpp"
-#include "boost/date_time/posix_time/time_period.hpp"
-#include "boost/date_time/posix_time/posix_time_duration.hpp"
-//#include "boost/date_time/gregorian/gregorian_io.hpp"
-#include "boost/io/ios_state.hpp"
-#include <iostream>
#include <locale>
+#include <iostream>
+#include <iterator> // i/ostreambuf_iterator
+#include <boost/io/ios_state.hpp>
+#include <boost/date_time/time_facet.hpp>
+#include <boost/date_time/period_formatter.hpp>
+#include <boost/date_time/posix_time/ptime.hpp>
+#include <boost/date_time/posix_time/time_period.hpp>
+#include <boost/date_time/posix_time/posix_time_duration.hpp>
+#include <boost/date_time/posix_time/conversion.hpp> // to_tm will be needed in the facets
namespace boost {
namespace posix_time {
@@ -39,9 +41,9 @@
typedef boost::date_time::time_input_facet<ptime, char> time_input_facet;
template <class CharT, class TraitsT>
- inline
+ inline
std::basic_ostream<CharT, TraitsT>&
- operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
const ptime& p) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
@@ -55,7 +57,6 @@
//since we would always need to reconstruct for every time period
//if the locale did not already exist. Of course this will be overridden
//if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
custom_ptime_facet* f = new custom_ptime_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
@@ -71,11 +72,10 @@
operator>>(std::basic_istream<CharT, Traits>& is, ptime& pt)
{
boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ 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;
-
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);
@@ -87,31 +87,30 @@
f->get(sit, str_end, is, pt);
}
}
- catch(...) {
+ 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); }
+ 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);
- }
-
+ 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,
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
const boost::posix_time::time_period& p) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
@@ -126,7 +125,6 @@
//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 as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
custom_ptime_facet* f = new custom_ptime_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
@@ -142,11 +140,10 @@
operator>>(std::basic_istream<CharT, Traits>& is, time_period& tp)
{
boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ 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;
-
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);
@@ -158,22 +155,21 @@
f->get(sit, str_end, is, tp);
}
}
- catch(...) {
+ catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
- is.setstate(std::ios_base::failbit);
- }
-
+ is.setstate(std::ios_base::failbit);
+ }
}
}
return is;
}
-
+
//! ostream operator for posix_time::time_duration
// todo fix to use facet -- place holder for now...
@@ -194,7 +190,6 @@
//since we would always need to reconstruct for every time period
//if the locale did not already exist. Of course this will be overridden
//if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
custom_ptime_facet* f = new custom_ptime_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
@@ -210,11 +205,10 @@
operator>>(std::basic_istream<CharT, Traits>& is, time_duration& td)
{
boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ 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;
-
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);
@@ -226,21 +220,20 @@
f->get(sit, str_end, is, td);
}
}
- catch(...) {
+ catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
- is.setstate(std::ios_base::failbit);
- }
-
+ is.setstate(std::ios_base::failbit);
+ }
}
}
return is;
}
-
+
} } // namespaces
#endif // DATE_TIME_POSIX_TIME_IO_HPP__
Modified: sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,16 +2,16 @@
#define BOOST_DATE_TIME_STRING_PARSE_TREE___HPP__
/* Copyright (c) 2004-2005 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
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-07-20 23:02:39 +0100 (Sun, 20 Jul 2008) $
*/
#include "boost/lexical_cast.hpp" //error without?
-#include "boost/algorithm/string/case_conv.hpp"
+#include "boost/algorithm/string/case_conv.hpp"
#include <map>
#include <string>
#include <vector>
@@ -37,21 +37,21 @@
return cache;
}
//some of the cache was used return the rest
- return string_type(cache, match_depth);
+ return string_type(cache, match_depth);
}
charT last_char() const
{
return cache[cache.size()-1];
}
//! Returns true if more characters were parsed than was necessary
- /*! Should be used in conjunction with last_char()
- * to get the remaining character.
+ /*! Should be used in conjunction with last_char()
+ * to get the remaining character.
*/
bool has_remaining() const
{
return (cache.size() > match_depth);
}
-
+
// cache will hold characters that have been read from the stream
string_type cache;
unsigned short match_depth;
@@ -64,8 +64,8 @@
std::basic_ostream<charT>&
operator<<(std::basic_ostream<charT>& os, parse_match_result<charT>& mr)
{
- os << "cm: " << mr.current_match
- << " C: '" << mr.cache
+ os << "cm: " << mr.current_match
+ << " C: '" << mr.cache
<< "' md: " << mr.match_depth
<< " R: " << mr.remaining();
return os;
@@ -93,11 +93,11 @@
typedef std::basic_string<charT> string_type;
typedef std::vector<std::basic_string<charT> > collection_type;
typedef parse_match_result<charT> parse_match_result_type;
-
- /*! Parameter "starting_point" desingates where the numbering begins.
- * A starting_point of zero will start the numbering at zero
- * (Sun=0, Mon=1, ...) were a starting_point of one starts the
- * numbering at one (Jan=1, Feb=2, ...). The default is zero,
+
+ /*! Parameter "starting_point" designates where the numbering begins.
+ * A starting_point of zero will start the numbering at zero
+ * (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)
{
@@ -126,44 +126,44 @@
while(i < s.size()) {
if (i==0) {
if (i == (s.size()-1)) {
- ti = m_next_chars.insert(value_type(s[i],
+ ti = m_next_chars.insert(value_type(s[i],
string_parse_tree<charT>(value)));
}
else {
- ti = m_next_chars.insert(value_type(s[i],
+ ti = m_next_chars.insert(value_type(s[i],
string_parse_tree<charT>()));
}
}
else {
if (i == (s.size()-1)) {
- ti = ti->second.m_next_chars.insert(value_type(s[i],
+ ti = ti->second.m_next_chars.insert(value_type(s[i],
string_parse_tree<charT>(value)));
}
-
+
else {
- ti = ti->second.m_next_chars.insert(value_type(s[i],
+ ti = ti->second.m_next_chars.insert(value_type(s[i],
string_parse_tree<charT>()));
}
-
- }
+
+ }
i++;
}
}
-
-
+
+
//! Recursive function that finds a matching string in the tree.
- /*! Must check match_results::has_remaining() after match() is
- * called. This is required so the user can determine if
- * stream iterator is already pointing to the expected
+ /*! Must check match_results::has_remaining() after match() is
+ * called. This is required so the user can determine if
+ * stream iterator is already pointing to the expected
* character or not (match() might advance sitr to next char in stream).
*
- * A parse_match_result that has been returned from a failed match
- * attempt can be sent in to the match function of a different
- * string_parse_tree to attempt a match there. Use the iterators
- * for the partially consumed stream, the parse_match_result object,
+ * A parse_match_result that has been returned from a failed match
+ * attempt can be sent in to the match function of a different
+ * string_parse_tree to attempt a match there. Use the iterators
+ * for the partially consumed stream, the parse_match_result object,
* and '0' for the level parameter. */
short
- match(std::istreambuf_iterator<charT>& sitr,
+ match(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
parse_match_result_type& result,
unsigned int& level) const
@@ -171,7 +171,7 @@
level++;
charT c;
- // if we conditionally advance sitr, we won't have
+ // if we conditionally advance sitr, we won't have
// to consume the next character past the input
bool adv_itr = true;
if (level > result.cache.size()) {
@@ -181,16 +181,16 @@
//sitr++;
}
else {
- // if we're looking for characters from the cache,
+ // if we're looking for characters from the cache,
// we don't want to increment sitr
- adv_itr = false;
+ adv_itr = false;
c = static_cast<charT>(std::tolower(result.cache[level-1]));
}
const_iterator litr = m_next_chars.lower_bound(c);
const_iterator uitr = m_next_chars.upper_bound(c);
while (litr != uitr) { // equal if not found
if(adv_itr) {
- sitr++;
+ sitr++;
result.cache += c;
}
if (litr->second.m_value != -1) { // -1 is default value
@@ -198,16 +198,16 @@
result.current_match = litr->second.m_value;
result.match_depth = static_cast<unsigned short>(level);
}
- litr->second.match(sitr, stream_end,
+ litr->second.match(sitr, stream_end,
result, level);
level--;
}
else {
- litr->second.match(sitr, stream_end,
+ litr->second.match(sitr, stream_end,
result, level);
level--;
}
-
+
if(level <= result.cache.size()) {
adv_itr = false;
}
@@ -218,13 +218,13 @@
}
- /*! Must check match_results::has_remaining() after match() is
- * called. This is required so the user can determine if
- * stream iterator is already pointing to the expected
+ /*! Must check match_results::has_remaining() after match() is
+ * called. This is required so the user can determine if
+ * stream iterator is already pointing to the expected
* character or not (match() might advance sitr to next char in stream).
*/
parse_match_result_type
- match(std::istreambuf_iterator<charT>& sitr,
+ match(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end) const
{
// lookup to_lower of char in tree.
@@ -242,8 +242,8 @@
iterator end = m_next_chars.end();
// os << "starting level: " << level << std::endl;
while (itr != end) {
- os << "level: " << level
- << " node: " << itr->first
+ os << "level: " << level
+ << " node: " << itr->first
<< " value: " << itr->second.m_value
<< std::endl;
itr->second.printme(os, level);
@@ -257,14 +257,14 @@
int level = 0;
printme(os, level);
}
-
+
void printmatch(std::ostream& os, charT c)
{
iterator litr = m_next_chars.lower_bound(c);
iterator uitr = m_next_chars.upper_bound(c);
os << "matches for: " << c << std::endl;
while (litr != uitr) {
- os << " node: " << litr->first
+ os << " node: " << litr->first
<< " value: " << litr->second.m_value
<< std::endl;
litr++;
Modified: sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-01-29 18:54:17 +0000 (Thu, 29 Jan 2009) $
*/
#include <sstream>
@@ -49,6 +49,7 @@
{
//grab the needed strings by using the locale to
//output each month
+ const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
for (int m=0; m < 12; m++) {
tm tm_value;
tm_value.tm_mon = m;
@@ -56,8 +57,8 @@
ostream_iter_type oitr(ss);
std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
&tm_value,
- &*outfmt.begin(),
- &*outfmt.begin()+outfmt.size());
+ p_outfmt,
+ p_outfmt_end);
months.push_back(ss.str());
}
}
@@ -101,6 +102,7 @@
{
//grab the needed strings by using the locale to
//output each month / weekday
+ const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
for (int i=0; i < 7; i++) {
tm tm_value;
tm_value.tm_wday = i;
@@ -108,8 +110,8 @@
ostream_iter_type oitr(ss);
std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
&tm_value,
- &*outfmt.begin(),
- &*outfmt.begin()+outfmt.size());
+ p_outfmt,
+ p_outfmt_end);
weekdays.push_back(ss.str());
}
Deleted: sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
+++ (empty file)
@@ -1,66 +0,0 @@
-
-#ifndef TEST_FRMWK_HPP___
-#define TEST_FRMWK_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)
- * $Date: 2008-03-23 13:03:24 +0000 (Sun, 23 Mar 2008) $
- */
-
-
-#include <iostream>
-#include <string>
-
-//! Really simple test framework for counting and printing
-class TestStats
-{
-public:
- static TestStats& instance() {static TestStats ts; return ts;}
- void addPassingTest() {testcount_++; passcount_++;}
- void addFailingTest() {testcount_++;}
- unsigned int testcount() const {return testcount_;}
- unsigned int passcount() const {return passcount_;}
- void print(std::ostream& out = std::cout) const
- {
- out << testcount_ << " Tests Executed: " ;
- if (passcount() != testcount()) {
- out << (testcount() - passcount()) << " FAILURES";
- }
- else {
- out << "All Succeeded" << std::endl;
- }
- out << std::endl;
- }
-private:
- TestStats() : testcount_(0), passcount_(0) {}
- unsigned int testcount_;
- unsigned int passcount_;
-};
-
-
-bool check(const std::string& testname, bool testcond)
-{
- TestStats& stat = TestStats::instance();
- if (testcond) {
- std::cout << "Pass :: " << testname << " " << std::endl;
- stat.addPassingTest();
- return true;
- }
- else {
- stat.addFailingTest();
- std::cout << "FAIL :: " << testname << " " << std::endl;
- return false;
- }
-}
-
-
-int printTestStats()
-{
- TestStats& stat = TestStats::instance();
- stat.print();
- return stat.testcount() - stat.passcount();
-}
-
-#endif
Modified: sandbox/SOC/2008/calendar/boost/date_time/time.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,16 +6,17 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
/*! @file time.hpp
This file contains the interface for the time associated classes.
*/
-#include "boost/date_time/time_defs.hpp"
-#include "boost/operators.hpp"
#include <string>
+#include <boost/operators.hpp>
+#include <boost/date_time/time_defs.hpp>
+#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace date_time {
@@ -77,21 +78,21 @@
/*! Optional bool parameter will return time zone as an offset
* (ie "+07:00"). Empty string is returned for classes that do
* not use a time_zone */
- std::string zone_name(bool as_offset=false) const
+ std::string zone_name(bool /*as_offset*/=false) const
{
return time_system::zone_name(time_);
}
/*! Optional bool parameter will return time zone as an offset
* (ie "+07:00"). Empty string is returned for classes that do
* not use a time_zone */
- std::string zone_abbrev(bool as_offset=false) const
+ std::string zone_abbrev(bool /*as_offset*/=false) const
{
return time_system::zone_name(time_);
}
//! An empty string is returned for classes that do not use a time_zone
std::string zone_as_posix_string() const
{
- return std::string("");
+ return std::string();
}
//! check to see if date is not a value
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
@@ -20,7 +20,17 @@
namespace date_time {
//!Defines some nice types for handling time level resolutions
- enum time_resolutions {sec, tenth, hundreth, milli, ten_thousandth, micro, nano, NumResolutions };
+ enum time_resolutions {
+ sec,
+ tenth,
+ hundreth, // deprecated misspelled version of hundredth
+ hundredth = hundreth,
+ milli,
+ ten_thousandth,
+ micro,
+ nano,
+ NumResolutions
+ };
//! Flags for daylight savings or summer time
enum dst_flags {not_dst, is_dst, calculate};
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,18 +6,19 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-01 10:00:02 +0100 (Mon, 01 Jun 2009) $
*/
-#include "boost/operators.hpp"
-#include "boost/date_time/time_defs.hpp"
-#include "boost/date_time/special_defs.hpp"
-#include "boost/date_time/compiler_config.hpp"
+#include <boost/cstdint.hpp>
+#include <boost/operators.hpp>
+#include <boost/date_time/time_defs.hpp>
+#include <boost/date_time/special_defs.hpp>
+#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace date_time {
-
+
//! Represents some amount of elapsed time measure to a given resolution
/*! This class represents a standard set of capabilities for all
counted time durations. Time duration implementations should derive
@@ -30,13 +31,13 @@
*/
template<class T, typename rep_type>
class time_duration : private
- boost::less_than_comparable<T
+ boost::less_than_comparable<T
, boost::equality_comparable<T
> >
/* dividable, addable, and subtractable operator templates
- * won't work with this class (MSVC++ 6.0). return type
- * from '+=' is different than expected return type
- * from '+'. multipliable probably wont work
+ * won't work with this class (MSVC++ 6.0). return type
+ * from '+=' is different than expected return type
+ * from '+'. multipliable probably wont work
* either (haven't tried) */
{
public:
@@ -50,12 +51,12 @@
typedef typename rep_type::tick_type tick_type;
typedef typename rep_type::impl_type impl_type;
- time_duration() : ticks_(0) {}
- time_duration(hour_type hours_in,
- min_type minutes_in,
+ time_duration() : ticks_(0) {}
+ time_duration(hour_type hours_in,
+ min_type minutes_in,
sec_type seconds_in=0,
fractional_seconds_type frac_sec_in = 0) :
- ticks_(rep_type::to_tick_count(hours_in,minutes_in,seconds_in,frac_sec_in))
+ ticks_(rep_type::to_tick_count(hours_in,minutes_in,seconds_in,frac_sec_in))
{}
// copy constructor required for dividable<>
//! Construct from another time_duration (Copy constructor)
@@ -136,17 +137,17 @@
}
duration_type invert_sign() const
{
- return duration_type(ticks_ * (-1));
- }
+ return duration_type(ticks_ * (-1));
+ }
bool is_negative() const
{
return ticks_ < 0;
- }
- bool operator<(const time_duration& rhs) const
+ }
+ bool operator<(const time_duration& rhs) const
{
return ticks_ < rhs.ticks_;
}
- bool operator==(const time_duration& rhs) const
+ bool operator==(const time_duration& rhs) const
{
return ticks_ == rhs.ticks_;
}
@@ -188,13 +189,13 @@
{
return duration_type(ticks_ * rhs);
}
- duration_type operator*=(int divisor)
+ duration_type operator*=(int divisor)
{
ticks_ = ticks_ * divisor;
return duration_type(ticks_);
}
- tick_type ticks() const
- {
+ tick_type ticks() const
+ {
return traits_type::as_number(ticks_);
}
@@ -258,9 +259,9 @@
//! 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 resoultion adjustment
*/
- template<class base_duration, boost::int64_t frac_of_second>
+ template<class base_duration, boost::int64_t frac_of_second>
class subsecond_duration : public base_duration
{
public:
@@ -270,8 +271,8 @@
{}
};
-
-
+
+
} } //namespace date_time
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,15 +7,26 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Martin Andrian, Jeff Garland, Bart Garst
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-22 12:49:20 +0000 (Sat, 22 Nov 2008) $
*/
-#include "boost/date_time/date_facet.hpp"
-#include "boost/date_time/string_convert.hpp"
-#include "boost/algorithm/string/erase.hpp"
+#include <cctype>
+#include <locale>
+#include <limits>
+#include <string>
#include <sstream>
#include <iomanip>
+#include <iterator> // i/ostreambuf_iterator
#include <exception>
+#include <boost/assert.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/algorithm/string/erase.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/date_facet.hpp>
+#include <boost/date_time/string_convert.hpp>
+#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace date_time {
@@ -28,6 +39,8 @@
static const char_type fractional_seconds_or_none_format[3]; // F
static const char_type seconds_with_fractional_seconds_format[3]; // s
static const char_type seconds_format[3]; // S
+ static const char_type hours_format[3]; // H
+ static const char_type unrestricted_hours_format[3]; // O
static const char_type standard_format[9]; // x X
static const char_type zone_abbrev_format[3]; // z
static const char_type zone_name_format[3]; // Z
@@ -62,10 +75,18 @@
time_formats<CharT>::seconds_with_fractional_seconds_format[3] =
{'%','s'};
- template <class CharT>
+ template <class CharT>
const typename time_formats<CharT>::char_type
time_formats<CharT>::seconds_format[3] = {'%','S'};
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::hours_format[3] = {'%','H'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::unrestricted_hours_format[3] = {'%','O'};
+
template <class CharT>
const typename time_formats<CharT>::char_type
//time_formats<CharT>::standard_format[5] = {'%','c',' ','%','z'};
@@ -172,6 +193,8 @@
static const char_type* fractional_seconds_or_none_format; // %F
static const char_type* seconds_with_fractional_seconds_format; // %s
static const char_type* seconds_format; // %S
+ static const char_type* hours_format; // %H
+ static const char_type* unrestricted_hours_format; // %O
static const char_type* standard_format; // %x X
static const char_type* zone_abbrev_format; // %z
static const char_type* zone_name_format; // %Z
@@ -197,9 +220,8 @@
#endif
//! sets default formats for ptime, local_date_time, and time_duration
- explicit time_facet(::size_t /* a_ref */ = 0)
- //: base_type(standard_format),
- : base_type(default_time_format),
+ explicit time_facet(::size_t a_ref = 0)
+ : base_type(default_time_format, period_formatter_type(), special_values_formatter_type(), date_gen_formatter_type(), a_ref),
m_time_duration_format(string_type(duration_sign_negative_only) + default_time_duration_format)
{}
@@ -242,6 +264,7 @@
a_time.date().as_special());
}
string_type format(this->m_format);
+
string_type frac_str;
if (format.find(seconds_with_fractional_seconds_format) != string_type::npos) {
// replace %s with %S.nnn
@@ -263,9 +286,7 @@
if(a_time.zone_abbrev().empty()) {
// if zone_abbrev() returns an empty string, we want to
// erase posix_zone_string_format from format
- boost::algorithm::replace_all(format,
- posix_zone_string_format,
- "");
+ boost::algorithm::erase_all(format, posix_zone_string_format);
}
else{
boost::algorithm::replace_all(format,
@@ -283,9 +304,7 @@
// erase zone_name_format & one preceeding space
std::basic_ostringstream<char_type> ss;
ss << ' ' << zone_name_format;
- boost::algorithm::replace_all(format,
- ss.str(),
- "");
+ boost::algorithm::erase_all(format, ss.str());
}
else{
boost::algorithm::replace_all(format,
@@ -303,9 +322,7 @@
// erase zone_abbrev_format & one preceeding space
std::basic_ostringstream<char_type> ss;
ss << ' ' << zone_abbrev_format;
- boost::algorithm::replace_all(format,
- ss.str(),
- "");
+ boost::algorithm::erase_all(format, ss.str());
}
else{
boost::algorithm::replace_all(format,
@@ -321,9 +338,7 @@
// if zone_name() returns an empty string, we want to
// erase zone_iso_extended_format from format
- boost::algorithm::replace_all(format,
- zone_iso_extended_format,
- "");
+ boost::algorithm::erase_all(format, zone_iso_extended_format);
}
else{
boost::algorithm::replace_all(format,
@@ -340,9 +355,7 @@
// if zone_abbrev() returns an empty string, we want to
// erase zone_iso_format from format
- boost::algorithm::replace_all(format,
- zone_iso_format,
- "");
+ boost::algorithm::erase_all(format, zone_iso_format);
}
else{
boost::algorithm::replace_all(format,
@@ -396,24 +409,45 @@
string_type format(m_time_duration_format);
if (a_time_dur.is_negative()) {
- // replace %- with minus sign. Should we use the numpunct facet?
- boost::algorithm::replace_all(format,
- duration_sign_negative_only,
- negative_sign);
+ // replace %- with minus sign. Should we use the numpunct facet?
+ boost::algorithm::replace_all(format,
+ duration_sign_negative_only,
+ negative_sign);
// remove all the %+ in the string with '-'
- boost::algorithm::replace_all(format,
- duration_sign_always,
- negative_sign);
+ boost::algorithm::replace_all(format,
+ duration_sign_always,
+ negative_sign);
}
else { //duration is positive
- // remove all the %- combos from the string
- boost::algorithm::replace_all(format,
- duration_sign_negative_only,
- "");
- // remove all the %+ in the string with '+'
- boost::algorithm::replace_all(format,
- duration_sign_always,
- positive_sign);
+ // remove all the %- combos from the string
+ boost::algorithm::erase_all(format, duration_sign_negative_only);
+ // remove all the %+ in the string with '+'
+ boost::algorithm::replace_all(format,
+ duration_sign_always,
+ positive_sign);
+ }
+
+ /*
+ * It is possible for a time duration to span more then 24 hours.
+ * Standard time_put::put is obliged to behave the same as strftime
+ * (See ISO 14882-2003 22.2.5.3.1 par. 1) and strftime's behavior is
+ * unspecified for the case when tm_hour field is outside 0-23 range
+ * (See ISO 9899-1999 7.23.3.5 par. 3). So we must output %H and %O
+ * here ourself.
+ */
+ string_type hours_str;
+ if (format.find(unrestricted_hours_format) != string_type::npos) {
+ hours_str = hours_as_string(a_time_dur);
+ boost::algorithm::replace_all(format, unrestricted_hours_format, hours_str);
+ }
+ // We still have to process restricted hours format specifier. In order to
+ // support parseability of durations in ISO format (%H%M%S), we'll have to
+ // restrict the stringified hours length to 2 characters.
+ if (format.find(hours_format) != string_type::npos) {
+ if (hours_str.empty())
+ hours_str = hours_as_string(a_time_dur);
+ BOOST_ASSERT(hours_str.length() <= 2);
+ boost::algorithm::replace_all(format, hours_format, hours_str);
}
string_type frac_str;
@@ -485,17 +519,33 @@
}
//make sure there is no sign
- frac_sec = date_time::absolute_value(frac_sec);
+ return integral_as_string(
+ date_time::absolute_value(frac_sec),
+ time_duration_type::num_fractional_digits());
+ }
+
+ static
+ string_type
+ hours_as_string(const time_duration_type& a_time, int width = 2)
+ {
+ return integral_as_string(date_time::absolute_value(a_time.hours()), width);
+ }
+
+ template< typename IntT >
+ static
+ string_type
+ integral_as_string(IntT val, int width = 2)
+ {
std::basic_ostringstream<char_type> ss;
ss.imbue(std::locale::classic()); // don't want any formatting
- ss << std::setw(time_duration_type::num_fractional_digits())
- << std::setfill(static_cast<char_type>('0'));
+ ss << std::setw(width)
+ << std::setfill(static_cast<char_type>('0'));
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
// JDG [7/6/02 VC++ compatibility]
char_type buff[34];
- ss << _i64toa(static_cast<boost::int64_t>(frac_sec), buff, 10);
+ ss << _i64toa(static_cast<boost::int64_t>(val), buff, 10);
#else
- ss << frac_sec;
+ ss << val;
#endif
return ss.str();
}
@@ -504,7 +554,7 @@
string_type m_time_duration_format;
};
-
+
template <class time_type, class CharT, class OutItrT>
std::locale::id time_facet<time_type, CharT, OutItrT>::id;
@@ -548,6 +598,14 @@
template <class time_type, class CharT, class OutItrT>
const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::hours_format = time_formats<CharT>::hours_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::unrestricted_hours_format = time_formats<CharT>::unrestricted_hours_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
time_facet<time_type, CharT, OutItrT>::standard_format = time_formats<CharT>::standard_format;
template <class time_type, class CharT, class OutItrT>
@@ -705,11 +763,15 @@
c = *sitr;
}
- long hour = 0;
- long min = 0;
- long sec = 0;
+ typedef typename time_duration_type::hour_type hour_type;
+ typedef typename time_duration_type::min_type min_type;
+ typedef typename time_duration_type::sec_type sec_type;
+
+ hour_type hour = 0;
+ min_type min = 0;
+ sec_type sec = 0;
typename time_duration_type::fractional_seconds_type frac(0);
-
+
typedef std::num_get<CharT, InItrT> num_get;
if(!std::has_facet<num_get>(a_ios.getloc())) {
num_get* ng = new num_get();
@@ -720,45 +782,49 @@
const_itr itr(m_time_duration_format.begin());
while (itr != m_time_duration_format.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ ++itr;
if (*itr != '%') {
switch(*itr) {
- case 'H':
+ case 'O':
{
- match_results mr;
- hour = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ // A period may span more than 24 hours. In that case the format
+ // string should be composed with the unrestricted hours specifier.
+ hour = var_string_to_int<hour_type, CharT>(sitr, stream_end,
+ std::numeric_limits<hour_type>::digits10 + 1);
if(hour == -1){
return check_special_value(sitr, stream_end, td, c);
}
break;
}
- case 'M':
+ case 'H':
{
match_results mr;
- min = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
- if(min == -1){
+ hour = fixed_string_to_int<hour_type, CharT>(sitr, stream_end, mr, 2);
+ if(hour == -1){
return check_special_value(sitr, stream_end, td, c);
}
break;
}
- case 'S':
+ case 'M':
{
match_results mr;
- sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
- if(sec == -1){
+ min = fixed_string_to_int<min_type, CharT>(sitr, stream_end, mr, 2);
+ if(min == -1){
return check_special_value(sitr, stream_end, td, c);
}
break;
}
case 's':
+ case 'S':
{
match_results mr;
- sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ sec = fixed_string_to_int<sec_type, CharT>(sitr, stream_end, mr, 2);
if(sec == -1){
return check_special_value(sitr, stream_end, td, c);
}
+ if (*itr == 'S')
+ break;
// %s is the same as %S%f so we drop through into %f
- //break;
}
case 'f':
{
@@ -796,20 +862,20 @@
}// switch
}
else { // itr == '%', second consecutive
- sitr++;
+ ++sitr;
}
- itr++; //advance past format specifier
+ ++itr; //advance past format specifier
}
else { //skip past chars in format and in buffer
- itr++;
+ ++itr;
// set use_current_char when sitr is already
// pointing at the next character to process
if (use_current_char) {
use_current_char = false;
}
else {
- sitr++;
+ ++sitr;
}
}
}
@@ -858,11 +924,15 @@
if((sitr != stream_end) && (*sitr == '-' || *sitr == '+')) {
c = *sitr;
}
-
+
+ typedef typename time_duration_type::hour_type hour_type;
+ typedef typename time_duration_type::min_type min_type;
+ typedef typename time_duration_type::sec_type sec_type;
+
// time elements
- long hour = 0;
- long min = 0;
- long sec = 0;
+ hour_type hour = 0;
+ min_type min = 0;
+ sec_type sec = 0;
typename time_duration_type::fractional_seconds_type frac(0);
// date elements
short day_of_year(0);
@@ -884,7 +954,7 @@
const_itr itr(this->m_format.begin());
while (itr != this->m_format.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ ++itr;
if (*itr != '%') {
// the cases are grouped by date & time flags - not alphabetical order
switch(*itr) {
@@ -898,7 +968,7 @@
try {
t_year = this->m_parser.parse_year(sitr, stream_end, s, mr);
}
- catch(std::out_of_range bad_year) { // base class for bad_year exception
+ catch(std::out_of_range&) { // base class for bad_year exception
if(this->m_sv_parser.match(sitr, stream_end, mr)) {
t = time_type(static_cast<special_values>(mr.current_match));
return sitr;
@@ -919,13 +989,13 @@
try {
t_month = this->m_parser.parse_month(sitr, stream_end, s, mr);
}
- catch(std::out_of_range bad_month) { // base class for bad_month exception
+ catch(std::out_of_range&) { // base class for bad_month exception
if(this->m_sv_parser.match(sitr, stream_end, mr)) {
t = time_type(static_cast<special_values>(mr.current_match));
return sitr;
}
else {
- throw; // rethrow bad_year
+ throw; // rethrow bad_month
}
}
// did m_parser already advance sitr to next char?
@@ -946,7 +1016,7 @@
try {
wd = this->m_parser.parse_weekday(sitr, stream_end, s, mr);
}
- catch(std::out_of_range bad_weekday) { // base class for bad_weekday exception
+ catch(std::out_of_range&) { // base class for bad_weekday exception
if(this->m_sv_parser.match(sitr, stream_end, mr)) {
t = time_type(static_cast<special_values>(mr.current_match));
return sitr;
@@ -982,14 +1052,14 @@
try {
t_day = this->m_parser.parse_day_of_month(sitr, stream_end);
}
- catch(std::out_of_range bad_day_of_month) { // base class for exception
+ catch(std::out_of_range&) { // base class for exception bad_day_of_month
match_results mr;
if(this->m_sv_parser.match(sitr, stream_end, mr)) {
t = time_type(static_cast<special_values>(mr.current_match));
return sitr;
}
else {
- throw; // rethrow bad_year
+ throw; // rethrow bad_day_of_month
}
}
break;
@@ -998,7 +1068,7 @@
case 'H':
{
match_results mr;
- hour = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ hour = fixed_string_to_int<hour_type, CharT>(sitr, stream_end, mr, 2);
if(hour == -1){
return check_special_value(sitr, stream_end, t, c);
}
@@ -1007,30 +1077,23 @@
case 'M':
{
match_results mr;
- min = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ min = fixed_string_to_int<min_type, CharT>(sitr, stream_end, mr, 2);
if(min == -1){
return check_special_value(sitr, stream_end, t, c);
}
break;
}
- case 'S':
- {
- match_results mr;
- sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
- if(sec == -1){
- return check_special_value(sitr, stream_end, t, c);
- }
- break;
- }
case 's':
+ case 'S':
{
match_results mr;
- sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ sec = fixed_string_to_int<sec_type, CharT>(sitr, stream_end, mr, 2);
if(sec == -1){
return check_special_value(sitr, stream_end, t, c);
}
+ if (*itr == 'S')
+ break;
// %s is the same as %S%f so we drop through into %f
- //break;
}
case 'f':
{
@@ -1097,26 +1160,26 @@
}// switch
}
else { // itr == '%', second consecutive
- sitr++;
+ ++sitr;
}
if(use_current_format_char) {
use_current_format_char = false;
}
else {
- itr++; //advance past format specifier
+ ++itr; //advance past format specifier
}
}
else { //skip past chars in format and in buffer
- itr++;
+ ++itr;
// set use_current_char when sitr is already
// pointing at the next character to process
if (use_current_char) {
use_current_char = false;
}
else {
- sitr++;
+ ++sitr;
}
}
}
@@ -1149,7 +1212,8 @@
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);
- throw std::ios_base::failure("Parse failed. No match found for '" + tmp + "'");
+ boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + tmp + "'"));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return sitr); // should never reach
}
tt = temporal_type(static_cast<special_values>(mr.current_match));
return sitr;
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,15 +6,19 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-
-#include "boost/date_time/date_formatting_locales.hpp"
-#include "boost/date_time/time_resolution_traits.hpp"
+#include <boost/date_time/compiler_config.hpp>
#ifndef BOOST_DATE_TIME_NO_LOCALE
+#include <locale>
+#include <iomanip>
+#include <iostream>
+#include <boost/date_time/date_formatting_locales.hpp>
+#include <boost/date_time/time_resolution_traits.hpp>
+
namespace boost {
namespace date_time {
@@ -116,4 +120,3 @@
#endif //BOOST_DATE_TIME_NO_LOCALE
#endif
-
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,26 +2,27 @@
#define DATE_TIME_TIME_RESOLUTION_TRAITS_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
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-04 13:18:59 +0100 (Thu, 04 Jun 2009) $
*/
-#include "boost/date_time/time_defs.hpp"
-#include "boost/date_time/int_adapter.hpp"
-#include "boost/cstdint.hpp"
+#include <boost/cstdint.hpp>
+#include <boost/date_time/time_defs.hpp>
+#include <boost/date_time/int_adapter.hpp>
+#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace date_time {
//! Simple function to calculate absolute value of a numeric type
- template <typename T>
- // JDG [7/6/02 made a template],
+ template <typename T>
+ // JDG [7/6/02 made a template],
// moved here from time_duration.hpp 2003-Sept-4.
- inline T absolute_value(T x)
+ inline T absolute_value(T x)
{
return x < 0 ? -x : x;
}
@@ -58,16 +59,16 @@
//! Used to determine if implemented type is int_adapter or int
static bool is_adapted() { return true;}
};
-
- template<typename frac_sec_type,
+
+ template<typename frac_sec_type,
time_resolutions res,
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
- boost::int64_t resolution_adjust,
+ boost::int64_t resolution_adjust,
#else
- typename frac_sec_type::int_type resolution_adjust,
+ typename frac_sec_type::int_type resolution_adjust,
#endif
- unsigned short frac_digits,
- typename v_type = boost::int32_t >
+ unsigned short frac_digits,
+ typename v_type = boost::int32_t >
class time_resolution_traits {
public:
typedef typename frac_sec_type::int_type fractional_seconds_type;
@@ -77,9 +78,9 @@
typedef v_type hour_type;
typedef v_type min_type;
typedef v_type sec_type;
-
+
// bring in function from frac_sec_type traits structs
- static typename frac_sec_type::int_type as_number(typename frac_sec_type::impl_type i)
+ static fractional_seconds_type as_number(impl_type i)
{
return frac_sec_type::as_number(i);
}
@@ -87,11 +88,14 @@
{
return frac_sec_type::is_adapted();
}
-
+
//Would like this to be frac_sec_type, but some compilers complain
- BOOST_STATIC_CONSTANT(int, ticks_per_second = resolution_adjust);
- // static const boost::int32_t ticks_per_second = resolution_adjust;
-
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ BOOST_STATIC_CONSTANT(boost::int64_t, ticks_per_second = resolution_adjust);
+#else
+ BOOST_STATIC_CONSTANT(fractional_seconds_type, ticks_per_second = resolution_adjust);
+#endif
+
static time_resolutions resolution()
{
return res;
@@ -116,16 +120,16 @@
minutes = absolute_value(minutes);
seconds = absolute_value(seconds);
fs = absolute_value(fs);
- return (((((fractional_seconds_type(hours)*3600)
- + (fractional_seconds_type(minutes)*60)
+ return (((((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)
+ return (((fractional_seconds_type(hours)*3600)
+ + (fractional_seconds_type(minutes)*60)
+ seconds)*res_adjust()) + fs;
}
-
+
};
typedef time_resolution_traits<time_resolution_traits_adapted32_impl, milli, 1000, 3 > milli_res;
Modified: sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-13 20:01:18 +0000 (Thu, 13 Nov 2008) $
*/
@@ -76,7 +76,7 @@
static time_rep_type get_time_rep(const date_type& day,
const time_duration_type& tod,
- date_time::dst_flags dst=not_dst)
+ date_time::dst_flags /* dst */ = not_dst)
{
if(day.is_special() || tod.is_special()) {
if(day.is_not_a_date() || tod.is_not_a_date_time()) {
@@ -132,7 +132,7 @@
}
static std::string zone_name(const time_rep_type&)
{
- return "";
+ return std::string();
}
static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
{
@@ -166,12 +166,9 @@
return add_time_duration(base,td1);
}
- //std::cout << td.ticks() << std::endl;
wrap_int_type day_offset(base.time_of_day.ticks());
date_duration_type day_overflow(static_cast<typename date_duration_type::duration_rep_type>(day_offset.subtract(td.ticks())));
-// std::cout << "sub: " << base.time_of_day.ticks() << "|"
-// << day_offset.as_int() << "|"
-// << day_overflow.days() << std::endl;
+
return time_rep_type(base.day-day_overflow,
time_duration_type(0,0,0,day_offset.as_int()));
}
@@ -185,13 +182,10 @@
time_duration_type td1 = td.invert_sign();
return subtract_time_duration(base,td1);
}
+
wrap_int_type day_offset(base.time_of_day.ticks());
- typename date_duration_type::duration_rep_type doff = day_offset.add(td.ticks());
-// std::cout << "day overflow: " << doff << std::endl;
-// std::cout << "ticks: " << td.ticks() << std::endl;
- date_duration_type day_overflow(doff);
-// std::cout << "base: " << to_simple_string(base.day) << std::endl;
-// std::cout << "overflow " << day_overflow.days() << std::endl;
+ date_duration_type day_overflow(static_cast< typename date_duration_type::duration_rep_type >(day_offset.add(td.ticks())));
+
return time_rep_type(base.day+day_overflow,
time_duration_type(0,0,0,day_offset.as_int()));
}
Modified: sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,20 +5,22 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
-#include "boost/shared_ptr.hpp"
-#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/tokenizer.hpp"
-#include <string>
-#include <sstream>
#include <map>
#include <vector>
-#include <stdexcept>
+#include <string>
+#include <sstream>
#include <fstream>
+#include <stdexcept>
+#include <boost/tokenizer.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/date_time/compiler_config.hpp>
+#include <boost/date_time/time_zone_names.hpp>
+#include <boost/date_time/time_zone_base.hpp>
+#include <boost/date_time/time_parsing.hpp>
namespace boost {
namespace date_time {
@@ -158,7 +160,7 @@
typedef typename time_zone_type::base_type time_zone_base_type;
typedef typename time_zone_type::time_duration_type time_duration_type;
typedef time_zone_names_base<char_type> time_zone_names;
- typedef dst_adjustment_offsets<time_duration_type> dst_adjustment_offsets;
+ typedef boost::date_time::dst_adjustment_offsets<time_duration_type> dst_adjustment_offsets;
typedef std::basic_string<char_type> string_type;
//! Constructs an empty database
@@ -173,7 +175,7 @@
std::ifstream ifs(pathspec.c_str());
if(!ifs){
- throw data_not_accessible(pathspec);
+ boost::throw_exception(data_not_accessible(pathspec));
}
std::getline(ifs, buff); // first line is column headings
@@ -183,13 +185,13 @@
}
//! returns true if record successfully added to map
- /*! Takes an id string in the form of "America/Phoenix", and a
+ /*! Takes a region name in the form of "America/Phoenix", and a
* time_zone object for that region. The id string must be a unique
* name that does not already exist in the database. */
- bool add_record(const string_type& id,
+ bool add_record(const string_type& region,
boost::shared_ptr<time_zone_base_type> tz)
{
- typename map_type::value_type p(id, tz);
+ typename map_type::value_type p(region, tz);
return (m_zone_map.insert(p)).second;
}
@@ -307,7 +309,6 @@
* zone_spec successfully added to database */
bool parse_string(string_type& s)
{
-
std::vector<string_type> result;
typedef boost::token_iterator_generator<boost::escaped_list_separator<char_type>, string_type::const_iterator, string_type >::type token_iter_type;
@@ -326,10 +327,11 @@
//take a shot at fixing gcc 4.x error
const unsigned int expected_fields = static_cast<unsigned int>(FIELD_COUNT);
if (result.size() != expected_fields) {
- std::stringstream msg;
+ std::ostringstream msg;
msg << "Expecting " << FIELD_COUNT << " fields, got "
<< result.size() << " fields in line: " << s;
- throw bad_field_count(msg.str());
+ boost::throw_exception(bad_field_count(msg.str()));
+ BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return false); // should never reach
}
// initializations
Modified: sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp
==============================================================================
--- sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp (original)
+++ sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-01 10:34:04 +0000 (Sat, 01 Nov 2008) $
*/
@@ -43,10 +43,11 @@
* wraps went. Ex: add a negative number and wrapping under could occur,
* this would be indicated by a negative return value. If wrapping over
* took place, a positive value would be returned */
- int_type add(int_type v)
+ template< typename IntT >
+ IntT add(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_val));
- int_type overflow = static_cast<int_type>(v / (wrap_val));
+ IntT overflow = static_cast<IntT>(v / (wrap_val));
value_ = static_cast<int_type>(value_ + remainder);
return calculate_wrap(overflow);
}
@@ -56,26 +57,28 @@
* Ex: subtract a negative number and wrapping over could
* occur, this would be indicated by a negative return value. If
* wrapping under took place, a positive value would be returned. */
- int_type subtract(int_type v)
+ template< typename IntT >
+ IntT subtract(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_val));
- int_type underflow = static_cast<int_type>(-(v / (wrap_val)));
+ IntT underflow = static_cast<IntT>(-(v / (wrap_val)));
value_ = static_cast<int_type>(value_ - remainder);
return calculate_wrap(underflow) * -1;
}
private:
int_type value_;
- int_type calculate_wrap(int_type wrap)
+ template< typename IntT >
+ IntT calculate_wrap(IntT wrap)
{
if ((value_) >= wrap_val)
{
- wrap++;
+ ++wrap;
value_ -= (wrap_val);
}
else if(value_ < 0)
{
- wrap--;
+ --wrap;
value_ += (wrap_val);
}
return wrap;
@@ -114,10 +117,11 @@
* wraps went. Ex: add a negative number and wrapping under could occur,
* this would be indicated by a negative return value. If wrapping over
* took place, a positive value would be returned */
- int_type add(int_type v)
+ template< typename IntT >
+ IntT add(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
- int_type overflow = static_cast<int_type>(v / (wrap_max - wrap_min + 1));
+ IntT overflow = static_cast<IntT>(v / (wrap_max - wrap_min + 1));
value_ = static_cast<int_type>(value_ + remainder);
return calculate_wrap(overflow);
}
@@ -126,10 +130,11 @@
* wraps went. Ex: subtract a negative number and wrapping over could
* occur, this would be indicated by a positive return value. If
* wrapping under took place, a negative value would be returned */
- int_type subtract(int_type v)
+ template< typename IntT >
+ IntT subtract(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
- int_type underflow = static_cast<int_type>(-(v / (wrap_max - wrap_min + 1)));
+ IntT underflow = static_cast<IntT>(-(v / (wrap_max - wrap_min + 1)));
value_ = static_cast<int_type>(value_ - remainder);
return calculate_wrap(underflow);
}
@@ -137,16 +142,17 @@
private:
int_type value_;
- int_type calculate_wrap(int_type wrap)
+ template< typename IntT >
+ IntT calculate_wrap(IntT wrap)
{
if ((value_) > wrap_max)
{
- wrap++;
+ ++wrap;
value_ -= (wrap_max - wrap_min + 1);
}
else if((value_) < wrap_min)
{
- wrap--;
+ --wrap;
value_ += (wrap_max - wrap_min + 1);
}
return wrap;
Added: sandbox/SOC/2008/calendar/libs/date_time/CMakeLists.txt
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/CMakeLists.txt 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -0,0 +1,28 @@
+#
+# Copyright Troy D. Straszheim
+#
+# Distributed under the Boost Software License, Version 1.0.
+# See http://www.boost.org/LICENSE_1_0.txt
+#
+#----------------------------------------------------------------------------
+# This file was automatically generated from the original CMakeLists.txt file
+# Add a variable to hold the headers for the library
+set (lib_headers
+ date_time.hpp
+ date_time
+)
+
+# Add a library target to the build system
+boost_library_project(
+ date_time
+ SRCDIRS src
+ TESTDIRS test
+ HEADERS ${lib_headers}
+ # DOCDIRS
+ DESCRIPTION "A set of date-time libraries based on generic programming concepts."
+ MODULARIZED
+ AUTHORS "Jeff Garland <jeff -at- crystalclearsoftware.com>"
+ # MAINTAINERS
+)
+
+
Added: sandbox/SOC/2008/calendar/libs/date_time/module.cmake
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/module.cmake 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -0,0 +1 @@
+boost_module(date_time DEPENDS algorithm smart_ptr tokenizer io bind serialization)
\ No newline at end of file
Added: sandbox/SOC/2008/calendar/libs/date_time/src/CMakeLists.txt
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/CMakeLists.txt 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -0,0 +1,13 @@
+#
+# Copyright Troy D. Straszheim
+#
+# Distributed under the Boost Software License, Version 1.0.
+# See http://www.boost.org/LICENSE_1_0.txt
+#
+add_definitions(-DBOOST_DATE_TIME_NO_LIB=1)
+boost_add_library(
+ boost_date_time
+ gregorian/greg_month.cpp gregorian/greg_weekday.cpp gregorian/date_generators.cpp
+ STATIC_COMPILE_FLAGS -DBOOST_DATE_TIME_STATIC_LINK
+ SHARED_COMPILE_FLAGS -DBOOST_ALL_DYN_LINK=1
+ )
Modified: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,7 +3,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-22 13:40:54 +0000 (Sat, 22 Nov 2008) $
*/
@@ -75,7 +75,7 @@
special_value_names,
date_time::NumSpecialValues,
s);
- if(i > date_time::NumSpecialValues) { // match not found
+ if(i >= date_time::NumSpecialValues) { // match not found
return not_special;
}
else {
Added: sandbox/SOC/2008/calendar/libs/date_time/test/CMakeLists.txt
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/CMakeLists.txt 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -0,0 +1,187 @@
+boost_additional_test_dependencies(date_time BOOST_DEPENDS test bind)
+
+# Core
+boost_test_run(testint_adapter)
+boost_test_run(testtime_resolution_traits)
+boost_test_run(testwrapping_int)
+boost_test_run(testconstrained_value)
+boost_test_run(testgregorian_calendar)
+boost_test_run(testgeneric_period)
+
+set(DATE_TIME_COMPILE_FLAGS
+ "-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_DATE_TIME_STATIC_LINK -DBOOST_ALL_NO_LIB")
+set(DATE_TIME_SHARED_COMPILE_FLAGS
+ "-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB")
+
+# A macro that collects the common settings used to build a run test
+# for the Date-Time library that links statically.
+macro(date_time_static_test SUBDIR TESTNAME)
+ boost_test_run(${TESTNAME}
+ "${SUBDIR}/${TESTNAME}.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS ${DATE_TIME_COMPILE_FLAGS})
+endmacro(date_time_static_test)
+
+# A macro that collects the common settings used to build a run test
+# for the Date-Time library that links dynamically.
+macro(date_time_shared_test SUBDIR TESTNAME)
+ boost_test_run("${TESTNAME}_dll"
+ "${SUBDIR}/${TESTNAME}.cpp"
+ DEPENDS boost_date_time SHARED
+ COMPILE_FLAGS ${DATE_TIME_SHARED_COMPILE_FLAGS})
+endmacro(date_time_shared_test)
+
+# Gregorian
+date_time_static_test(gregorian testdate)
+date_time_static_test(gregorian testdate_duration)
+date_time_static_test(gregorian testgreg_durations)
+date_time_static_test(gregorian testperiod)
+date_time_static_test(gregorian testdate_iterator)
+date_time_static_test(gregorian testformatters)
+### streaming
+date_time_static_test(gregorian testdate_facet_new)
+date_time_static_test(gregorian testdate_input_facet)
+###
+date_time_static_test(gregorian testgenerators)
+date_time_static_test(gregorian testgreg_cal)
+date_time_static_test(gregorian testgreg_day)
+date_time_static_test(gregorian testgreg_month)
+date_time_static_test(gregorian testgreg_year)
+
+date_time_shared_test(gregorian testdate)
+date_time_shared_test(gregorian testdate_duration)
+date_time_shared_test(gregorian testgreg_durations)
+date_time_shared_test(gregorian testperiod)
+date_time_shared_test(gregorian testdate_iterator)
+date_time_shared_test(gregorian testformatters)
+### streaming
+date_time_shared_test(gregorian testdate_facet_new)
+date_time_shared_test(gregorian testdate_input_facet)
+###
+date_time_shared_test(gregorian testgenerators)
+date_time_shared_test(gregorian testgreg_cal)
+date_time_shared_test(gregorian testgreg_day)
+date_time_shared_test(gregorian testgreg_month)
+date_time_shared_test(gregorian testgreg_year)
+
+# POSIX Time
+date_time_static_test(posix_time testfiletime_functions)
+date_time_static_test(posix_time testlocal_adjustor)
+date_time_static_test(posix_time testc_local_adjustor)
+date_time_static_test(posix_time testclock)
+date_time_static_test(posix_time testdst_rules)
+date_time_static_test(posix_time testduration)
+date_time_static_test(posix_time testiterator)
+date_time_static_test(posix_time testparse_time)
+date_time_static_test(posix_time testtime_period)
+date_time_static_test(posix_time testtime)
+date_time_static_test(posix_time testmicrosec_time_clock)
+date_time_static_test(posix_time testtime_formatters)
+date_time_static_test(posix_time testgreg_duration_operators)
+### streaming
+date_time_static_test(posix_time testtime_facet)
+date_time_static_test(posix_time testtime_input_facet)
+###
+
+# Wide streaming
+boost_test_run(testgreg_wstream
+ "gregorian/testgreg_wstream.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+boost_test_run(testtime_wstream
+ "posix_time/testtime_wstream.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+
+# Pre-1.33 facets
+boost_test_run(testfacet_dll
+ "gregorian/testfacet.cpp"
+ DEPENDS boost_date_time SHARED
+ COMPILE_FLAGS "${DATE_TIME_SHARED_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+# Note: This next test was commented out in the Jamfile.v2 because "it
+# crashes on VC6 (cause unknown)"
+boost_test_run(testparse_date_dll
+ "gregorian/testparse_date.cpp"
+ DEPENDS boost_date_time SHARED
+ COMPILE_FLAGS "${DATE_TIME_SHARED_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+boost_test_run(testfacet
+ "gregorian/testfacet.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+boost_test_run(testparse_date
+ "gregorian/testparse_date.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+boost_test_run(teststreams
+ "posix_time/teststreams.cpp"
+ DEPENDS boost_date_time STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+
+# Local time
+date_time_static_test(local_time testdst_transition_day_rule)
+date_time_static_test(local_time testcustom_time_zone)
+date_time_static_test(local_time testposix_time_zone)
+date_time_static_test(local_time testwcustom_time_zone)
+date_time_static_test(local_time testwposix_time_zone)
+
+# we have to copy these into the binary dir because to make the
+# paths inside the tests match
+if (NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+ FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/libs/date_time/data")
+ execute_process(COMMAND cmake -E copy "${CMAKE_SOURCE_DIR}/libs/date_time/data/date_time_zonespec.csv" "${CMAKE_BINARY_DIR}/libs/date_time/data")
+ FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/libs/date_time/test/local_time")
+ execute_process(COMMAND cmake -E copy "${CMAKE_SOURCE_DIR}/libs/date_time/test/local_time/poorly_formed_zonespec.csv" "${CMAKE_BINARY_DIR}/libs/date_time/test/local_time")
+endif (NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+
+date_time_static_test(local_time testtz_database)
+date_time_static_test(local_time testlocal_time)
+date_time_static_test(local_time testlocal_time_iterator)
+date_time_static_test(local_time testlocal_time_period)
+### streaming
+date_time_static_test(local_time testlocal_time_facet)
+date_time_static_test(local_time testlocal_time_input_facet)
+###
+date_time_static_test(local_time testclocks)
+
+
+set(DATE_TIME_COMPILE_FLAGS
+ "-DBOOST_DATE_TIME_STATIC_LINK -DBOOST_ALL_NO_LIB -DUSE_DATE_TIME_PRE_1_33_FACET_IO")
+
+# Serialization
+ # xml archive tests
+boost_test_run(testgreg_serialize_xml
+ "gregorian/testgreg_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DDATE_TIME_XML_SERIALIZE")
+boost_test_run(testtime_serialize_xml_std_config
+ "posix_time/testtime_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DDATE_TIME_XML_SERIALIZE")
+boost_test_run(testtime_serialize_xml
+ "posix_time/testtime_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DDATE_TIME_XML_SERIALIZE")
+
+ # text archive tests
+boost_test_run(testgreg_serialize
+ "gregorian/testgreg_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS}")
+boost_test_run(testgreg_serialize_dll
+ "gregorian/testgreg_serialize.cpp"
+ DEPENDS boost_date_time SHARED boost_serialization SHARED
+ COMPILE_FLAGS "${DATE_TIME_SHARED_COMPILE_FLAGS}")
+boost_test_run(testtime_serialize_std_config
+ "posix_time/testtime_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG")
+boost_test_run(testtime_serialize
+ "posix_time/testtime_serialize.cpp"
+ DEPENDS boost_date_time boost_serialization STATIC
+ COMPILE_FLAGS "${DATE_TIME_COMPILE_FLAGS}")
+
+# Copyright (c) 2000-2005
+# CrystalClear Software, Inc.
+# Subject to the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE-1.0 or
+# http://www.boost.org/LICENSE-1.0)
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2 (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -1,7 +1,7 @@
local DATE_TIME_DYNAMIC_PROPERTIES = <define>BOOST_ALL_DYN_LINK <runtime-link>shared <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_NO_LIB ;
-local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_DATE_TIME_STATIC_LINK
+local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_DATE_TIME_STATIC_LINK
# FIXME
#std::locale-support
<define>BOOST_ALL_NO_LIB ;
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
@@ -136,7 +136,7 @@
//never reached if working -- but stops compiler warnings :-)
std::cout << "Oops: " << to_iso_string(d9) << std::endl;
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("day out of range", true);
}
try {
@@ -145,7 +145,7 @@
//never reached if working -- but stops compiler warnings :-)
std::cout << "Oops: " << to_iso_string(d9) << std::endl;
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("day out of range", true);
}
@@ -155,7 +155,7 @@
//never reached if working -- but stops compiler warnings :-)
std::cout << "Oops: " << to_iso_string(d20) << std::endl;
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("day out of range", true);
}
@@ -166,7 +166,7 @@
//never reached if working -- but stops compiler warnings :-)
std::cout << "Oops: " << to_iso_string(d21) << std::endl;
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("day out of range", true);
}
@@ -176,7 +176,7 @@
check("last day of month ok", true);
std::cout << to_iso_string(d22) << std::endl; //stop compiler warning
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("last day of month -- oops bad exception", false);
}
@@ -187,7 +187,7 @@
//never reached if working -- but stops compiler warnings :-)
std::cout << "Oops: " << to_iso_string(d23) << std::endl;
}
- catch (bad_day_of_month) {
+ catch (bad_day_of_month&) {
check("day out of range", true);
}
@@ -281,7 +281,7 @@
date d(neg_infin);
tm d_tm = to_tm(d);
check("Exception not thrown (special_value to_tm)", false);
- }catch(std::out_of_range e){
+ }catch(std::out_of_range& e){
check("Caught expected exception (special_value to_tm)", true);
}catch(...){
check("Caught un-expected exception (special_value to_tm)", false);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -5,20 +5,20 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-01 10:02:43 +0100 (Mon, 01 Jun 2009) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/date_facet.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
#include <sstream>
template<class temporal_type, typename charT>
inline
-void
-teststreaming(std::string testname,
+void
+teststreaming(std::string testname,
temporal_type value,
std::basic_string<charT> expected_result,
const std::locale& locale = std::locale::classic())
@@ -26,7 +26,7 @@
std::basic_stringstream<charT> ss;
ss.imbue(locale);
ss << value;
- check(testname, ss.str() == expected_result);
+ check_equal(testname, ss.str(), expected_result);
}
@@ -76,20 +76,20 @@
int main() {
using namespace boost::gregorian;
-
- std::copy(&month_short_names[0],
+
+ std::copy(&month_short_names[0],
&month_short_names[12],
std::back_inserter(short_month_names));
- std::copy(&month_long_names[0],
+ std::copy(&month_long_names[0],
&month_long_names[12],
std::back_inserter(long_month_names));
- std::copy(&weekday_short_names[0],
+ std::copy(&weekday_short_names[0],
&weekday_short_names[7],
std::back_inserter(short_weekday_names));
- std::copy(&weekday_long_names[0],
+ std::copy(&weekday_long_names[0],
&weekday_long_names[7],
std::back_inserter(long_weekday_names));
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,11 +3,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-01 10:02:43 +0100 (Mon, 01 Jun 2009) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
#include <sstream>
#include <string>
@@ -18,7 +18,7 @@
template<class temporal_type, class exception_type>
bool failure_test(temporal_type component,
const std::string& input,
- exception_type /*except*/,
+ exception_type const& /*except*/,
boost::gregorian::date_input_facet* facet)
{
using namespace boost::gregorian;
@@ -29,7 +29,7 @@
try {
iss >> component;
}
- catch(exception_type e) {
+ catch(exception_type& e) {
std::cout << "Expected exception caught: \""
<< e.what() << "\"" << std::endl;
result = iss.fail(); // failbit must be set to pass test
@@ -100,17 +100,17 @@
// default format tests: date, days, month, weekday, day, year
std::istringstream iss("2005-Jan-15 21 Feb Tue 4 2002");
iss >> d;
- check("Default format date", d == date(2005,Jan,15));
+ check_equal("Default format date", d, date(2005,Jan,15));
iss >> dd;
- check("Default (only) format positive days", dd == days(21));
+ check_equal("Default (only) format positive days", dd, days(21));
iss >> m;
- check("Default format month", m == greg_month(2));
+ check_equal("Default format month", m, greg_month(2));
iss >> gw;
- check("Default format weekday", gw == greg_weekday(2));
+ check_equal("Default format weekday", gw, greg_weekday(2));
iss >> gd;
- check("Default (only) format day of month", gd == greg_day(4));
+ check_equal("Default (only) format day of month", gd, greg_day(4));
iss >> gy;
- check("Default format year", gy == greg_year(2002));
+ check_equal("Default format year", gy, greg_year(2002));
// failure tests
check("Input Misspelled in year (date) w/exceptions",
failure_test(d, "205-Jan-15", e_bad_year, new date_input_facet()));
@@ -151,15 +151,15 @@
iss.imbue(std::locale(std::locale::classic(), facet));
iss >> d;
- check("ISO format date", d == date(2005,Jan,15));
+ check_equal("ISO format date", d, date(2005,Jan,15));
iss >> dd;
- check("Default (only) format negative days", dd == days(-55));
+ check_equal("Default (only) format negative days", dd, days(-55));
iss >> m;
- check("Full format month", m == greg_month(2));
+ check_equal("Full format month", m, greg_month(2));
iss >> gw;
- check("Full format weekday", gw == greg_weekday(2));
+ check_equal("Full format weekday", gw, greg_weekday(2));
iss >> gy;
- check("2 digit format year", gy == greg_year(2002));
+ check_equal("2 digit format year", gy, greg_year(2002));
date_input_facet* f1 = new date_input_facet();
date_input_facet* f2 = new date_input_facet();
@@ -177,41 +177,41 @@
date_input_facet* f = new date_input_facet("%%d %Y-%b-%d");
std::stringstream ss;
ss.imbue(std::locale(ss.getloc(), f));
-
+
ss.str("%d 2005-Jun-14");
ss >> d;
- check("Literal '%' in date format", d == date(2005,Jun,14));
+ check_equal("Literal '%' in date format", d, date(2005,Jun,14));
f->format("%%%d %Y-%b-%d");
ss.str("%14 2005-Jun-14");
ss >> d;
- check("Multiple literal '%'s in date format", d == date(2005,Jun,14));
-
+ check_equal("Multiple literal '%'s in date format", d, date(2005,Jun,14));
+
f->month_format("%%b %b");
ss.str("%b Jun");
ss >> m;
- check("Literal '%' in month format", m == greg_month(6));
+ check_equal("Literal '%' in month format", m, greg_month(6));
f->month_format("%%%b");
ss.str("%Jun");
ss >> m;
- check("Multiple literal '%'s in month format", m == greg_month(6));
-
+ check_equal("Multiple literal '%'s in month format", m, greg_month(6));
+
f->weekday_format("%%a %a");
ss.str("%a Tue");
ss >> gw;
- check("Literal '%' in weekday format", gw == greg_weekday(2));
+ check_equal("Literal '%' in weekday format", gw, greg_weekday(2));
f->weekday_format("%%%a");
ss.str("%Tue");
ss >> gw;
- check("Multiple literal '%'s in weekday format", gw == greg_weekday(2));
-
+ check_equal("Multiple literal '%'s in weekday format", gw, greg_weekday(2));
+
f->year_format("%%Y %Y");
ss.str("%Y 2005");
ss >> y;
- check("Literal '%' in year format", y == greg_year(2005));
+ check_equal("Literal '%' in year format", y, greg_year(2005));
f->year_format("%%%Y");
ss.str("%2005");
ss >> y;
- check("Multiple literal '%'s in year format", y == greg_year(2005));
+ check_equal("Multiple literal '%'s in year format", y, greg_year(2005));
}
// All days, month, weekday, day, and year formats have been tested
@@ -219,22 +219,22 @@
facet->set_iso_extended_format();
iss.str("2005-01-15");
iss >> d;
- check("ISO Extended format date", d == date(2005,Jan,15));
+ check_equal("ISO Extended format date", d, date(2005,Jan,15));
facet->format("%B %d, %Y");
iss.str("March 15, 2006");
iss >> d;
- check("Custom date format: \"%B %d, %Y\" => 'March 15, 2006'",
- d == date(2006,Mar,15));
+ check_equal("Custom date format: \"%B %d, %Y\" => 'March 15, 2006'",
+ d, date(2006,Mar,15));
facet->format("%Y-%j"); // Ordinal format ISO8601(2000 sect 5.2.2.1 extended)
iss.str("2006-074");
iss >> d;
- check("Custom date format: \"%Y-%j\" => '2006-074'",
- d == date(2006,Mar,15));
- check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (w/exceptions)",
+ check_equal("Custom date format: \"%Y-%j\" => '2006-074'",
+ d, date(2006,Mar,15));
+ check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (w/exceptions)",
failure_test(d, "2006-74", e_bad_day_of_year, facet));
- check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (no exceptions)",
+ check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (no exceptions)",
failure_test(d, "2006-74", facet));
// date_period tests
@@ -250,7 +250,7 @@
iss.str("[2002-07-04/2002-07-24]");
facet->set_iso_extended_format();
iss >> dp;
- check("Default period (closed range)", dp == date_period(begin,len));
+ check_equal("Default period (closed range)", dp, date_period(begin,len));
{
std::stringstream ss;
date d(not_a_date_time);
@@ -262,32 +262,32 @@
date_period dp3(d3, d4);
ss << dp;
ss >> dp2;
- check("Special values period (reversibility test)", dp == dp2);
+ check_equal("Special values period (reversibility test)", dp, dp2);
ss.str("[-infinity/+infinity]");
ss >> dp2;
- check("Special values period (infinities)", dp3 == dp2);
+ check_equal("Special values period (infinities)", dp3, dp2);
}
-
+
// open range
period_parser pp(period_parser::AS_OPEN_RANGE);
iss.str("[2002-07-04/2002-07-25)");
facet->period_parser(pp);
iss >> dp;
- check("Open range period", dp == date_period(begin,len));
+ check_equal("Open range period", dp, date_period(begin,len));
// custom period delimiters
pp.delimiter_strings(" to ", "from ", " exclusive", " inclusive");
iss.str("from 2002-07-04 to 2002-07-25 exclusive");
facet->period_parser(pp);
iss >> dp;
- check("Open range period - custom delimiters", dp == date_period(begin,len));
+ check_equal("Open range period - custom delimiters", dp, date_period(begin,len));
pp.range_option(period_parser::AS_CLOSED_RANGE);
iss.str("from 2002-07-04 to 2002-07-24 inclusive");
facet->period_parser(pp);
iss >> dp;
- check("Closed range period - custom delimiters", dp == date_period(begin,len));
+ check_equal("Closed range period - custom delimiters", dp, date_period(begin,len));
+
-
// date_generator tests
// date_generators use formats contained in the
@@ -304,30 +304,30 @@
first_kday_after fka(Sunday);
// using default date_generator_parser "nth_strings"
iss.str("29 Feb");
- iss >> pd;
+ iss >> pd;
// Feb-29 is a valid date_generator, get_date() will fail in a non-leap year
- check("Default strings, partial_date",
- pd.get_date(2004) == date(2004,Feb,29));
+ check_equal("Default strings, partial_date",
+ pd.get_date(2004), date(2004,Feb,29));
iss.str("second Mon of Mar");
iss >> nkd;
- check("Default strings, nth_day_of_the_week_in_month",
- nkd.get_date(2004) == date(2004,Mar,8));
+ check_equal("Default strings, nth_day_of_the_week_in_month",
+ nkd.get_date(2004), date(2004,Mar,8));
iss.str("first Tue of Apr");
- iss >> fkd;
- check("Default strings, first_day_of_the_week_in_month",
- fkd.get_date(2004) == date(2004,Apr,6));
+ iss >> fkd;
+ check_equal("Default strings, first_day_of_the_week_in_month",
+ fkd.get_date(2004), date(2004,Apr,6));
iss.str("last Wed of May");
- iss >> lkd;
- check("Default strings, last_day_of_the_week_in_month",
- lkd.get_date(2004) == date(2004,May,26));
+ iss >> lkd;
+ check_equal("Default strings, last_day_of_the_week_in_month",
+ lkd.get_date(2004), date(2004,May,26));
iss.str("Thu before");
- iss >> fkb;
- check("Default strings, first_day_of_the_week_before",
- fkb.get_date(date(2004,Feb,8)) == date(2004,Feb,5));
+ iss >> fkb;
+ check_equal("Default strings, first_day_of_the_week_before",
+ fkb.get_date(date(2004,Feb,8)), date(2004,Feb,5));
iss.str("Fri after");
- iss >> fka;
- check("Default strings, first_day_of_the_week_after",
- fka.get_date(date(2004,Feb,1)) == date(2004,Feb,6));
+ iss >> fka;
+ check_equal("Default strings, first_day_of_the_week_after",
+ fka.get_date(date(2004,Feb,1)), date(2004,Feb,6));
// failure tests
check("Incorrect elements (date_generator) w/exceptions", // after/before type mixup
failure_test(fkb, "Fri after", e_failure, new date_input_facet()));
@@ -337,67 +337,73 @@
failure_test(lkd, "first Tue of Apr", e_failure, new date_input_facet()));
check("Incorrect elements (date_generator) no exceptions", // first/last type mixup
failure_test(lkd, "first Tue of Apr", new date_input_facet()));
- check("Incorrect elements (date_generator) w/exceptions", // 'in' is wrong
+ check("Incorrect elements (date_generator) w/exceptions", // 'in' is wrong
failure_test(nkd, "second Mon in Mar", e_failure, new date_input_facet()));
- check("Incorrect elements (date_generator) no exceptions", // 'in' is wrong
+ check("Incorrect elements (date_generator) no exceptions", // 'in' is wrong
failure_test(nkd, "second Mon in Mar", new date_input_facet()));
// date_generators - custom element strings
facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past","in");
iss.str("3rd Sat in Jul");
iss >> nkd;
- check("Custom strings, nth_day_of_the_week_in_month",
- nkd.get_date(2004) == date(2004,Jul,17));
+ check_equal("Custom strings, nth_day_of_the_week_in_month",
+ nkd.get_date(2004), date(2004,Jul,17));
iss.str("1st Wed in May");
- iss >> fkd;
- check("Custom strings, first_day_of_the_week_in_month",
- fkd.get_date(2004) == date(2004,May,5));
+ iss >> fkd;
+ check_equal("Custom strings, first_day_of_the_week_in_month",
+ fkd.get_date(2004), date(2004,May,5));
iss.str("final Tue in Apr");
- iss >> lkd;
- check("Custom strings, last_day_of_the_week_in_month",
- lkd.get_date(2004) == date(2004,Apr,27));
+ iss >> lkd;
+ check_equal("Custom strings, last_day_of_the_week_in_month",
+ lkd.get_date(2004), date(2004,Apr,27));
iss.str("Fri prior to");
- iss >> fkb;
- check("Custom strings, first_day_of_the_week_before",
- fkb.get_date(date(2004,Feb,8)) == date(2004,Feb,6));
+ iss >> fkb;
+ check_equal("Custom strings, first_day_of_the_week_before",
+ fkb.get_date(date(2004,Feb,8)), date(2004,Feb,6));
iss.str("Thu past");
- iss >> fka;
- check("Custom strings, first_day_of_the_week_after",
- fka.get_date(date(2004,Feb,1)) == date(2004,Feb,5));
+ iss >> fka;
+ check_equal("Custom strings, first_day_of_the_week_after",
+ fka.get_date(date(2004,Feb,1)), date(2004,Feb,5));
// date_generators - special case with empty element string
/* Doesn't work. Empty string returns -1 from string_parse_tree
* because it attempts to match the next set of characters in the
* stream to the wrong element. Ex. It attempts to match "Mar" to
* the 'of' element in the test below.
- *
+ *
facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past",""); // the 'of' string is an empty string
iss.str("final Mon Mar");
- iss >> lkd;
- check("Special case, empty element string",
- lkd.get_date(2005) == date(2005,Mar,28));
+ iss >> lkd;
+ check_equal("Special case, empty element string",
+ lkd.get_date(2005), date(2005,Mar,28));
*/
-
+
// special values tests (date and days only)
iss.str("minimum-date-time +infinity");
iss >> d;
iss >> dd;
- check("Special values, default strings, min_date_time date",
- d == date(min_date_time));
- check("Special values, default strings, pos_infin days",
- dd == days(pos_infin));
+ check_equal("Special values, default strings, min_date_time date",
+ d, date(min_date_time));
+ check_equal("Special values, default strings, pos_infin days",
+ dd, days(pos_infin));
iss.str("-infinity maximum-date-time");
iss >> d;
iss >> dd;
- check("Special values, default strings, neg_infin date",
- d == date(neg_infin));
- check("Special values, default strings, max_date_time days",
- dd == days(max_date_time));
+ check_equal("Special values, default strings, neg_infin date",
+ d, date(neg_infin));
+ check_equal("Special values, default strings, max_date_time days",
+ dd, days(max_date_time));
iss.str("not-a-date-time");
iss >> d;
- check("Special values, default strings, not_a_date_time date",
- d == date(not_a_date_time));
+ check_equal("Special values, default strings, not_a_date_time date",
+ d, date(not_a_date_time));
+
+ // in addition check that special_value_from_string also works correctly for other special values
+ check_equal("Special values, default strings, not_special test",
+ special_value_from_string("not_special"), not_special);
+ check_equal("Special values, default strings, junk test",
+ special_value_from_string("junk"), not_special);
// special values custom, strings
special_values_parser svp("NADT", "MINF", "INF", "MINDT", "MAXDT");
@@ -405,33 +411,33 @@
iss.str("MINDT INF");
iss >> d;
iss >> dd;
- check("Special values, custom strings, min_date_time date",
- d == date(min_date_time));
- check("Special values, custom strings, pos_infin days",
- dd == days(pos_infin));
+ check_equal("Special values, custom strings, min_date_time date",
+ d, date(min_date_time));
+ check_equal("Special values, custom strings, pos_infin days",
+ dd, days(pos_infin));
iss.str("MINF MAXDT");
iss >> d;
iss >> dd;
- check("Special values, custom strings, neg_infin date",
- d == date(neg_infin));
- check("Special values, custom strings, max_date_time days",
- dd == days(max_date_time));
+ check_equal("Special values, custom strings, neg_infin date",
+ d, date(neg_infin));
+ check_equal("Special values, custom strings, max_date_time days",
+ dd, days(max_date_time));
iss.str("NADT");
iss >> dd;
- check("Special values, custom strings, not_a_date_time days",
- dd == days(not_a_date_time));
+ check_equal("Special values, custom strings, not_a_date_time days",
+ dd, days(not_a_date_time));
// failure test
- check("Misspelled input, special_value date w/exceptions",
+ check("Misspelled input, special_value date w/exceptions",
failure_test(d, "NSDT", e_bad_year, new date_input_facet()));
- check("Misspelled input, special_value date no exceptions",
+ check("Misspelled input, special_value date no exceptions",
failure_test(d, "NSDT", new date_input_facet()));
- check("Misspelled input, special_value days w/exceptions",
+ check("Misspelled input, special_value days w/exceptions",
failure_test(dd, "NSDT", e_failure, new date_input_facet()));
- check("Misspelled input, special_value days no exceptions",
+ check("Misspelled input, special_value days no exceptions",
failure_test(dd, "NSDT", new date_input_facet()));
{
- // German names. Please excuse any errors, I don't speak German and
+ // German names. Please excuse any errors, I don't speak German and
// had to rely on an on-line translation service.
// These tests check one of each (at least) from all sets of custom strings
@@ -454,7 +460,7 @@
wkdays_abbrev.assign(w_a, w_a+7);
wkdays_full.assign(w_f, w_f+7);
date_parser d_parser("%B %d %Y",
- months_abbrev, months_full,
+ months_abbrev, months_full,
wkdays_abbrev, wkdays_full);
// create a special_values parser
@@ -472,7 +478,7 @@
"Fünft","Letzt","Vor","Nach","Von");
// create the date_input_facet
- date_input_facet* de_facet =
+ date_input_facet* de_facet =
new date_input_facet("%B %d %Y",
d_parser,
sv_parser,
@@ -484,25 +490,25 @@
iss.str("Juni 06 2005 Dez Wenigstes Datum Die");
iss >> d;
iss >> m;
- check("German names: date", d == date(2005, Jun, 6));
- check("German names: month", m == greg_month(Dec));
+ check_equal("German names: date", d, date(2005, Jun, 6));
+ check_equal("German names: month", m, greg_month(Dec));
iss >> d;
iss >> gw;
- check("German names: special value date", d == date(min_date_time));
- check("German names: short weekday", gw == greg_weekday(Tuesday));
+ check_equal("German names: special value date", d, date(min_date_time));
+ check_equal("German names: short weekday", gw, greg_weekday(Tuesday));
de_facet->weekday_format("%A"); // long weekday
// Tuesday, Second Tuesday of Mar
iss.str("Dienstag Zweitens Dienstag von Mar");
iss >> gw;
iss >> nkd;
- check("German names: long weekday", gw == greg_weekday(Tuesday));
- check("German names, nth_day_of_the_week_in_month",
- nkd.get_date(2005) == date(2005,Mar,8));
+ check_equal("German names: long weekday", gw, greg_weekday(Tuesday));
+ check_equal("German names, nth_day_of_the_week_in_month",
+ nkd.get_date(2005), date(2005,Mar,8));
// Tuesday after
iss.str("Dienstag Nach");
- iss >> fka;
- check("German names, first_day_of_the_week_after",
- fka.get_date(date(2005,Apr,5)) == date(2005,Apr,12));
+ iss >> fka;
+ check_equal("German names, first_day_of_the_week_after",
+ fka.get_date(date(2005,Apr,5)), date(2005,Apr,12));
}
{
@@ -519,25 +525,25 @@
"**October**","**November**","**December**"};
const char* const weekday_short_names[]={"day1", "day2","day3","day4",
"day5","day6","day7"};
- const char* const weekday_long_names[]= {"Sun-0", "Mon-1", "Tue-2",
- "Wed-3", "Thu-4",
+ const char* const weekday_long_names[]= {"Sun-0", "Mon-1", "Tue-2",
+ "Wed-3", "Thu-4",
"Fri-5", "Sat-6"};
std::vector<std::basic_string<char> > short_weekday_names;
std::vector<std::basic_string<char> > long_weekday_names;
std::vector<std::basic_string<char> > short_month_names;
std::vector<std::basic_string<char> > long_month_names;
-
- std::copy(&weekday_short_names[0],
+
+ std::copy(&weekday_short_names[0],
&weekday_short_names[7],
std::back_inserter(short_weekday_names));
- std::copy(&weekday_long_names[0],
+ std::copy(&weekday_long_names[0],
&weekday_long_names[7],
std::back_inserter(long_weekday_names));
- std::copy(&month_short_names[0],
+ std::copy(&month_short_names[0],
&month_short_names[12],
std::back_inserter(short_month_names));
- std::copy(&month_long_names[0],
+ std::copy(&month_long_names[0],
&month_long_names[12],
std::back_inserter(long_month_names));
@@ -552,20 +558,20 @@
facet->format("%a %b %d, %Y");
ss.str("day7 *apr* 23, 2005");
ss >> d;
- check("Short custom names, set via accessor function", d.day_of_week() == greg_weekday(6));
- check("Short custom names, set via accessor function", d.month() == greg_month(4));
+ check_equal("Short custom names, set via accessor function", d.day_of_week(), greg_weekday(6));
+ check_equal("Short custom names, set via accessor function", d.month(), greg_month(4));
ss.str("");
ss.str("Sun-0 **April** 24, 2005");
facet->format("%A %B %d, %Y");
ss >> d;
- check("Long custom names, set via accessor function", d.day_of_week() == greg_weekday(0));
- check("Long custom names, set via accessor function", d.month() == greg_month(4));
+ check_equal("Long custom names, set via accessor function", d.day_of_week(), greg_weekday(0));
+ check_equal("Long custom names, set via accessor function", d.month(), greg_month(4));
}
#else
- check("This test is a nop for platforms with USE_DATE_TIME_PRE_1_33_FACET_IO",
+ check("This test is a nop for platforms with USE_DATE_TIME_PRE_1_33_FACET_IO",
true);
#endif
return printTestStats();
}
-
+
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -13,7 +13,7 @@
#include "boost/date_time/gregorian/greg_facet.hpp"
#include "boost/date_time/date_format_simple.hpp"
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#ifndef BOOST_DATE_TIME_NO_LOCALE
@@ -295,7 +295,7 @@
try{
ss2 >> m; // misspelled
check("Bad month exception NOT thrown (misspelled name)", false);
- }catch(bad_month){
+ }catch(bad_month&){
check("Bad month exception caught (misspelled name)", true);
}catch(...){
check("Bad month exception NOT caught (misspelled name)", false);
@@ -324,7 +324,7 @@
try{
ss2 >> wd;
check("Bad weekday exception NOT thrown (misspelled name)", false);
- }catch(bad_weekday){
+ }catch(bad_weekday&){
check("Bad weekday exception caught (misspelled name)", true);
}catch(...){
check("Bad weekday exception NOT caught (misspelled name)", false);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/date_time/format_date_parser.hpp"
#include <sstream>
#include <algorithm>
@@ -66,7 +66,7 @@
void
wtest_format(const std::basic_string<wchar_t>& format,
const std::basic_string<wchar_t>& value,
- const std::string testname,
+ const std::string& testname,
boost::gregorian::date expected_res)
{
typedef boost::date_time::format_date_parser<date, wchar_t> parser_type;
@@ -75,19 +75,18 @@
try {
// string_type format(format);
std::basic_stringstream<wchar_t> ws;
- ws << value;
+ ws << value;
iter_type sitr(ws);
iter_type stream_end;
-
+
parser_type p(format, wshort_month_names, wlong_month_names,
wshort_week_names, wlong_week_names);
date d = p.parse_date(sitr, stream_end, format);
- check(testname, d == expected_res);
+ check_equal(testname, d, expected_res);
}
catch(std::exception& e) {
std::cout << "Got an exception: " << e.what() << std::endl;
check(testname, false);
-
}
}
@@ -95,7 +94,7 @@
void
test_format(const std::basic_string<char>& format,
const std::basic_string<char>& value,
- const std::string testname,
+ const std::string& testname,
boost::gregorian::date expected_res)
{
typedef boost::date_time::format_date_parser<date, char> parser_type;
@@ -107,16 +106,15 @@
ws << value;
iter_type sitr(ws);
iter_type stream_end;
-
+
parser_type pt(format, short_month_names, long_month_names,
short_week_names, long_week_names);
date d = pt.parse_date(sitr, stream_end, format);
- check(testname, d == expected_res);
+ check_equal(testname, d, expected_res);
}
catch(std::exception& e) {
std::cout << "Got an exception: " << e.what() << std::endl;
check(testname, false);
-
}
}
@@ -126,24 +124,22 @@
test_format2(boost::date_time::format_date_parser<date, charT>& parser,
const charT* const format,
const charT* const value,
- const std::string testname,
+ const std::string& testname,
boost::gregorian::date expected_res)
{
try {
date d = parser.parse_date(value, format);
- check(testname, d == expected_res);
+ check_equal(testname, d == expected_res);
}
catch(std::exception& e) {
std::cout << "Got an exception: " << e.what() << std::endl;
check(testname, false);
-
}
}
int
main()
{
-
std::copy(&wmonth_short_names[0],
&wmonth_short_names[12],
std::back_inserter(wshort_month_names));
@@ -231,15 +227,15 @@
"%A %B %d, %Y", date(2004,3,15));
// bad format case...
-
- {
+
+ {
try {
std::wstring format(L"%Y-%d");
std::wstringstream ws;
ws << L"2004-12-31";
std::istreambuf_iterator<wchar_t> sitr(ws);
std::istreambuf_iterator<wchar_t> stream_end;
-
+
boost::date_time::format_date_parser<date,wchar_t> pt(format,
wshort_month_names,
wlong_month_names,
@@ -359,7 +355,7 @@
"long strings from locale", date(2004,Nov,1));
test_format2(parser, "%A %B %d, %Y", "thursday december 31, 2004",
"long strings from locale", date(2004,Dec,31));
-
+
}
return printTestStats();
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
#include <string>
#include <sstream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/greg_calendar.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include "boost/date_time/gregorian/greg_day.hpp"
#include "boost/date_time/gregorian/greg_weekday.hpp"
#include "boost/date_time/gregorian/greg_day_of_year.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int main(){
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/greg_month.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -12,8 +12,8 @@
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/gregorian/greg_serialize.hpp>
-#include <boost/date_time/testfrmwk.hpp>
-#include <fstream>
+#include "../testfrmwk.hpp"
+#include <sstream>
using namespace boost;
using namespace gregorian;
@@ -25,16 +25,16 @@
}
int main(){
- std::ofstream ofs("tmp_file");
+ std::ostringstream oss;
// NOTE: DATE_TIME_XML_SERIALIZE is only used in testing and is
// defined in the testing Jamfile
#if defined(DATE_TIME_XML_SERIALIZE)
std::cout << "Running xml archive tests" << std::endl;
- archive::xml_oarchive oa(ofs);
+ archive::xml_oarchive oa(oss);
#else
std::cout << "Running text archive tests" << std::endl;
- archive::text_oarchive oa(ofs);
+ archive::text_oarchive oa(oss);
#endif
date d(2002,Feb,12);
@@ -54,8 +54,8 @@
first_kday_after fkda(Thursday);
// load up the archive
-#if defined(DATE_TIME_XML_SERIALIZE)
try{
+#if defined(DATE_TIME_XML_SERIALIZE)
save_to(oa, BOOST_SERIALIZATION_NVP(d));
save_to(oa, BOOST_SERIALIZATION_NVP(sv_d1));
save_to(oa, BOOST_SERIALIZATION_NVP(sv_d2));
@@ -71,14 +71,7 @@
save_to(oa, BOOST_SERIALIZATION_NVP(lkd));
save_to(oa, BOOST_SERIALIZATION_NVP(fkdb));
save_to(oa, BOOST_SERIALIZATION_NVP(fkda));
- }catch(archive::archive_exception ae){
- std::string s(ae.what());
- check("Error writing to archive: " + s, false);
- ofs.close();
- return printTestStats();
- }
#else
- try{
save_to(oa, d);
save_to(oa, sv_d1);
save_to(oa, sv_d2);
@@ -94,20 +87,18 @@
save_to(oa, lkd);
save_to(oa, fkdb);
save_to(oa, fkda);
- }catch(archive::archive_exception ae){
+#endif
+ }catch(archive::archive_exception& ae){
std::string s(ae.what());
- check("Error writing to archive: " + s, false);
- ofs.close();
+ check("Error writing to archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false);
return printTestStats();
}
-#endif // DATE_TIME_XML_SERIALIZE
- ofs.close();
- std::ifstream ifs("tmp_file");
+ std::istringstream iss(oss.str());
#if defined(DATE_TIME_XML_SERIALIZE)
- archive::xml_iarchive ia(ifs);
+ archive::xml_iarchive ia(iss);
#else
- archive::text_iarchive ia(ifs);
+ archive::text_iarchive ia(iss);
#endif
// read from the archive
@@ -126,8 +117,9 @@
last_kday_of_month lkd2(Monday,Jan);
first_kday_before fkdb2(Monday);
first_kday_after fkda2(Monday);
-#if defined(DATE_TIME_XML_SERIALIZE)
+
try{
+#if defined(DATE_TIME_XML_SERIALIZE)
ia >> BOOST_SERIALIZATION_NVP(d2);
ia >> BOOST_SERIALIZATION_NVP(sv_d3);
ia >> BOOST_SERIALIZATION_NVP(sv_d4);
@@ -143,14 +135,7 @@
ia >> BOOST_SERIALIZATION_NVP(lkd2);
ia >> BOOST_SERIALIZATION_NVP(fkdb2);
ia >> BOOST_SERIALIZATION_NVP(fkda2);
- }catch(archive::archive_exception ae){
- std::string s(ae.what());
- check("Error reading from archive: " + s, false);
- ifs.close();
- return printTestStats();
- }
#else
- try{
ia >> d2;
ia >> sv_d3;
ia >> sv_d4;
@@ -166,14 +151,12 @@
ia >> lkd2;
ia >> fkdb2;
ia >> fkda2;
- }catch(archive::archive_exception ae){
+#endif
+ }catch(archive::archive_exception& ae){
std::string s(ae.what());
- check("Error reading from archive: " + s, false);
- ifs.close();
+ check("Error reading from archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false);
return printTestStats();
}
-#endif // DATE_TIME_XML_SERIALIZE
- ifs.close();
check("date", d == d2);
check("special_value date (nadt)", sv_d1 == sv_d3);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,12 +3,12 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Bart Garst
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include <iostream>
#include <sstream>
#include <boost/date_time/gregorian/gregorian.hpp>
-#include <boost/date_time/testfrmwk.hpp>
+#include "../testfrmwk.hpp"
using namespace boost::gregorian;
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/greg_year.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/lexical_cast.hpp"
#include <iostream>
#include <string>
@@ -22,15 +22,15 @@
try {
d = from_simple_string(date_spec);
}
- catch(bad_year by){ // ex: "205-Jan-15"
+ catch(bad_year& by){ // ex: "205-Jan-15"
result = true;
output_str = by.what();
}
- catch(bad_month bm){ // ex: "2005-Jsn-15"
+ catch(bad_month& bm){ // ex: "2005-Jsn-15"
result = true;
output_str = bm.what();
}
- catch(bad_day_of_month bd){ // ex: "2005-Jan-51"
+ catch(bad_day_of_month& bd){ // ex: "2005-Jan-51"
result = true;
output_str = bd.what();
}
@@ -236,7 +236,7 @@
std::cout << "Shouldn't be reached." <<
boost::gregorian::to_simple_string(bd) << std::endl;
}
- catch(boost::gregorian::bad_month){
+ catch(boost::gregorian::bad_month&){
check("bad spelling 'Jull'", true);
}
catch(std::exception& e){
@@ -256,7 +256,7 @@
<< boost::gregorian::to_iso_string(bad_day) << std::endl;
}
- catch(boost::gregorian::bad_day_of_month) { //expected
+ catch(boost::gregorian::bad_day_of_month&) { //expected
check("check bad day", true);
}
catch(std::exception& e) {
@@ -275,7 +275,7 @@
<< boost::gregorian::to_iso_string(bad_day) << std::endl;
}
- catch(boost::gregorian::bad_day_of_month) { //expected
+ catch(boost::gregorian::bad_day_of_month&) { //expected
check("check bad leap year", true);
}
catch(std::exception& e) {
@@ -294,7 +294,7 @@
<< boost::gregorian::to_iso_string(bad_month) << std::endl;
}
- catch(boost::gregorian::bad_month) { //expected
+ catch(boost::gregorian::bad_month&) { //expected
check("check bad month", true);
}
catch(std::exception& e) {
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
int main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,11 +2,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,13 +2,13 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
#include "boost/shared_ptr.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,7 +2,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
@@ -10,7 +10,7 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/local_time.hpp"
// #include "boost/date_time/local_time/posix_time_zone.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
//#include "boost/date_time/c_time.hpp"
#include <iostream>
@@ -288,7 +288,7 @@
local_date_time ldt(not_a_date_time);
tm ldt_tm = to_tm(ldt);
check("Exception not thrown (special_value to_tm)", false);
- }catch(std::out_of_range e){
+ }catch(std::out_of_range& e){
check("Caught expected exception (special_value to_tm)", true);
}catch(...){
check("Caught un-expected exception (special_value to_tm)", false);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -4,28 +4,34 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include <iostream>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
template<class temporal_type, typename charT>
inline
void
-teststreaming(std::string testname,
+teststreaming(std::string const& testname,
temporal_type value,
- std::basic_string<charT> expected_result,
+ std::basic_string<charT> const& expected_result,
const std::locale& locale)
{
std::basic_stringstream<charT> ss;
ss.imbue(locale);
ss << value;
- check(testname, ss.str() == expected_result);
+
+ if (!check(testname, ss.str() == expected_result))
+#if !defined(BOOST_NO_STD_WSTRING)
+ std::wcout << L"Expected: \"" << expected_result.c_str() << L"\"\nGot: \"" << ss.str().c_str() << L"\"" << std::endl;
+#else
+ std::cout << "Expected: \"" << expected_result.c_str() << "\"\nGot: \"" << ss.str().c_str() << L"\"" << std::endl;
+#endif
}
int main(){
@@ -72,8 +78,10 @@
local_date_time ldt4(b_time, la);
local_date_time ldt5(a_time, nyc);
local_date_time ldt6(b_time, phx);
-
-
+
+ local_time_period ltp1(ldt1, hours(10) + minutes(24) + seconds(5));
+ local_time_period ltp2(ldt4, hours(15) + minutes(20) + seconds(41));
+
typedef boost::date_time::time_facet<local_date_time, char> ldt_facet;
//ldt_facet* timefacet = new ldt_facet("%c %Z"); // full name
ldt_facet* timefacet = new ldt_facet("%a %b %d %H:%M:%S %Y %Z"); // full name
@@ -94,7 +102,10 @@
teststreaming("Los Angeles in summer", ldt4, std::string("Sun Aug 15 05:00:00 2004 Pacific Daylight Time"), loc1);
teststreaming("New York in winter", ldt5, std::string("Wed Dec 15 07:00:00 2004 Eastern Standard Time"), loc1);
teststreaming("Phoenix in Summer", ldt6, std::string("Sun Aug 15 05:00:00 2004 Mountain Standard Time"), loc1);
-
+
+ teststreaming("UTC local_time_period", ltp1, std::string("[Wed Dec 15 12:00:00 2004 Coordinated Universal Time/Wed Dec 15 22:24:04 2004 Coordinated Universal Time]"), loc1);
+ teststreaming("LA local_time_period", ltp2, std::string("[Sun Aug 15 05:00:00 2004 Pacific Daylight Time/Sun Aug 15 20:20:40 2004 Pacific Daylight Time]"), loc1);
+
//ptimefacet1->format("%c %z"); // show that zone abbrev is ignored
ptimefacet1->format("%a %b %d %H:%M:%S %Y %z"); // show that zone abbrev is ignored
std::cout << "\nTime zone abbreviation tests" << std::endl;
@@ -169,6 +180,9 @@
teststreaming("UTC local_date_time", ldt1, std::wstring(L"Wed Dec 15 12:00:00 2004 Coordinated Universal Time"), loc3);
teststreaming("Chicago in summer", ldt2, std::wstring(L"Sun Aug 15 07:00:00 2004 Central Daylight Time") , loc3);
+ teststreaming("UTC local_time_period", ltp1, std::wstring(L"[Wed Dec 15 12:00:00 2004 Coordinated Universal Time/Wed Dec 15 22:24:04 2004 Coordinated Universal Time]"), loc3);
+ teststreaming("LA local_time_period", ltp2, std::wstring(L"[Sun Aug 15 05:00:00 2004 Pacific Daylight Time/Sun Aug 15 20:20:40 2004 Pacific Daylight Time]"), loc3);
+
//wtimefacet->format(L"%c %z"); // abbrev
wtimefacet->format(L"%a %b %d %H:%M:%S %Y %z"); // abbrev
std::cout << "\nAbbreviated time zone names tests - wide stream" << std::endl;
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,11 +2,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
#include <sstream>
#include <string>
@@ -15,7 +15,7 @@
template<class temporal_type, class exception_type>
bool failure_test(temporal_type component,
const std::string& input,
- exception_type /*except*/,
+ exception_type const& /*except*/,
boost::local_time::local_time_input_facet* facet)
{
using namespace boost::local_time;
@@ -26,7 +26,7 @@
try {
iss >> component;
}
- catch(exception_type e) {
+ catch(exception_type& e) {
std::cout << "Expected exception caught: \""
<< e.what() << "\"" << std::endl;
result = iss.fail(); // failbit must be set to pass test
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,12 +3,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include <iostream>
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
// #if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
// #include "boost/date_time/gregorian/formatters_limited.hpp"
// #else
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int main()
{
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,13 +2,13 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
//#include "boost/date_time/local_time/time_zone.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/date_time/local_time/posix_time_zone.hpp"
@@ -127,31 +127,31 @@
try {
posix_time_zone badz("EST-13");
check("Exception not thrown: bad UTC offset", false);
- }catch(bad_offset boff){
+ }catch(bad_offset& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}
try {
posix_time_zone badz("EST-5EDT24:00:01,J124/1:30,J310");
check("Exception not thrown: bad DST adjust", false);
- }catch(bad_adjustment badj){
+ }catch(bad_adjustment& badj){
std::string msg(badj.what());
check("Exception caught: "+msg , true);
}
try {
posix_time_zone badz("EST-5EDT01:00:00,J124/-1:30,J310");
check("Exception not thrown: bad DST start/end offset", false);
- }catch(bad_offset boff){
+ }catch(bad_offset& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}
try {
posix_time_zone badz("EST-5EDT01:00:00,J124/1:30,J370");
check("Exception not thrown: invalid date spec", false);
- }catch(boost::gregorian::bad_day_of_month boff){
+ }catch(boost::gregorian::bad_day_of_month& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
- }catch(boost::gregorian::bad_month boff){
+ }catch(boost::gregorian::bad_month& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}catch(...){
@@ -200,7 +200,7 @@
try{
check("Non-Julian First/last of month", fl_2.dst_local_start_time(2003) ==
ptime(date(2003,Mar,1),hours(2)));
- }catch(std::exception e){
+ }catch(std::exception& e){
check("Expected exception caught for Non-Julian day of 59, in non-leap year (Feb-29)", true);
}
check("Non-Julian First/last of month", fl_2.dst_local_end_time(2003) ==
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,11 +2,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/custom_time_zone.hpp"
@@ -32,7 +32,7 @@
try{
tz_database tz_db;
tz_db.load_from_file("missing_file.csv"); // file does not exist
- }catch(data_not_accessible e){
+ }catch(data_not_accessible& e){
check("Caught Missing data file exception", true);
}catch(...){
check("Caught first unexpected exception", false);
@@ -52,7 +52,7 @@
try {
// first try to find the data file from the test dir
tz_db.load_from_file("../data/date_time_zonespec.csv");
- }catch(data_not_accessible e) {
+ }catch(data_not_accessible& e) {
// couldn't find the data file so assume we are being run from
// boost_root/status and try again
tz_db.load_from_file("../libs/date_time/data/date_time_zonespec.csv");
@@ -121,14 +121,14 @@
tz_database other_db;
try{
other_db.load_from_file("local_time/poorly_formed_zonespec.csv");
- }catch(bad_field_count be){
+ }catch(bad_field_count& be){
caught_bfc = true;
}catch(...) {
// do nothing (file not found)
}
try{
other_db.load_from_file("../libs/date_time/test/local_time/poorly_formed_zonespec.csv");
- }catch(bad_field_count be){
+ }catch(bad_field_count& be){
caught_bfc = true;
}catch(...) {
// do nothing (file not found)
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,11 +2,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/local_time/local_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -2,13 +2,13 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
//#include "boost/date_time/local_time/time_zone.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/date_time/local_time/posix_time_zone.hpp"
@@ -130,31 +130,31 @@
try {
w_posix_time_zone badz(L"EST-13");
check("Exception not thrown: bad UTC offset", false);
- }catch(bad_offset boff){
+ }catch(bad_offset& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}
try {
w_posix_time_zone badz(L"EST-5EDT24:00:01,J124/1:30,J310");
check("Exception not thrown: bad DST adjust", false);
- }catch(bad_adjustment badj){
+ }catch(bad_adjustment& badj){
std::string msg(badj.what());
check("Exception caught: "+msg , true);
}
try {
w_posix_time_zone badz(L"EST-5EDT01:00:00,J124/-1:30,J310");
check("Exception not thrown: bad DST start/end offset", false);
- }catch(bad_offset boff){
+ }catch(bad_offset& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}
try {
w_posix_time_zone badz(L"EST-5EDT01:00:00,J124/1:30,J370");
check("Exception not thrown: invalid date spec", false);
- }catch(boost::gregorian::bad_day_of_month boff){
+ }catch(boost::gregorian::bad_day_of_month& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
- }catch(boost::gregorian::bad_month boff){
+ }catch(boost::gregorian::bad_month& boff){
std::string msg(boff.what());
check("Exception caught: "+msg , true);
}catch(...){
@@ -203,7 +203,7 @@
try{
check("Non-Julian First/last of month", fl_2.dst_local_start_time(2003) ==
ptime(date(2003,Mar,1),hours(2)));
- }catch(std::exception e){
+ }catch(std::exception& e){
check("Expected exception caught for Non-Julian day of 59, in non-leap year (Feb-29)", true);
}
check("Non-Julian First/last of month", fl_2.dst_local_end_time(2003) ==
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/c_local_time_adjustor.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_timezone_defs.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
// Define dst rule for Paraguay which is transitions forward on Oct 1 and
// back Mar 1
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,7 +3,7 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include "boost/date_time/posix_time/posix_time_duration.hpp"
@@ -13,7 +13,7 @@
#else
#include "boost/date_time/posix_time/time_formatters.hpp"
#endif
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include "boost/date_time/filetime_functions.hpp"
#include <cmath>
@@ -33,21 +33,20 @@
ptime pt = from_ftime<ptime>(ft);
- check("ptime year matches systemtime year",
- st.wYear == pt.date().year());
- check("ptime month matches systemtime month",
- st.wMonth == pt.date().month());
- check("ptime day matches systemtime day",
- st.wDay == pt.date().day());
- check("ptime hour matches systemtime hour",
- st.wHour == pt.time_of_day().hours());
- check("ptime minute matches systemtime minute",
- st.wMinute == pt.time_of_day().minutes());
- check("ptime second matches systemtime second",
- st.wSecond == pt.time_of_day().seconds());
- check("truncated ptime fractional second matches systemtime millisecond",
- st.wMilliseconds == (pt.time_of_day().fractional_seconds() / adjustor)
- );
+ check_equal("ptime year matches systemtime year",
+ st.wYear, pt.date().year());
+ check_equal("ptime month matches systemtime month",
+ st.wMonth, pt.date().month());
+ check_equal("ptime day matches systemtime day",
+ st.wDay, pt.date().day());
+ check_equal("ptime hour matches systemtime hour",
+ st.wHour, pt.time_of_day().hours());
+ check_equal("ptime minute matches systemtime minute",
+ st.wMinute, pt.time_of_day().minutes());
+ check_equal("ptime second matches systemtime second",
+ st.wSecond, pt.time_of_day().seconds());
+ check_equal("truncated ptime fractional second matches systemtime millisecond",
+ st.wMilliseconds, (pt.time_of_day().fractional_seconds() / adjustor));
// burn up a little time
for (int j=0; j<100000; j++)
@@ -58,6 +57,28 @@
} // for loop
+ // check that time_from_ftime works for pre-1970-Jan-01 dates, too
+ // zero FILETIME should represent 1601-Jan-01 00:00:00.000
+ FILETIME big_bang_by_ms;
+ big_bang_by_ms.dwLowDateTime = big_bang_by_ms.dwHighDateTime = 0;
+ ptime pt = from_ftime<ptime>(big_bang_by_ms);
+
+ check_equal("big bang ptime year matches 1601",
+ 1601, pt.date().year());
+ check_equal("big bang ptime month matches Jan",
+ 1, pt.date().month());
+ check_equal("big bang ptime day matches 1",
+ 1, pt.date().day());
+ check_equal("big bang ptime hour matches 0",
+ 0, pt.time_of_day().hours());
+ check_equal("big bang ptime minute matches 0",
+ 0, pt.time_of_day().minutes());
+ check_equal("big bang ptime second matches 0",
+ 0, pt.time_of_day().seconds());
+ check_equal("big bang truncated ptime fractional second matches 0",
+ 0, (pt.time_of_day().fractional_seconds() / adjustor));
+
+
#else // BOOST_HAS_FTIME
// we don't want a forced failure here, not a shortcoming
check("FILETIME not available for this compiler/platform", true);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int main(){
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,12 +3,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
#include "boost/date_time/gregorian/formatters_limited.hpp"
#else
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time_adjustor.hpp"
#include "boost/date_time/local_timezone_defs.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,8 +7,10 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/microsec_time_clock.hpp"
-#include "boost/date_time/testfrmwk.hpp"
-
+#include "../testfrmwk.hpp"
+#if defined(BOOST_HAS_FTIME)
+#include <windows.h>
+#endif
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/posix_time/time_period.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int main()
{
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/gregorian/gregorian.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#ifndef BOOST_DATE_TIME_NO_LOCALE
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
void special_values_tests()
{
@@ -302,7 +302,7 @@
ptime pt(pos_infin);
tm pt_tm = to_tm(pt);
check("Exception not thrown (special_value to_tm)", false);
- }catch(std::out_of_range e){
+ }catch(std::out_of_range& e){
check("Caught expected exception (special_value to_tm)", true);
}catch(...){
check("Caught un-expected exception (special_value to_tm)", false);
@@ -314,7 +314,7 @@
pt += time_duration(pos_infin);
tm pt_tm = to_tm(pt);
check("Exception not thrown (special_value to_tm)", false);
- }catch(std::out_of_range e){
+ }catch(std::out_of_range& e){
check("Caught expected exception (special_value to_tm)", true);
}catch(...){
check("Caught un-expected exception (special_value to_tm)", false);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -4,11 +4,11 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-01-29 18:54:17 +0000 (Thu, 29 Jan 2009) $
*/
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <fstream>
#include <iostream>
#include <sstream>
@@ -24,7 +24,7 @@
std::basic_stringstream<charT> ss;
ss.imbue(locale);
ss << value;
- check(testname, ss.str() == expected_result);
+ check_equal(testname, ss.str(), expected_result);
}
@@ -54,6 +54,8 @@
ptime tf = t + microseconds(3);
time_period tp(t, tf + days(7) + time_duration(1,1,1));
time_duration td = hours(3) + minutes(2) + seconds(1) + milliseconds(9);
+ time_duration longer_td = hours(10) + minutes(22) + seconds(15) + milliseconds(980); // two characters in hours
+ time_duration long_td = hours(300) + minutes(2) + seconds(1) + milliseconds(9); // more than two characters in hours
{
std::stringstream ss;
ss << t;
@@ -94,6 +96,18 @@
ss << td;
check("Multiple literal '%'s in time_duration format", ss.str() == std::string("03:02:01 %01"));
ss.str("");
+
+ // Longer time durations
+ f->time_duration_format("%H:%M:%S");
+ ss << longer_td;
+ check("Longer time durations", ss.str() == std::string("10:22:15"));
+ ss.str("");
+
+ // Long time durations
+ f->time_duration_format("%O:%M:%S");
+ ss << long_td;
+ check("Long time durations", ss.str() == std::string("300:02:01"));
+ ss.str("");
}
{ // negative time_duration tests
std::string result;
@@ -168,9 +182,35 @@
ss << td4 - td3;
result = "-00 hours and -01 minutes";
check("Negative time_duration two sign flags" + ss.str(), result == ss.str());
+ ss.str("");
+
+ // Longer time durations
+ f->time_duration_format("%-%H:%M:%S");
+ ss << -longer_td;
+ check("Longer negative time durations", ss.str() == std::string("-10:22:15"));
+ ss.str("");
+ // Long time durations
+ f->time_duration_format("%-%O:%M:%S");
+ ss << -long_td;
+ check("Long negative time durations", ss.str() == std::string("-300:02:01"));
+ ss.str("");
}
-
+
+ // The test verifies that #2698 is fixed. That is, the time and date facet should
+ // not dereference end() iterator for the format string in do_put_tm.
+ {
+ boost::gregorian::date date(2009, 1, 1);
+ boost::posix_time::time_duration td(0, 0, 0, 0);
+ boost::posix_time::ptime boost_time(date, td);
+ std::stringstream sstr;
+
+ boost::posix_time::time_facet* pFacet = new boost::posix_time::time_facet("");
+ sstr.imbue(std::locale(std::locale::classic(), pFacet));
+
+ sstr << boost_time;
+ }
+
#if !defined(BOOST_NO_STD_WSTRING)
std::copy(&short_month_names[0],
&short_month_names[12],
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int
main()
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,12 +3,12 @@
* 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 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2009-06-01 10:02:43 +0100 (Mon, 01 Jun 2009) $
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
#include <iostream>
#include <sstream>
#include <string>
@@ -18,7 +18,7 @@
template<class temporal_type, class exception_type>
bool failure_test(temporal_type component,
const std::string& input,
- exception_type /*except*/,
+ exception_type const& /*except*/,
boost::posix_time::time_input_facet* facet)
{
using namespace boost::posix_time;
@@ -29,7 +29,7 @@
try {
iss >> component;
}
- catch(exception_type e) {
+ catch(exception_type& e) {
std::cout << "Expected exception caught: \""
<< e.what() << "\"" << std::endl;
result = iss.fail(); // failbit must be set to pass test
@@ -96,25 +96,25 @@
iss >> td;
iss >> pt;
#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
- check("Default format time_duration", td == time_duration(9,59,1,321987654));
- check("Default format ptime", pt == ptime(date(2005,01,15),time_duration(10,15,3,123456789)));
+ check_equal("Default format time_duration", td, time_duration(9,59,1,321987654));
+ check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(10,15,3,123456789)));
#else
- check("Default format time_duration", td == time_duration(9,59,1,321987));
- check("Default format ptime", pt == ptime(date(2005,01,15),time_duration(10,15,3,123456)));
+ check_equal("Default format time_duration", td, time_duration(9,59,1,321987));
+ check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(10,15,3,123456)));
#endif
// test all flags that appear in time_input_facet
iss.str("12:34:56 2005-Jan-15 12:34:56");
iss >> td;
iss >> pt;
- check("Default format time_duration no frac_sec", td == time_duration(12,34,56));
+ check_equal("Default format time_duration no frac_sec", td, time_duration(12,34,56));
// the following test insures %F parsing stops at the appropriate point
- check("Default format ptime", pt == ptime(date(2005,01,15),time_duration(12,34,56)));
-
+ check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(12,34,56)));
+
iss.str("14:13:12 extra stuff"); // using default %H:%M:%S%F format
iss >> td;
- check("Default frac_sec format time_duration", td == time_duration(14,13,12));
-
+ check_equal("Default frac_sec format time_duration", td, time_duration(14,13,12));
+
time_input_facet* facet = new time_input_facet();
std::locale loc(std::locale::classic(), facet);
facet->time_duration_format("%H:%M:%S%f");
@@ -122,61 +122,61 @@
iss.str("14:13:12.0 extra stuff");
iss >> td;
- check("Required-frac_sec format time_duration", td == time_duration(14,13,12));
+ check_equal("Required-frac_sec format time_duration", td, time_duration(14,13,12));
iss.str("12");
facet->time_duration_format("%H");
iss >> td;
- check("Hours format", td == hours(12));
+ check_equal("Hours format", td, hours(12));
iss.str("05");
facet->time_duration_format("%M");
iss >> td;
- check("Minutes format", td == minutes(5));
+ check_equal("Minutes format", td, minutes(5));
iss.str("45");
facet->time_duration_format("%S");
iss >> td;
- check("Seconds w/o frac_sec format", td == seconds(45));
+ check_equal("Seconds w/o frac_sec format", td, seconds(45));
iss.str("10.01");
facet->time_duration_format("%s");
iss >> td;
#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
- check("Seconds w/ frac_sec format", td == time_duration(0,0,10,10000000));
+ check_equal("Seconds w/ frac_sec format", td, time_duration(0,0,10,10000000));
#else
- check("Seconds w/ frac_sec format", td == time_duration(0,0,10,10000));
+ check_equal("Seconds w/ frac_sec format", td, time_duration(0,0,10,10000));
#endif
-
+
iss.str("2005-105T23:59");
facet->format("%Y-%jT%H:%M"); // extended ordinal format
iss >> pt;
- check("Extended Ordinal format", pt == ptime(date(2005,4,15),time_duration(23,59,0)));
+ check_equal("Extended Ordinal format", pt, ptime(date(2005,4,15),time_duration(23,59,0)));
/* this is not implemented yet. The flags: %I & %p are not parsed
iss.str("2005-Jun-14 03:15:00 PM");
facet->format("%Y-%b-%d %I:%M:%S %p");
iss >> pt;
- check("12 hour time format (AM/PM)", pt == ptime(date(2005,6,14),time_duration(15,15,0)));
+ check_equal("12 hour time format (AM/PM)", pt, ptime(date(2005,6,14),time_duration(15,15,0)));
*/
iss.str("2005-Jun-14 15:15:00 %d");
facet->format("%Y-%b-%d %H:%M:%S %%d");
iss >> pt;
- check("Literal '%' in format", pt == ptime(date(2005,6,14),time_duration(15,15,0)));
+ check_equal("Literal '%' in format", pt, ptime(date(2005,6,14),time_duration(15,15,0)));
iss.str("15:15:00 %d");
facet->time_duration_format("%H:%M:%S %%d");
iss >> td;
- check("Literal '%' in time_duration format", td == time_duration(15,15,0));
+ check_equal("Literal '%' in time_duration format", td, time_duration(15,15,0));
iss.str("2005-Jun-14 15:15:00 %14");
facet->format("%Y-%b-%d %H:%M:%S %%%d"); // %% => % & %d => day_of_month
iss >> pt;
- check("Multiple literal '%'s in format", pt == ptime(date(2005,6,14),time_duration(15,15,0)));
+ check_equal("Multiple literal '%'s in format", pt, ptime(date(2005,6,14),time_duration(15,15,0)));
iss.str("15:15:00 %15");
facet->time_duration_format("%H:%M:%S %%%M");
iss >> td;
- check("Multiple literal '%'s in time_duration format", td == time_duration(15,15,0));
-
+ check_equal("Multiple literal '%'s in time_duration format", td, time_duration(15,15,0));
+
{ /****** iso format tests (and custom 'scrunched-together formats) ******/
time_input_facet *facet = new time_input_facet();
facet->set_iso_format();
@@ -195,21 +195,21 @@
ss.str("20021017T231217.12345");
ss >> pt;
- check("iso_format ptime", pt == result);
+ check_equal("iso_format ptime", pt, result);
ss.str("");
facet->set_iso_extended_format();
ss.str("2002-10-17 23:12:17.12345");
ss >> pt;
- check("iso_extended_format ptime", pt == result);
+ check_equal("iso_extended_format ptime", pt, result);
ss.str("");
ss.str("231217.12345");
ss >> td;
- check("iso_format time_duration", td == td2);
+ check_equal("iso_format time_duration", td, td2);
ss.str("");
ss.str("-infinity");
ss >> td;
- check("iso_format time_duration (special_value)",
- td == time_duration(neg_infin));
+ check_equal("iso_format time_duration (special_value)",
+ td, time_duration(neg_infin));
ss.str("");
// the above tests prove correct parsing of time values in these formats.
// these tests show they also handle special_values & exceptions properly
@@ -221,34 +221,34 @@
ss.str("not-a-date-time");
++count;
ss >> td;
- check("special value w/ hours flag", td == nadt);
+ check_equal("special value w/ hours flag", td, nadt);
ss.str("");
facet->time_duration_format("%M%S%F");
ss.str("not-a-date-time");
++count;
ss >> td;
- check("special value w/ minutes flag", td == nadt);
+ check_equal("special value w/ minutes flag", td, nadt);
ss.str("");
facet->time_duration_format("%S%F");
ss.str("not-a-date-time");
++count;
ss >> td;
- check("special value w/ seconds flag", td == nadt);
+ check_equal("special value w/ seconds flag", td, nadt);
ss.str("");
facet->time_duration_format("%s");
ss.str("not-a-date-time");
++count;
ss >> td;
- check("special value w/ sec w/frac_sec (always) flag", td == nadt);
+ check_equal("special value w/ sec w/frac_sec (always) flag", td, nadt);
ss.str("");
facet->time_duration_format("%f");
ss.str("not-a-date-time");
++count;
ss >> td;
- check("special value w/ frac_sec (always) flag", td == nadt);
+ check_equal("special value w/ frac_sec (always) flag", td, nadt);
ss.str("");
}
- catch(...) {
+ catch(...) {
// any exception is a failure
std::stringstream msg;
msg << "special_values with scrunched formats failed at test" << count;
@@ -276,7 +276,7 @@
failure_test(td, "bad_input", exc, new time_input_facet("%f")));
check("silent failure test w/ frac_sec flag",
failure_test(td, "bad_input", new time_input_facet("%f")));
-
+
}
// special_values tests. prove the individual flags catch special_values
// NOTE: these flags all by themselves will not parse a complete ptime,
@@ -286,41 +286,41 @@
facet->time_duration_format("%H");
iss >> pt;
iss >> td;
- check("Special value: ptime %H flag", pt == ptime(pos_infin));
- check("Special value: time_duration %H flag", td == time_duration(neg_infin));
-
+ check_equal("Special value: ptime %H flag", pt, ptime(pos_infin));
+ check_equal("Special value: time_duration %H flag", td, time_duration(neg_infin));
+
iss.str("not-a-date-time +infinity");
facet->format("%M");
facet->time_duration_format("%M");
iss >> pt;
iss >> td;
- check("Special value: ptime %M flag", pt == ptime(not_a_date_time));
- check("Special value: time_duration %M flag", td == time_duration(pos_infin));
-
+ check_equal("Special value: ptime %M flag", pt, ptime(not_a_date_time));
+ check_equal("Special value: time_duration %M flag", td, time_duration(pos_infin));
+
iss.str("-infinity not-a-date-time ");
facet->format("%S");
facet->time_duration_format("%S");
iss >> pt;
iss >> td;
- check("Special value: ptime %S flag", pt == ptime(neg_infin));
- check("Special value: time_duration %S flag", td == time_duration(not_a_date_time));
-
+ check_equal("Special value: ptime %S flag", pt, ptime(neg_infin));
+ check_equal("Special value: time_duration %S flag", td, time_duration(not_a_date_time));
+
iss.str("+infinity -infinity");
facet->format("%s");
facet->time_duration_format("%s");
iss >> pt;
iss >> td;
- check("Special value: ptime %s flag", pt == ptime(pos_infin));
- check("Special value: time_duration %s flag", td == time_duration(neg_infin));
-
+ check_equal("Special value: ptime %s flag", pt, ptime(pos_infin));
+ check_equal("Special value: time_duration %s flag", td, time_duration(neg_infin));
+
iss.str("not-a-date-time +infinity");
facet->format("%j");
facet->time_duration_format("%f");
iss >> pt;
iss >> td;
- check("Special value: ptime %j flag", pt == ptime(not_a_date_time));
- check("Special value: time_duration %f flag", td == time_duration(pos_infin));
-
+ check_equal("Special value: ptime %j flag", pt, ptime(not_a_date_time));
+ check_equal("Special value: time_duration %f flag", td, time_duration(pos_infin));
+
// time_period tests - the time_period_parser is thoroughly tested in gregorian tests
// default period format is closed range so last ptime is included in peiod
iss.str("[2005-Jan-01 00:00:00/2005-Dec-31 23:59:59]");
@@ -341,21 +341,21 @@
time_period tp3(pt3, pt4);
ss << tp;
ss >> tp2;
- check("Special values period (reversibility test)", tp == tp2);
+ check_equal("Special values period (reversibility test)", tp, tp2);
ss.str("[-infinity/+infinity]");
ss >> tp2;
- check("Special values period (infinities)", tp3 == tp2);
+ check_equal("Special values period (infinities)", tp3, tp2);
}
// Failure tests
// faliure tests for date elements tested in gregorian tests
time_input_facet* facet2 = new time_input_facet();
facet2->time_duration_format("%H:%M:%S%f");
- check("Failure test: Missing frac_sec with %f flag (w/exceptions)",
+ check("Failure test: Missing frac_sec with %f flag (w/exceptions)",
failure_test(td, "14:13:12 extra stuff", e_failure, facet2));
time_input_facet* facet3 = new time_input_facet();
facet3->time_duration_format("%H:%M:%S%f");
- check("Failure test: Missing frac_sec with %f flag (no exceptions)",
+ check("Failure test: Missing frac_sec with %f flag (no exceptions)",
failure_test(td, "14:13:12 extra stuff", facet3));
// Reversable format tests
@@ -370,22 +370,22 @@
ss.str("");
ss << pt_io; // stream out pt_io
ss >> pt;
- check("Stream out one ptime then into another: default format", pt_io == pt);
+ check_equal("Stream out one ptime then into another: default format", pt_io, pt);
ss.str("");
ss << td_io; // stream out td_io
ss >> td;
- check("Stream out one time_duration then into another: default format", td_io == td);
+ check_equal("Stream out one time_duration then into another: default format", td_io, td);
td_io = time_duration(1,29,59); // no frac_sec, default format has %F
pt_io = ptime(date(2004,2,29), td_io); // leap year
ss.str("");
ss << pt_io; // stream out pt_io
ss >> pt;
- check("Stream out one ptime then into another: default format", pt_io == pt);
+ check_equal("Stream out one ptime then into another: default format", pt_io, pt);
ss.str("");
ss << td_io; // stream out td_io
ss >> td;
- check("Stream out one time_duration then into another: default format", td_io == td);
+ check_equal("Stream out one time_duration then into another: default format", td_io, td);
td_io = time_duration(13,05,0); // no seconds as the next formats won't use them
pt_io = ptime(date(2004,2,29), td_io); // leap year
@@ -394,14 +394,14 @@
ss.str("");
ss << pt_io; // stream out pt_io
ss >> pt;
- check("Stream out one ptime then into another: extended ordinal format", pt_io == pt);
+ check_equal("Stream out one ptime then into another: extended ordinal format", pt_io, pt);
otp_facet->format("Time: %H:%M, Date: %B %d, %Y"); // custom format with extra words
inp_facet->format("Time: %H:%M, Date: %B %d, %Y");
ss.str("");
ss << pt_io; // stream out pt_io
ss >> pt;
- check("Stream out one ptime then into another: custom format (" + ss.str() + ")", pt_io == pt);
+ check_equal("Stream out one ptime then into another: custom format (" + ss.str() + ")", pt_io, pt);
{
// fully parameterized constructor - compile only test, all other features tested in gregorian
@@ -411,7 +411,7 @@
boost::date_time::date_generator_parser<date, char> dgp; // default constructor
time_input_facet tif("%Y-%m-%d %H:%M:%s", fdp, svp, pp, dgp);
}
-#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
}
@@ -432,4 +432,4 @@
}
return printTestStats();
}
-
+
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/posix_time/time_period.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "../testfrmwk.hpp"
int main()
{
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -11,8 +11,8 @@
#include <boost/archive/xml_iarchive.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/time_serialize.hpp>
-#include <boost/date_time/testfrmwk.hpp>
-#include <fstream>
+#include "../testfrmwk.hpp"
+#include <sstream>
using namespace boost;
using namespace posix_time;
@@ -47,16 +47,16 @@
ptime sv_pt4(min_date_time);
time_duration sv_td2(0,0,0);
- std::ofstream ofs("tmp_file");
+ std::ostringstream oss;
// NOTE: DATE_TIME_XML_SERIALIZE is only used in testing and is
// defined in the testing Jamfile
#if defined(DATE_TIME_XML_SERIALIZE)
std::cout << "Running xml archive tests" << std::endl;
- archive::xml_oarchive oa(ofs);
+ archive::xml_oarchive oa(oss);
#else
std::cout << "Running text archive tests" << std::endl;
- archive::text_oarchive oa(ofs);
+ archive::text_oarchive oa(oss);
#endif // DATE_TIME_XML_SERIALIZE
try{
@@ -75,20 +75,17 @@
save_to(oa, td);
save_to(oa, sv_td);
#endif // DATE_TIME_XML_SERIALIZE
- }catch(archive::archive_exception ae){
+ }catch(archive::archive_exception& ae){
std::string s(ae.what());
- check("Error writing to archive: " + s, false);
- ofs.close();
+ check("Error writing to archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false);
return printTestStats();
}
- ofs.close();
-
- std::ifstream ifs("tmp_file");
+ std::istringstream iss(oss.str());
#if defined(DATE_TIME_XML_SERIALIZE)
- archive::xml_iarchive ia(ifs);
+ archive::xml_iarchive ia(iss);
#else
- archive::text_iarchive ia(ifs);
+ archive::text_iarchive ia(iss);
#endif // DATE_TIME_XML_SERIALIZE
try{
@@ -107,15 +104,12 @@
ia >> td2;
ia >> sv_td2;
#endif // DATE_TIME_XML_SERIALIZE
- }catch(archive::archive_exception ae){
+ }catch(archive::archive_exception& ae){
std::string s(ae.what());
- check("Error readng from archive: " + s, false);
- ifs.close();
+ check("Error readng from archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false);
return printTestStats();
}
- ifs.close();
-
check("ptime", pt == pt2);
check("special_values ptime (nadt)", sv_pt1 == sv_pt3);
check("special_values ptime (pos_infin)", sv_pt2 == sv_pt4);
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -3,13 +3,13 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Bart Garst
- * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ * $Date: 2008-11-25 20:36:52 +0000 (Tue, 25 Nov 2008) $
*/
#include <iostream>
#include <sstream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/date_time/testfrmwk.hpp>
+#include "../testfrmwk.hpp"
#include <boost/lexical_cast.hpp>
using namespace boost::gregorian;
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include "boost/config.hpp"
#include "boost/date_time/constrained_value.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
#include <iostream>
class bad_day {}; //exception type
Added: sandbox/SOC/2008/calendar/libs/date_time/test/testfrmwk.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testfrmwk.hpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -0,0 +1,89 @@
+
+#ifndef TEST_FRMWK_HPP___
+#define TEST_FRMWK_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)
+ * $Date$
+ */
+
+
+#include <iostream>
+#include <string>
+#include <boost/config.hpp>
+
+//! Really simple test framework for counting and printing
+class TestStats
+{
+public:
+ static TestStats& instance() {static TestStats ts; return ts;}
+ void addPassingTest() {testcount_++; passcount_++;}
+ void addFailingTest() {testcount_++;}
+ unsigned int testcount() const {return testcount_;}
+ unsigned int passcount() const {return passcount_;}
+ void print(std::ostream& out = std::cout) const
+ {
+ out << testcount_ << " Tests Executed: " ;
+ if (passcount() != testcount()) {
+ out << (testcount() - passcount()) << " FAILURES";
+ }
+ else {
+ out << "All Succeeded" << std::endl;
+ }
+ out << std::endl;
+ }
+private:
+ TestStats() : testcount_(0), passcount_(0) {}
+ unsigned int testcount_;
+ unsigned int passcount_;
+};
+
+
+bool check(const std::string& testname, bool testcond)
+{
+ TestStats& stat = TestStats::instance();
+ if (testcond) {
+ std::cout << "Pass :: " << testname << " " << std::endl;
+ stat.addPassingTest();
+ return true;
+ }
+ else {
+ stat.addFailingTest();
+ std::cout << "FAIL :: " << testname << " " << std::endl;
+ return false;
+ }
+}
+
+template< typename T, typename U >
+inline bool check_equal(const std::string& testname, T const& left, U const& right)
+{
+ bool res = check(testname, left == right);
+ if (!res)
+ {
+ std::cout << " left = " << left << ", right = " << right << std::endl;
+ }
+ return res;
+}
+
+#ifndef BOOST_NO_STD_WSTRING
+inline bool check_equal(const std::string& testname, std::wstring const& left, std::wstring const& right)
+{
+ bool res = check(testname, left == right);
+ if (!res)
+ {
+ std::wcout << L" left = " << left << L", right = " << right << std::endl;
+ }
+ return res;
+}
+#endif
+
+int printTestStats()
+{
+ TestStats& stat = TestStats::instance();
+ stat.print();
+ return stat.testcount() - stat.passcount();
+}
+
+#endif
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include <iostream>
#include "boost/date_time/period.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
/*! duration_rep parameter for period requires a func unit() that
* returns the smallest unit of measure for this type. This minimal
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -7,7 +7,7 @@
#include "boost/date_time/gregorian_calendar.hpp"
#include "boost/date_time/year_month_day.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
#include <iostream>
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/int_adapter.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
#include "boost/cstdint.hpp"
#include <iostream>
#include <sstream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -6,7 +6,7 @@
*/
#include "boost/date_time/time_resolution_traits.hpp"
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
int
Modified: sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -8,7 +8,7 @@
#include "boost/date_time/wrapping_int.hpp"
//#define BOOST_INCLUDE_MAIN
//#include <boost/test/test_tools.hpp>
-#include "boost/date_time/testfrmwk.hpp"
+#include "testfrmwk.hpp"
#include "boost/cstdint.hpp"
#include <iostream>
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2 (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -9,21 +9,26 @@
import set ;
toolset.using doxygen ;
-boostbook date_time : date_time.xml ;
+boostbook date_time : date_time.xml
+ :
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
+ ;
# boostbook date_time_doc : exclusive_date_time.xml ;
# file lists take the form of [ set.difference [ glob include/these ] : [ glob but/not/these ] ]
-local date_time_files = [ set.difference
- [ glob ../../../boost/date_time/*.hpp ] :
- [ glob ../../../boost/date_time/testfrmwk.hpp
- # ../../../boost/date_time/time_zone_base.hpp
- # ../../../boost/date_time/time_zone_names.hpp
- # ../../../boost/date_time/tz_db_base.hpp
- # ../../../boost/date_time/dst_transition_generators.hpp
- ]
- ] ;
+local date_time_files = [ glob ../../../boost/date_time/*.hpp ] ;
+
+# local date_time_files = [ set.difference
+# [ glob ../../../boost/date_time/*.hpp ] :
+# [ glob ../../../boost/date_time/testfrmwk.hpp
+# # ../../../boost/date_time/time_zone_base.hpp
+# # ../../../boost/date_time/time_zone_names.hpp
+# # ../../../boost/date_time/tz_db_base.hpp
+# # ../../../boost/date_time/dst_transition_generators.hpp
+# ]
+# ] ;
local gregorian_files = [ set.difference
[ glob ../../../boost/date_time/gregorian/*.hpp ] :
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -9,9 +9,170 @@
<section id="date_time.changes">
<title>Change History</title>
-
+
<!-- if each new change tgroup has a "Bug Fix" as the first "Type", the columns will line up nicely -->
+ <bridgehead renderas="sect3">Changes from Boost 1.38 to 1.40 (date_time 1.06 to 1.07)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+<!--
+ <row>
+ <entry>Feature</entry>
+ <entry>
+ </entry>
+ </row>
+-->
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Minor bug fixes (<ulink url="https://svn.boost.org/trac/boost/ticket/2809">#2809</ulink>,
+ <ulink url="https://svn.boost.org/trac/boost/ticket/2824">#2824</ulink>,
+ <ulink url="https://svn.boost.org/trac/boost/ticket/3015">#3015</ulink>,
+ <ulink url="https://svn.boost.org/trac/boost/ticket/3105">#3105</ulink> and others).
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <bridgehead renderas="sect3">Changes from Boost 1.34 to 1.38 (date_time 1.05 to 1.06)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Feature</entry>
+ <entry>
+ Added support for formatting and reading time durations longer than 24 hours.
+ A new formatter <code>%O</code> is used indicate such long durations in the
+ format string. The old <code>%H</code> format specifier is thus restricted
+ to represent durations that fit into two characters, in order to retain support
+ for reading durations in ISO format. In case if it is detected that the <code>%H</code>
+ format specifier is used with longer durations, the results are not specified
+ (an assertion in debug builds is raised).
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Added support for GCC 4.3. Several compilation issues were solved, as well as
+ compiler warnings were taken care of.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Added missing streaming operators for the <code>local_time_period</code> class.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Added several missing includes in different places. Some includes that are
+ not needed in some configurations were made conditional.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Solved compilation problem that was caused by not finding streaming operators
+ for <code>gregorian::date_duration</code> via ADL. The type is now made actually
+ a class rather a typedef for the <code>date_time::date_duration</code> template.
+ The similar change was done for <code>gregorian::weeks</code>.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Added a correctly spelled <code>date_time::hundredth</code> time resolution enum
+ value. The old one <code>date_time::hundreth</code> is considered deprecated and
+ to be removed in future releases.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed compilation error in <code>format_date_parser.hpp</code> because of incorrect
+ stream type being used.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ On Windows platform made inclusion of <code>windows.h</code> optional. The header is only used
+ when the <code>BOOST_USE_WINDOWS_H</code> macro is defined. Otherwise (and by default),
+ the library uses internal definitions of symbols from this header.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ On Windows platform function <code>from_ftime</code> could return incorrect time if
+ the <code>FILETIME</code> that is being passed to the function contained dates before 1970-Jan-01.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed a possible crash in <code>gregorian::special_value_from_string</code> if the string
+ did not represent a valid special value.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Removed the <code>testfrmwk.hpp</code> file from the public include directory. This file
+ was internal for the library tests and was not documented.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed missing include in <code>filetime_functions.hpp</code>
+ (<ulink url="https://svn.boost.org/trac/boost/ticket/2688">#2688</ulink>).
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed dereferencing end string iterators in different places of code,
+ which could cause crashes on MSVC
+ (<ulink url="https://svn.boost.org/trac/boost/ticket/2698">#2698</ulink>).
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+
<bridgehead renderas="sect3">Changes from Boost 1.33 to 1.34 (date_time 1.04 to 1.05)</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
@@ -56,7 +217,6 @@
<row>
<entry>Bug Fix</entry>
<entry>Fix DST traits for Austrialia (sf# 1672139) to set end of DST at 3:00 am instead of 2:00 am.
-
</entry>
</row>
@@ -103,13 +263,6 @@
</entry>
</row>
-
- <row>
- <entry>Bug Fix</entry>
- <entry>
- </entry>
- </row>
-
</tbody>
</tgroup>
</informaltable>
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -40,7 +40,7 @@
<para>
The construction of a date validates all input so that it is not possible to
- construct and 'invalid' date. That is 2001-Feb-29 cannot be constructed as a date.
+ construct an 'invalid' date. That is 2001-Feb-29 cannot be constructed as a date.
Various exceptions derived from std::out_of_range are thrown to indicate which aspect
of the date input is invalid. Note that the
special value not-a-date-time can be used as 'invalid' or 'null' date if so desired.
@@ -230,7 +230,7 @@
<row>
<entry valign="top" morerows="1"><screen>greg_day_of_week day_of_week() const</screen></entry>
- <entry>Get the day of the week (eg: Sunday, Monday, etc.</entry>
+ <entry>Get the day of the week (Sunday, Monday, etc.)</entry>
</row>
<row>
<entry><screen>date d(2002,Jan,10);
@@ -364,7 +364,7 @@
<tbody>
<row>
<entry valign="top" morerows="1"><screen>std::string to_simple_string(date d)</screen></entry>
- <entry>To <code>YYYY-mmm-DD</code> string where <code>mmm</code> 3 char month name.</entry>
+ <entry>To <code>YYYY-mmm-DD</code> string where <code>mmm</code> is a 3 char month name.</entry>
</row>
<row>
<entry><screen>"2002-Jan-01"</screen></entry>
@@ -447,7 +447,7 @@
<row>
<entry valign="top" morerows="1"><screen>date operator-(date_duration) const</screen></entry>
- <entry>Return a date by adding a day offset</entry>
+ <entry>Return a date by substracting a day offset</entry>
</row>
<row>
<entry><screen>date d(2002,Jan,1);
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -113,14 +113,16 @@
<row>
<entry valign="top" morerows="1"><screen>date_period expand(days)</screen></entry>
- <entry>Add duration to both begin and end.</entry>
+ <entry>Subtract duration from begin and add duration to end.</entry>
</row>
<row>
+ <entry>
<screen>
date_period dp(date(2005,Jan,2), days(2));
dp.expand(days(1));
// dp == 2005-Jan-01 to 2005-Jan-04
- </screen>
+ </screen>
+ </entry>
</row>
</tbody>
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -301,6 +301,14 @@
</row>
<row>
+ <entry valign="top" morerows="1"><screen>%O</screen></entry>
+ <entry>The number of hours in a time duration as a decimal number (range 0 to max. representable duration); single digits are preceded by a zero.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
<entry valign="top" morerows="1"><screen>%I !</screen></entry>
<entry>The hour as a decimal number using a 12-hour clock</entry>
</row>
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -24,7 +24,7 @@
</para>
<para>All types for the gregorian system are found in namespace boost::gregorian. The library supports a convenience header boost/date_time/gregorian/gregorian_types.hpp that will include all the classes of the library with no input/output dependency. Another header boost/date_time/gregorian/gregorian.hpp will include the types and the input/output code.
</para>
- <para>The class <link linkend="date_time.gregorian.date_class">boost::gregorian::date</link> is the primary temporal type for users. If you are interested in learning about writing programs do specialized date calculations such as finding the "first sunday in april" see the date <link linkend="date_time.gregorian.date_algorithms">generators and algorithms page</link>.
+ <para>The class <link linkend="date_time.gregorian.date_class">boost::gregorian::date</link> is the primary temporal type for users. If you are interested in learning about writing programs that do specialized date calculations such as finding the "first sunday in april" see the date <link linkend="date_time.gregorian.date_algorithms">generators and algorithms page</link>.
</para>
<anchor id="greg_ex" />
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -11,7 +11,7 @@
<para>
<anchor id="snap_to_details" />
<bridgehead renderas="sect4">Reversibility of Operations Pitfall</bridgehead>
-<para>A natural expectation when adding a number of months to a date, and then subtracting the same number of months, is to end up exactly where you started. This is most often the result the <code>date_time</code> library provides but there is one significant exception: The snap-to-end-of-month behavior implemented by the <link linkend="additional_duration_types">months</link> duration type. The <link linkend="additional_duration_types">months</link> duration type may provide unexpected results when the starting day is the 28th, 29th, or 30th in a 31 day month. The <link linkend="iterators_intro">month_iterator</link> is not effected by this issue and is therefore included in the examples to illustrate a possible alternative.
+<para>A natural expectation when adding a number of months to a date, and then subtracting the same number of months, is to end up exactly where you started. This is most often the result the <code>date_time</code> library provides but there is one significant exception: The snap-to-end-of-month behavior implemented by the <link linkend="additional_duration_types">months</link> duration type. The <link linkend="additional_duration_types">months</link> duration type may provide unexpected results when the starting day is the 28th, 29th, or 30th in a 31 day month. The <link linkend="iterators_intro">month_iterator</link> is not affected by this issue and is therefore included in the examples to illustrate a possible alternative.
</para>
<para>When the starting date is in the middle of a month, adding or subtracting any number of months will result in a date that is the same day of month (e.g. if you start on the 15th, you will end on the 15th). When a date is the last day of the month, adding or subtracting any number of months will give a result that is also the last day of the month (e.g if you start on Jan 31st, you will land on: Feb 28th, Mar 31st, etc).
@@ -29,7 +29,7 @@
</programlisting>
</para>
-<para>If the start date is the 28th, 29th, or 30th in a 31 day month, the result of adding or subtracting a month may result in the snap-to-end-of-month behavior kicking in unexpectedly. This would cause the final result to be different that the starting date.
+<para>If the start date is the 28th, 29th, or 30th in a 31 day month, the result of adding or subtracting a month may result in the snap-to-end-of-month behavior kicking in unexpectedly. This would cause the final result to be different than the starting date.
<programlisting>
// using months duration type
date d(2005, Nov, 29);
Modified: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml
==============================================================================
--- sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml (original)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml 2009-08-10 17:15:05 EDT (Mon, 10 Aug 2009)
@@ -60,8 +60,9 @@
</row>
<row>
<entry><screen>date d(2002,Jan,01);
-ptime t(d, seconds(10)); //10 sec after midnight
-time_period tp(t, hours(3));</screen>
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+time_period tp(t1, t2);</screen>
</entry>
</row>
@@ -72,9 +73,8 @@
</row>
<row>
<entry><screen>date d(2002,Jan,01);
-ptime t1(d, seconds(10)); //10 sec after midnight
-ptime t2(d, hours(10)); //10 hours after midnight
-time_period tp(t1, t2);</screen>
+ptime t(d, seconds(10)); //10 sec after midnight
+time_period tp(t, hours(3));</screen>
</entry>
</row>
@@ -123,14 +123,16 @@
<row>
<entry valign="top" morerows="1"><screen>time_period expand(days)</screen></entry>
- <entry>Add duration to both begin and end.</entry>
+ <entry>Subtract duration from begin and add duration to end.</entry>
</row>
<row>
+ <entry>
<screen>
time_period tp(ptime(date(2005,Jan,1),hours(1)), hours(2));
tp.expand(minutes(5));
// tp == 2005-Jan-01 00:55:00 to 2005-Jan-01 03:05:00
</screen>
+ </entry>
</row>
</tbody>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk