Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49705 - in branches/release: boost/date_time boost/date_time/gregorian boost/date_time/local_time boost/date_time/posix_time libs/date_time/test/gregorian libs/date_time/test/local_time libs/date_time/test/posix_time libs/date_time/xmldoc
From: andrey.semashev_at_[hidden]
Date: 2008-11-12 14:37:58


Author: andysem
Date: 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
New Revision: 49705
URL: http://svn.boost.org/trac/boost/changeset/49705

Log:
Merged various fixes from trunk.

Text files modified:
   branches/release/boost/date_time/c_local_time_adjustor.hpp | 8
   branches/release/boost/date_time/c_time.hpp | 20 ++
   branches/release/boost/date_time/compiler_config.hpp | 30 ++++
   branches/release/boost/date_time/constrained_value.hpp | 47 +++++-
   branches/release/boost/date_time/date_duration.hpp | 25 +--
   branches/release/boost/date_time/date_facet.hpp | 25 ++-
   branches/release/boost/date_time/date_generator_parser.hpp | 101 ++++++++--------
   branches/release/boost/date_time/date_generators.hpp | 30 ++--
   branches/release/boost/date_time/date_parsing.hpp | 56 ++++----
   branches/release/boost/date_time/filetime_functions.hpp | 149 ++++++++++++++++++-----
   branches/release/boost/date_time/format_date_parser.hpp | 20 ++
   branches/release/boost/date_time/gregorian/conversion.hpp | 25 ++-
   branches/release/boost/date_time/gregorian/greg_date.hpp | 11
   branches/release/boost/date_time/gregorian/greg_duration.hpp | 114 ++++++++++++++++-
   branches/release/boost/date_time/gregorian/greg_duration_types.hpp | 21 ++
   branches/release/boost/date_time/gregorian/greg_facet.hpp | 19 +-
   branches/release/boost/date_time/gregorian/greg_serialize.hpp | 4
   branches/release/boost/date_time/gregorian/greg_weekday.hpp | 2
   branches/release/boost/date_time/gregorian/gregorian_io.hpp | 13 +
   branches/release/boost/date_time/gregorian_calendar.ipp | 2
   branches/release/boost/date_time/int_adapter.hpp | 4
   branches/release/boost/date_time/local_time/local_date_time.hpp | 52 ++++----
   branches/release/boost/date_time/local_time/local_time_io.hpp | 83 ++++++++++++-
   branches/release/boost/date_time/local_time/posix_time_zone.hpp | 49 ++++---
   branches/release/boost/date_time/local_time_adjustor.hpp | 27 ++-
   branches/release/boost/date_time/microsec_time_clock.hpp | 149 +++++------------------
   branches/release/boost/date_time/period_parser.hpp | 8
   branches/release/boost/date_time/posix_time/conversion.hpp | 12 +
   branches/release/boost/date_time/posix_time/posix_time_io.hpp | 22 +--
   branches/release/boost/date_time/string_parse_tree.hpp | 90 +++++++-------
   branches/release/boost/date_time/time.hpp | 11
   branches/release/boost/date_time/time_defs.hpp | 12 +
   branches/release/boost/date_time/time_facet.hpp | 248 +++++++++++++++++++++++++--------------
   branches/release/boost/date_time/time_formatting_streams.hpp | 11 +
   branches/release/boost/date_time/time_system_split.hpp | 16 -
   branches/release/boost/date_time/tz_db_base.hpp | 34 ++--
   branches/release/boost/date_time/wrapping_int.hpp | 34 +++--
   branches/release/libs/date_time/test/gregorian/testdate.cpp | 14 +-
   branches/release/libs/date_time/test/gregorian/testdate_input_facet.cpp | 4
   branches/release/libs/date_time/test/gregorian/testfacet.cpp | 4
   branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp | 49 ++-----
   branches/release/libs/date_time/test/gregorian/testparse_date.cpp | 14 +-
   branches/release/libs/date_time/test/local_time/testlocal_time.cpp | 2
   branches/release/libs/date_time/test/local_time/testlocal_time_facet.cpp | 26 +++
   branches/release/libs/date_time/test/local_time/testlocal_time_input_facet.cpp | 4
   branches/release/libs/date_time/test/local_time/testposix_time_zone.cpp | 12
   branches/release/libs/date_time/test/local_time/testtz_database.cpp | 8
   branches/release/libs/date_time/test/local_time/testwposix_time_zone.cpp | 12
   branches/release/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp | 4
   branches/release/libs/date_time/test/posix_time/testtime.cpp | 4
   branches/release/libs/date_time/test/posix_time/testtime_input_facet.cpp | 4
   branches/release/libs/date_time/test/posix_time/testtime_serialize.cpp | 28 +--
   branches/release/libs/date_time/xmldoc/changes.xml | 92 ++++++++++++++
   branches/release/libs/date_time/xmldoc/date_class.xml | 8
   branches/release/libs/date_time/xmldoc/format_flags.xml | 8 +
   branches/release/libs/date_time/xmldoc/gregorian.xml | 2
   branches/release/libs/date_time/xmldoc/snap_to_details.xml | 4
   57 files changed, 1168 insertions(+), 719 deletions(-)

Modified: branches/release/boost/date_time/c_local_time_adjustor.hpp
==============================================================================
--- branches/release/boost/date_time/c_local_time_adjustor.hpp (original)
+++ branches/release/boost/date_time/c_local_time_adjustor.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/boost/date_time/c_time.hpp
==============================================================================
--- branches/release/boost/date_time/c_time.hpp (original)
+++ branches/release/boost/date_time/c_time.hpp 2008-11-12 14:37:53 EST (Wed, 12 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: branches/release/boost/date_time/compiler_config.hpp
==============================================================================
--- branches/release/boost/date_time/compiler_config.hpp (original)
+++ branches/release/boost/date_time/compiler_config.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -8,7 +8,9 @@
  * $Date$
  */
 
- #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: branches/release/boost/date_time/constrained_value.hpp
==============================================================================
--- branches/release/boost/date_time/constrained_value.hpp (original)
+++ branches/release/boost/date_time/constrained_value.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,7 +9,12 @@
  * $Date$
  */
 
+#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: branches/release/boost/date_time/date_duration.hpp
==============================================================================
--- branches/release/boost/date_time/date_duration.hpp (original)
+++ branches/release/boost/date_time/date_duration.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -11,6 +11,7 @@
 
 
 #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: branches/release/boost/date_time/date_facet.hpp
==============================================================================
--- branches/release/boost/date_time/date_facet.hpp (original)
+++ branches/release/boost/date_time/date_facet.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,17 +9,21 @@
  * $Date$
  */
 
-
-#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 {
 
@@ -638,7 +642,8 @@
         }
         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));
       }

Modified: branches/release/boost/date_time/date_generator_parser.hpp
==============================================================================
--- branches/release/boost/date_time/date_generator_parser.hpp (original)
+++ branches/release/boost/date_time/date_generator_parser.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -10,12 +10,14 @@
  * $Date$
  */
 
-
-#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: branches/release/boost/date_time/date_generators.hpp
==============================================================================
--- branches/release/boost/date_time/date_generators.hpp (original)
+++ branches/release/boost/date_time/date_generators.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -12,10 +12,12 @@
 /*! @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: branches/release/boost/date_time/date_parsing.hpp
==============================================================================
--- branches/release/boost/date_time/date_parsing.hpp (original)
+++ branches/release/boost/date_time/date_parsing.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,15 +9,15 @@
  * $Date$
  */
 
-#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)
@@ -34,38 +34,38 @@
    */
   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++)));
+ 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;
         }
@@ -101,7 +101,7 @@
     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";
       }
@@ -196,7 +196,7 @@
                      iterator_type& end,
                      char)
     {
- std::stringstream ss("");
+ std::ostringstream ss;
       while(beg != end) {
         ss << *beg++;
       }
@@ -228,7 +228,7 @@
                                iterator_type& end,
                                wchar_t)
     {
- std::stringstream ss("");
+ std::ostringstream ss;
       while(beg != end) {
 #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
@@ -249,7 +249,7 @@
                      iterator_type& end,
                      std::wstring) {
       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)
@@ -289,7 +289,7 @@
       return period<date_type, typename date_type::duration_type>(d1, d2);
     }
 #endif
-
+
 } } //namespace date_time
 
 

Modified: branches/release/boost/date_time/filetime_functions.hpp
==============================================================================
--- branches/release/boost/date_time/filetime_functions.hpp (original)
+++ branches/release/boost/date_time/filetime_functions.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -16,59 +16,138 @@
  */
 
 #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>
 
-
 namespace boost {
 namespace date_time {
 
+namespace winapi {
+
+#if !defined(BOOST_USE_WINDOWS_H)
+
+extern "C" {
+
+ struct FILETIME
+ {
+ boost::uint32_t dwLowDateTime;
+ boost::uint32_t dwHighDateTime;
+ };
+ struct SYSTEMTIME
+ {
+ boost::uint16_t wYear;
+ boost::uint16_t wMonth;
+ boost::uint16_t wDayOfWeek;
+ boost::uint16_t wDay;
+ boost::uint16_t wHour;
+ boost::uint16_t wMinute;
+ boost::uint16_t wSecond;
+ boost::uint16_t wMilliseconds;
+ };
+
+ __declspec(dllimport) void __stdcall GetSystemTimeAsFileTime(FILETIME* lpFileTime);
+ __declspec(dllimport) int __stdcall FileTimeToLocalFileTime(const FILETIME* lpFileTime, FILETIME* lpLocalFileTime);
+ __declspec(dllimport) void __stdcall GetSystemTime(SYSTEMTIME* lpSystemTime);
+ __declspec(dllimport) int __stdcall SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, FILETIME* lpFileTime);
+
+} // extern "C"
+
+#endif // defined(BOOST_USE_WINDOWS_H)
+
+ typedef FILETIME file_time;
+ typedef SYSTEMTIME system_time;
+
+ inline void get_system_time_as_file_time(file_time& ft)
+ {
+#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
+ // Some runtime library implementations expect local times as the norm for ctime.
+ file_time ft_utc;
+ GetSystemTimeAsFileTime(&ft_utc);
+ FileTimeToLocalFileTime(&ft_utc, &ft);
+#elif defined(BOOST_NO_GETSYSTEMTIMEASFILETIME)
+ system_time st;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ft);
+#else
+ GetSystemTimeAsFileTime(&ft);
+#endif
+ }
+
+ /*!
+ * The function converts file_time into number of nanoseconds elapsed since 1970-Jan-01
+ *
+ * \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_nanoseconds(FileTimeT const& ft)
+ {
+ /* shift is difference between 1970-Jan-01 & 1601-Jan-01
+ * in 100-nanosecond intervals */
+ const uint64_t c1 = 27111902UL;
+ const uint64_t c2 = 3577643008UL; // issues warning without 'UL'
+ const uint64_t shift = (c1 << 32) + c2;
+
+ union {
+ FileTimeT as_file_time;
+ uint64_t as_integer;
+ } caster;
+ caster.as_file_time = ft;
+
+ caster.as_integer -= shift; // filetime is now 100-nanos since 1970-Jan-01
+ return (caster.as_integer * 100); // upscale to nanoseconds
+ }
+
+} // namespace winapi
 
   //! Create a time object from an initialized FILETIME struct.
- /*! 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>
+ * 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
- 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
-#else
- uint64_t sub_sec = (filetime % 10000000) / 10; // truncate to microseconds
+ 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;
+
+ uint64_t nanos = winapi::file_time_to_nanoseconds(ft);
+
+ uint64_t sec = nanos / 1000000000UL;
+ uint32_t sub_sec = (nanos % 1000000000UL); // nanoseconds since the last second
+#if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
+ sub_sec /= 1000; // truncate to microseconds
 #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_duration_type dd(days);
     date_type d = date_type(1970, Jan, 01) + dd;
- return time_type(d, time_duration_type(_h, _m, _s, sub_sec));
+ return TimeT(d, time_duration_type(hours, minutes, seconds, sub_sec));
   }
 
 }} // boost::date_time

Modified: branches/release/boost/date_time/format_date_parser.hpp
==============================================================================
--- branches/release/boost/date_time/format_date_parser.hpp (original)
+++ branches/release/boost/date_time/format_date_parser.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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;
@@ -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: branches/release/boost/date_time/gregorian/conversion.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/conversion.hpp (original)
+++ branches/release/boost/date_time/gregorian/conversion.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,18 +9,20 @@
  * $Date$
  */
 
-#include <exception>
-#include "boost/date_time/gregorian/gregorian_types.hpp"
-#include "boost/date_time/c_time.hpp"
+#include <string>
+#include <stdexcept>
+#include <boost/throw_exception.hpp>
+#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"
+# include <boost/date_time/gregorian/formatters_limited.hpp>
 # else
-# include "boost/date_time/gregorian/formatters.hpp"
+# 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"
+# include <boost/date_time/gregorian/gregorian_io.hpp>
 #endif // USE_DATE_TIME_PRE_1_33_FACET_IO
 
 namespace boost {
@@ -33,14 +35,15 @@
   std::tm to_tm(const date& d)
   {
     if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){
+ std::string s = "tm unable to handle date value of ";
 #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);
+ s += to_simple_string(d);
 #else
- std::stringstream ss;
- ss << "tm unable to handle date value of " << d;
- throw std::out_of_range(ss.str());
+ std::ostringstream ss;
+ ss << d;
+ s += ss.str();
 #endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+ boost::throw_exception(std::out_of_range(s));
     }
     std::tm datetm;
     boost::gregorian::date::ymd_type ymd = d.year_month_day();

Modified: branches/release/boost/date_time/gregorian/greg_date.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_date.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_date.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,10 +9,11 @@
  * $Date$
  */
 
-#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: branches/release/boost/date_time/gregorian/greg_duration.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_duration.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_duration.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,30 +9,126 @@
  * $Date$
  */
 
-#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: branches/release/boost/date_time/gregorian/greg_duration_types.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_duration_types.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_duration_types.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,11 +9,11 @@
  */
 
 
-#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: branches/release/boost/date_time/gregorian/greg_facet.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_facet.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_facet.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -12,12 +12,15 @@
 #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 {
@@ -286,14 +289,12 @@
     /* 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);
     }
     
     num += 1; // months numbered 1-12
@@ -328,14 +329,12 @@
     /* 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);
     }
    
     wd = greg_weekday(num); // weekdays numbered 0-6

Modified: branches/release/boost/date_time/gregorian/greg_serialize.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_serialize.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_serialize.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/boost/date_time/gregorian/greg_weekday.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/greg_weekday.hpp (original)
+++ branches/release/boost/date_time/gregorian/greg_weekday.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/boost/date_time/gregorian/gregorian_io.hpp
==============================================================================
--- branches/release/boost/date_time/gregorian/gregorian_io.hpp (original)
+++ branches/release/boost/date_time/gregorian/gregorian_io.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,10 +9,17 @@
  * $Date$
  */
 
-#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: branches/release/boost/date_time/gregorian_calendar.ipp
==============================================================================
--- branches/release/boost/date_time/gregorian_calendar.ipp (original)
+++ branches/release/boost/date_time/gregorian_calendar.ipp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/boost/date_time/int_adapter.hpp
==============================================================================
--- branches/release/boost/date_time/int_adapter.hpp (original)
+++ branches/release/boost/date_time/int_adapter.hpp 2008-11-12 14:37:53 EST (Wed, 12 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: branches/release/boost/date_time/local_time/local_date_time.hpp
==============================================================================
--- branches/release/boost/date_time/local_time/local_date_time.hpp (original)
+++ branches/release/boost/date_time/local_time/local_date_time.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -8,15 +8,17 @@
  * $Date$
  */
 
-
-#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: branches/release/boost/date_time/local_time/local_time_io.hpp
==============================================================================
--- branches/release/boost/date_time/local_time/local_time_io.hpp (original)
+++ branches/release/boost/date_time/local_time/local_time_io.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -8,12 +8,15 @@
  * $Date$
  */
 
+#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 {
@@ -106,13 +109,79 @@
           // if the user want's to fail quietly, we simply set the 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.
+ std::ostreambuf_iterator<CharT> oitr(os);
+ 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: branches/release/boost/date_time/local_time/posix_time_zone.hpp
==============================================================================
--- branches/release/boost/date_time/local_time/posix_time_zone.hpp (original)
+++ branches/release/boost/date_time/local_time/posix_time_zone.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -10,15 +10,16 @@
 
 #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;
@@ -231,7 +234,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 +245,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 +289,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
@@ -328,7 +331,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 +346,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_)));
       }
     }
 

Modified: branches/release/boost/date_time/local_time_adjustor.hpp
==============================================================================
--- branches/release/boost/date_time/local_time_adjustor.hpp (original)
+++ branches/release/boost/date_time/local_time_adjustor.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -13,9 +13,13 @@
   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: branches/release/boost/date_time/microsec_time_clock.hpp
==============================================================================
--- branches/release/boost/date_time/microsec_time_clock.hpp (original)
+++ branches/release/boost/date_time/microsec_time_clock.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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,118 +64,39 @@
       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 nanos = winapi::file_time_to_nanoseconds(ft);
+ std::time_t t = static_cast<time_t>(nanos / 1000000000UL); // 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>((nanos % 1000000000UL) / 1000UL);
+#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);
@@ -182,17 +105,15 @@
       //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: branches/release/boost/date_time/period_parser.hpp
==============================================================================
--- branches/release/boost/date_time/period_parser.hpp (original)
+++ branches/release/boost/date_time/period_parser.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -10,8 +10,9 @@
  * $Date$
  */
 
-#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 {
@@ -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: branches/release/boost/date_time/posix_time/conversion.hpp
==============================================================================
--- branches/release/boost/date_time/posix_time/conversion.hpp (original)
+++ branches/release/boost/date_time/posix_time/conversion.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -72,14 +72,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: branches/release/boost/date_time/posix_time/posix_time_io.hpp
==============================================================================
--- branches/release/boost/date_time/posix_time/posix_time_io.hpp (original)
+++ branches/release/boost/date_time/posix_time/posix_time_io.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,14 +9,16 @@
  * $Date$
  */
 
-#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 {
@@ -75,7 +77,6 @@
     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);
@@ -101,7 +102,6 @@
           // if the user want's to fail quietly, we simply set the failbit
           is.setstate(std::ios_base::failbit);
         }
-
       }
     }
     return is;
@@ -146,7 +146,6 @@
     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);
@@ -168,7 +167,6 @@
         else {
           is.setstate(std::ios_base::failbit);
         }
-
       }
     }
     return is;
@@ -214,7 +212,6 @@
     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);
@@ -236,7 +233,6 @@
         else {
           is.setstate(std::ios_base::failbit);
         }
-
       }
     }
     return is;

Modified: branches/release/boost/date_time/string_parse_tree.hpp
==============================================================================
--- branches/release/boost/date_time/string_parse_tree.hpp (original)
+++ branches/release/boost/date_time/string_parse_tree.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -2,7 +2,7 @@
 #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
@@ -11,7 +11,7 @@
 
 
 #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: branches/release/boost/date_time/time.hpp
==============================================================================
--- branches/release/boost/date_time/time.hpp (original)
+++ branches/release/boost/date_time/time.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -13,9 +13,10 @@
 /*! @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: branches/release/boost/date_time/time_defs.hpp
==============================================================================
--- branches/release/boost/date_time/time_defs.hpp (original)
+++ branches/release/boost/date_time/time_defs.hpp 2008-11-12 14:37:53 EST (Wed, 12 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: branches/release/boost/date_time/time_facet.hpp
==============================================================================
--- branches/release/boost/date_time/time_facet.hpp (original)
+++ branches/release/boost/date_time/time_facet.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -10,12 +10,22 @@
  * $Date$
  */
 
-#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/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 +38,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 +74,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 +192,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 +219,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 +263,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 +285,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 +303,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 +321,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 +337,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 +354,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 +408,46 @@
 
       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);
+ if (hours_str.length() > 2)
+ hours_str.erase(0, 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: branches/release/boost/date_time/time_formatting_streams.hpp
==============================================================================
--- branches/release/boost/date_time/time_formatting_streams.hpp (original)
+++ branches/release/boost/date_time/time_formatting_streams.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -9,12 +9,16 @@
  * $Date$
  */
 
-
-#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: branches/release/boost/date_time/time_system_split.hpp
==============================================================================
--- branches/release/boost/date_time/time_system_split.hpp (original)
+++ branches/release/boost/date_time/time_system_split.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/boost/date_time/tz_db_base.hpp
==============================================================================
--- branches/release/boost/date_time/tz_db_base.hpp (original)
+++ branches/release/boost/date_time/tz_db_base.hpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -8,17 +8,19 @@
  * $Date$
  */
 
-#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: branches/release/boost/date_time/wrapping_int.hpp
==============================================================================
--- branches/release/boost/date_time/wrapping_int.hpp (original)
+++ branches/release/boost/date_time/wrapping_int.hpp 2008-11-12 14:37:53 EST (Wed, 12 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;

Modified: branches/release/libs/date_time/test/gregorian/testdate.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testdate.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testdate.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/gregorian/testdate_input_facet.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testdate_input_facet.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testdate_input_facet.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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

Modified: branches/release/libs/date_time/test/gregorian/testfacet.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testfacet.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testfacet.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testgreg_serialize.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -13,7 +13,7 @@
 #include <boost/date_time/gregorian/gregorian.hpp>
 #include <boost/date_time/gregorian/greg_serialize.hpp>
 #include <boost/date_time/testfrmwk.hpp>
-#include <fstream>
+#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: branches/release/libs/date_time/test/gregorian/testparse_date.cpp
==============================================================================
--- branches/release/libs/date_time/test/gregorian/testparse_date.cpp (original)
+++ branches/release/libs/date_time/test/gregorian/testparse_date.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/local_time/testlocal_time.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testlocal_time.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testlocal_time.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/local_time/testlocal_time_facet.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testlocal_time_facet.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testlocal_time_facet.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -17,15 +17,21 @@
 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: branches/release/libs/date_time/test/local_time/testlocal_time_input_facet.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testlocal_time_input_facet.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testlocal_time_input_facet.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/local_time/testposix_time_zone.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testposix_time_zone.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testposix_time_zone.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/local_time/testtz_database.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testtz_database.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testtz_database.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/local_time/testwposix_time_zone.cpp
==============================================================================
--- branches/release/libs/date_time/test/local_time/testwposix_time_zone.cpp (original)
+++ branches/release/libs/date_time/test/local_time/testwposix_time_zone.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp
==============================================================================
--- branches/release/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp (original)
+++ branches/release/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -8,7 +8,9 @@
 #include "boost/date_time/posix_time/posix_time.hpp"
 #include "boost/date_time/microsec_time_clock.hpp"
 #include "boost/date_time/testfrmwk.hpp"
-
+#if defined(BOOST_HAS_FTIME)
+#include <windows.h>
+#endif
 
 int
 main()

Modified: branches/release/libs/date_time/test/posix_time/testtime.cpp
==============================================================================
--- branches/release/libs/date_time/test/posix_time/testtime.cpp (original)
+++ branches/release/libs/date_time/test/posix_time/testtime.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/test/posix_time/testtime_input_facet.cpp
==============================================================================
--- branches/release/libs/date_time/test/posix_time/testtime_input_facet.cpp (original)
+++ branches/release/libs/date_time/test/posix_time/testtime_input_facet.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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

Modified: branches/release/libs/date_time/test/posix_time/testtime_serialize.cpp
==============================================================================
--- branches/release/libs/date_time/test/posix_time/testtime_serialize.cpp (original)
+++ branches/release/libs/date_time/test/posix_time/testtime_serialize.cpp 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -12,7 +12,7 @@
 #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 <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: branches/release/libs/date_time/xmldoc/changes.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/changes.xml (original)
+++ branches/release/libs/date_time/xmldoc/changes.xml 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -12,6 +12,98 @@
   
   <!-- 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.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.
+ </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>
+ </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">

Modified: branches/release/libs/date_time/xmldoc/date_class.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/date_class.xml (original)
+++ branches/release/libs/date_time/xmldoc/date_class.xml 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/xmldoc/format_flags.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/format_flags.xml (original)
+++ branches/release/libs/date_time/xmldoc/format_flags.xml 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/xmldoc/gregorian.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/gregorian.xml (original)
+++ branches/release/libs/date_time/xmldoc/gregorian.xml 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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: branches/release/libs/date_time/xmldoc/snap_to_details.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/snap_to_details.xml (original)
+++ branches/release/libs/date_time/xmldoc/snap_to_details.xml 2008-11-12 14:37:53 EST (Wed, 12 Nov 2008)
@@ -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);


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