Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56372 - in trunk: boost/date_time boost/date_time/gregorian libs/date_time/test/gregorian
From: andrey.semashev_at_[hidden]
Date: 2009-09-24 16:21:39


Author: andysem
Date: 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
New Revision: 56372
URL: http://svn.boost.org/trac/boost/changeset/56372

Log:
Refs #3308. Fixed calculation of difference between dates on 64 bit platforms.
Text files modified:
   trunk/boost/date_time/date.hpp | 75 ++++++++++++++----------
   trunk/boost/date_time/gregorian/greg_date.hpp | 24 ++++----
   trunk/boost/date_time/gregorian_calendar.hpp | 14 ++--
   trunk/boost/date_time/gregorian_calendar.ipp | 56 +++++++++---------
   trunk/libs/date_time/test/gregorian/testdate.cpp | 118 ++++++++++++++++++++--------------------
   5 files changed, 149 insertions(+), 138 deletions(-)

Modified: trunk/boost/date_time/date.hpp
==============================================================================
--- trunk/boost/date_time/date.hpp (original)
+++ trunk/boost/date_time/date.hpp 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
@@ -2,43 +2,43 @@
 #define DATE_TIME_DATE_HPP___
 
 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
  * Boost Software License, Version 1.0. (See accompanying
  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  * Author: Jeff Garland, Bart Garst
  * $Date$
  */
 
-#include "boost/date_time/year_month_day.hpp"
-#include "boost/date_time/special_defs.hpp"
-#include "boost/operators.hpp"
+#include <boost/operators.hpp>
+#include <boost/date_time/year_month_day.hpp>
+#include <boost/date_time/special_defs.hpp>
 
 namespace boost {
 namespace date_time {
 
   //!Representation of timepoint at the one day level resolution.
- /*!
+ /*!
     The date template represents an interface shell for a date class
     that is based on a year-month-day system such as the gregorian
     or iso systems. It provides basic operations to enable calculation
- and comparisons.
+ and comparisons.
 
     <b>Theory</b>
 
- This date representation fundamentally departs from the C tm struct
+ This date representation fundamentally departs from the C tm struct
     approach. The goal for this type is to provide efficient date
     operations (add, subtract) and storage (minimize space to represent)
     in a concrete class. Thus, the date uses a count internally to
- represent a particular date. The calendar parameter defines
+ represent a particular date. The calendar parameter defines
     the policies for converting the the year-month-day and internal
     counted form here. Applications that need to perform heavy
     formatting of the same date repeatedly will perform better
     by using the year-month-day representation.
-
+
     Internally the date uses a day number to represent the date.
- This is a monotonic time representation. This representation
+ This is a monotonic time representation. This representation
     allows for fast comparison as well as simplifying
- the creation of writing numeric operations. Essentially, the
+ the creation of writing numeric operations. Essentially, the
     internal day number is like adjusted julian day. The adjustment
     is determined by the Epoch date which is represented as day 1 of
     the calendar. Day 0 is reserved for negative infinity so that
@@ -48,11 +48,11 @@
     day representations.
   */
 
-
- template<class T, class calendar, class duration_type_>
- class date : private
- boost::less_than_comparable<T
- , boost::equality_comparable<T
+
+ template<class T, class calendar, class duration_type_>
+ class date : private
+ boost::less_than_comparable<T
+ , boost::equality_comparable<T
> >
   {
   public:
@@ -67,26 +67,26 @@
     typedef typename calendar::date_rep_type date_rep_type;
     typedef typename calendar::date_int_type date_int_type;
     typedef typename calendar::day_of_week_type day_of_week_type;
- date(year_type y, month_type m, day_type d)
+ date(year_type y, month_type m, day_type d)
       : days_(calendar::day_number(ymd_type(y, m, d)))
     {}
- date(const ymd_type& ymd)
+ date(const ymd_type& ymd)
       : days_(calendar::day_number(ymd))
- {}
+ {}
     //let the compiler write copy, assignment, and destructor
     year_type year() const
     {
- ymd_type ymd = calendar::from_day_number(days_);
+ ymd_type ymd = calendar::from_day_number(days_);
       return ymd.year;
     }
     month_type month() const
     {
- ymd_type ymd = calendar::from_day_number(days_);
+ ymd_type ymd = calendar::from_day_number(days_);
       return ymd.month;
     }
     day_type day() const
     {
- ymd_type ymd = calendar::from_day_number(days_);
+ ymd_type ymd = calendar::from_day_number(days_);
       return ymd.day;
     }
     day_of_week_type day_of_week() const
@@ -138,10 +138,21 @@
     }
     duration_type operator-(const date_type& d) const
     {
- date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
- return duration_type(val.as_number());
+ if (!this->is_special() && !d.is_special())
+ {
+ // The duration underlying type may be wider than the date underlying type.
+ // Thus we calculate the difference in terms of two durations from some common fixed base date.
+ typedef typename duration_type::duration_rep_type duration_rep_type;
+ return duration_type(static_cast< duration_rep_type >(days_) - static_cast< duration_rep_type >(d.days_));
+ }
+ else
+ {
+ // In this case the difference will be a special value, too
+ date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
+ return duration_type(val.as_special());
+ }
     }
-
+
     date_type operator-(const duration_type& dd) const
     {
       if(dd.is_special())
@@ -155,10 +166,10 @@
       *this = *this - dd;
       return date_type(days_);
     }
- date_rep_type day_count() const
+ date_rep_type day_count() const
     {
       return days_;
- };
+ }
     //allow internal access from operators
     date_type operator+(const duration_type& dd) const
     {
@@ -170,25 +181,25 @@
     }
     date_type operator+=(const duration_type& dd)
     {
- *this = *this + dd;
+ *this = *this + dd;
       return date_type(days_);
     }
 
     //see reference
   protected:
- /*! This is a private constructor which allows for the creation of new
- dates. It is not exposed to users since that would require class
+ /*! This is a private constructor which allows for the creation of new
+ dates. It is not exposed to users since that would require class
       users to understand the inner workings of the date class.
     */
     explicit date(date_int_type days) : days_(days) {};
     explicit date(date_rep_type days) : days_(days.as_number()) {};
     date_int_type days_;
-
+
   };
 
 
 
-
+
 } } // namespace date_time
 
 

Modified: trunk/boost/date_time/gregorian/greg_date.hpp
==============================================================================
--- trunk/boost/date_time/gregorian/greg_date.hpp (original)
+++ trunk/boost/date_time/gregorian/greg_date.hpp 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
@@ -2,10 +2,10 @@
 #define GREG_DATE_HPP___
 
 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
  * Boost Software License, Version 1.0. (See accompanying
  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
- * Author: Jeff Garland
+ * Author: Jeff Garland
  * $Date$
  */
 
@@ -28,10 +28,10 @@
   using date_time::min_date_time;
 
   //! A date type based on gregorian_calendar
- /*! This class is the primary interface for programming with
+ /*! This class is the primary interface for programming with
       greogorian dates. The is a lightweight type that can be
- freely passed by value. All comparison operators are
- supported.
+ freely passed by value. All comparison operators are
+ supported.
       \ingroup date_basics
   */
   class date : public date_time::date<date, gregorian_calendar, date_duration>
@@ -52,7 +52,7 @@
     {}
 #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
     //! Main constructor with year, month, day
- date(year_type y, month_type m, day_type d)
+ date(year_type y, month_type m, day_type d)
       : date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
     {
       if (gregorian_calendar::end_of_month_day(y, m) < d) {
@@ -60,7 +60,7 @@
       }
     }
     //! Constructor from a ymd_type structure
- explicit date(const ymd_type& ymd)
+ explicit date(const ymd_type& ymd)
       : date_time::date<date, gregorian_calendar, date_duration>(ymd)
     {}
     //! Needed copy constructor
@@ -99,16 +99,16 @@
       return day_of_year_type(doy);
     }
     //!Return the Modified Julian Day number for the date.
- long modjulian_day() const
+ date_int_type modjulian_day() const
     {
       ymd_type ymd = year_month_day();
- return gregorian_calendar::modjulian_day_number(ymd);
+ return gregorian_calendar::modjulian_day_number(ymd);
     }
     //!Return the iso 8601 week number 1..53
     int week_number() const
     {
       ymd_type ymd = year_month_day();
- return gregorian_calendar::week_number(ymd);
+ return gregorian_calendar::week_number(ymd);
     }
     //! Return the day number from the calendar
     date_int_type day_number() const
@@ -118,7 +118,7 @@
     //! Return the last day of the current month
     date end_of_month() const
     {
- ymd_type ymd = year_month_day();
+ ymd_type ymd = year_month_day();
       short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
       return date(ymd.year, ymd.month, eom_day);
     }
@@ -126,7 +126,7 @@
    private:
 
   };
-
+
 
 
 } } //namespace gregorian

Modified: trunk/boost/date_time/gregorian_calendar.hpp
==============================================================================
--- trunk/boost/date_time/gregorian_calendar.hpp (original)
+++ trunk/boost/date_time/gregorian_calendar.hpp 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
@@ -2,10 +2,10 @@
 #define DATE_TIME_GREGORIAN_CALENDAR_HPP__
 
 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
  * Boost Software License, Version 1.0. (See accompanying
  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
- * Author: Jeff Garland
+ * Author: Jeff Garland
  * $Date$
  */
 
@@ -27,7 +27,7 @@
   template<typename ymd_type_, typename date_int_type_>
   class gregorian_calendar_base {
   public:
- //! define a type a date split into components
+ //! define a type a date split into components
     typedef ymd_type_ ymd_type;
     //! define a type for representing months
     typedef typename ymd_type::month_type month_type;
@@ -44,10 +44,10 @@
     //static unsigned short day_of_year(date_int_type);
     static date_int_type day_number(const ymd_type& ymd);
     static date_int_type julian_day_number(const ymd_type& ymd);
- static long modjulian_day_number(const ymd_type& ymd);
+ static date_int_type modjulian_day_number(const ymd_type& ymd);
     static ymd_type from_day_number(date_int_type);
     static ymd_type from_julian_day_number(date_int_type);
- static ymd_type from_modjulian_day_number(long);
+ static ymd_type from_modjulian_day_number(date_int_type);
     static bool is_leap_year(year_type);
     static unsigned short end_of_month_day(year_type y, month_type m);
     static ymd_type epoch();
@@ -58,7 +58,7 @@
 
 
 } } //namespace
-
+
 #ifndef NO_BOOST_DATE_TIME_INLINE
 #include "boost/date_time/gregorian_calendar.ipp"
 #endif
@@ -66,5 +66,5 @@
 
 
 #endif
-
+
 

Modified: trunk/boost/date_time/gregorian_calendar.ipp
==============================================================================
--- trunk/boost/date_time/gregorian_calendar.ipp (original)
+++ trunk/boost/date_time/gregorian_calendar.ipp 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
  * Boost Software License, Version 1.0. (See accompanying
  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  * Author: Jeff Garland, Bart Garst
@@ -27,10 +27,10 @@
     //std::cout << year << "-" << month << "-" << day << " is day: " << d << "\n";
     return d;
   }
-
+
   //!Return the iso week number for the date
   /*!Implements the rules associated with the iso 8601 week number.
- Basically the rule is that Week 1 of the year is the week that contains
+ Basically the rule is that Week 1 of the year is the week that contains
     January 4th or the week that contains the first Thursday in January.
     Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000.
   */
@@ -42,11 +42,11 @@
     unsigned long juliantoday = julian_day_number(ymd);
     unsigned long day = (julianbegin + 3) % 7;
     unsigned long week = (juliantoday + day - julianbegin + 4)/7;
-
+
     if ((week >= 1) && (week <= 52)) {
       return week;
     }
-
+
     if ((week == 53)) {
       if((day==6) ||(day == 5 && is_leap_year(ymd.year))) {
         return week; //under these circumstances week == 53.
@@ -62,18 +62,18 @@
       week = (juliantoday + day - julianbegin + 4)/7;
       return week;
     }
-
+
     return week; //not reachable -- well except if day == 5 and is_leap_year != true
-
+
   }
-
+
   //! Convert a ymd_type into a day number
   /*! The day number is an absolute number of days since the start of count
    */
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   date_int_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd)
+ gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd)
   {
     unsigned short a = static_cast<unsigned short>((14-ymd.month)/12);
     unsigned short y = static_cast<unsigned short>(ymd.year + 4800 - a);
@@ -81,14 +81,14 @@
     unsigned long d = ymd.day + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045;
     return d;
   }
-
+
   //! Convert a year-month-day into the julian day number
   /*! Since this implementation uses julian day internally, this is the same as the day_number.
    */
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   date_int_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
+ gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
   {
     return day_number(ymd);
   }
@@ -99,17 +99,17 @@
    */
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
- long
- gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
+ date_int_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
   {
     return julian_day_number(ymd)-2400001; //prerounded
   }
-
+
   //! Change a day number into a year-month-day
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   ymd_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
   {
     date_int_type a = dayNumber + 32044;
     date_int_type b = (4*a + 3)/146097;
@@ -121,15 +121,15 @@
     unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
     year_type year = static_cast<unsigned short>(100*b + d - 4800 + (m/10));
     //std::cout << year << "-" << month << "-" << day << "\n";
-
+
     return ymd_type(static_cast<unsigned short>(year),month,day);
   }
-
+
   //! Change a day number into a year-month-day
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   ymd_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
   {
     date_int_type a = dayNumber + 32044;
     date_int_type b = (4*a+3)/146097;
@@ -141,19 +141,19 @@
     unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
     year_type year = static_cast<year_type>(100*b + d - 4800 + (m/10));
     //std::cout << year << "-" << month << "-" << day << "\n";
-
+
     return ymd_type(year,month,day);
   }
-
+
   //! Change a modified julian day number into a year-month-day
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   ymd_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(long dayNumber) {
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(date_int_type dayNumber) {
     date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded
     return from_julian_day_number(jd);
   }
-
+
   //! Determine if the provided year is a leap year
   /*!
    *@return true if year is a leap year, false otherwise
@@ -161,12 +161,12 @@
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   bool
- gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
+ gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
   {
     //divisible by 4, not if divisible by 100, but true if divisible by 400
     return (!(year % 4)) && ((year % 100) || (!(year % 400)));
   }
-
+
   //! Calculate the last day of the month
   /*! Find the day which is the end of the month given year and month
    * No error checking is performed.
@@ -175,7 +175,7 @@
   BOOST_DATE_TIME_INLINE
   unsigned short
   gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year,
- month_type month)
+ month_type month)
   {
     switch (month) {
     case 2:
@@ -194,12 +194,12 @@
     };
 
   }
-
+
   //! Provide the ymd_type specification for the calandar start
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   ymd_type_
- gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
+ gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
   {
     return ymd_type(1400,1,1);
   }
@@ -208,7 +208,7 @@
   template<typename ymd_type_, typename date_int_type_>
   BOOST_DATE_TIME_INLINE
   unsigned short
- gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
+ gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
   {
     return 7;
   }

Modified: trunk/libs/date_time/test/gregorian/testdate.cpp
==============================================================================
--- trunk/libs/date_time/test/gregorian/testdate.cpp (original)
+++ trunk/libs/date_time/test/gregorian/testdate.cpp 2009-09-24 16:21:37 EDT (Thu, 24 Sep 2009)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
  * Boost Software License, Version 1.0. (See accompanying
  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  * Author: Jeff Garland, Bart Garst
@@ -10,9 +10,9 @@
 #include "../testfrmwk.hpp"
 
 int
-main()
+main()
 {
-
+
   using namespace boost::gregorian;
 
   //various constructors
@@ -31,12 +31,12 @@
   check("month_rep constructor", d4 == d4a);
   //std::cout << d3 << std::endl;
   //retrieval functions
- check("1900-01-01 day is 01", d1.day() == 1);
- check("1900-01-01 month is 01", d1.month() == 1);
- check("1900-01-01 year is 1900", d1.year() == 1900);
- check("2000-12-31 day is 31", d4.day() == 31);
- check("2000-12-31 month is 12", d4.month() == 12);
- check("2000-12-31 year is 2000", d4.year() == 2000);
+ check_equal("1900-01-01 day is 01", d1.day(), 1);
+ check_equal("1900-01-01 month is 01", d1.month(), 1);
+ check_equal("1900-01-01 year is 1900", d1.year(), 1900);
+ check_equal("2000-12-31 day is 31", d4.day(), 31);
+ check_equal("2000-12-31 month is 12", d4.month(), 12);
+ check_equal("2000-12-31 year is 2000", d4.year(), 2000);
   //operator<
   check("1900-01-01 is less than 2000-01-01", d1 < d2);
   check("2000-01-01 is NOT less than 2000-01-01", !(d1 < d1));
@@ -50,17 +50,17 @@
   //operator!=
   check("2000-01-01 is NOT equal to 1900-01-01", d2 != d1);
   //operator==
- check("2000-01-01 is equal 2000-01-01", d3 == d2);
+ check_equal("2000-01-01 is equal 2000-01-01", d3, d2);
   check("2000-01-01 is greater equal 2000-01-01", d3 >= d2);
   check("2000-01-01 is greater equal 2000-01-01", d3 <= d2);
 
   date::ymd_type ymd = d1.year_month_day();
- check("ymd year", ymd.year == 1900);
- check("ymd month", ymd.month == 1);
- check("ymd day", ymd.day == 1);
-
+ check_equal("ymd year", ymd.year, 1900);
+ check_equal("ymd month", ymd.month, 1);
+ check_equal("ymd day", ymd.day, 1);
+
   //The max function will not compile with Borland 5.5
- //Complains about must specialize basic_data<limits> ???
+ //Complains about must specialize basic_data<limits> ???
 // std::cout << "Max date is " << (date::max)() << std::endl;
 // //std::cout << "Max date is " << (basic_date< date_limits<unsigned int,1900> >::max)() << std::endl;
 // //std::cout << "Max date is " << (date_limits<unsigned int, 1900>::max)() << std::endl;
@@ -90,13 +90,13 @@
   date_duration twoDays(2);
   date_duration negtwoDays(-2);
   date_duration zeroDays(0);
- check("2000-03-01 - 2000-02-28 == 2 days", twoDays == (d7-d6));
- check("2000-02-28 - 2000-03-01 == - 2 days", negtwoDays == (d6-d7));
- check("2000-02-28 - 2000-02-28 == 0 days", zeroDays == (d6-d6));
- check("2000-02-28 + 2 days == 2000-03-01 ", d6 + twoDays == d7);
- check("2000-03-01 - 2 days == 2000-02-28 ", d7 - twoDays == d6);
- check("Add duration to date", date(1999,1,1) + date_duration(365) == date(2000,1,1));
- check("Add zero days", date(1999,1,1) + zeroDays == date(1999,1,1));
+ check_equal("2000-03-01 - 2000-02-28 == 2 days", twoDays, (d7-d6));
+ check_equal("2000-02-28 - 2000-03-01 == - 2 days", negtwoDays, (d6-d7));
+ check_equal("2000-02-28 - 2000-02-28 == 0 days", zeroDays, (d6-d6));
+ check_equal("2000-02-28 + 2 days == 2000-03-01 ", d6 + twoDays, d7);
+ check_equal("2000-03-01 - 2 days == 2000-02-28 ", d7 - twoDays, d6);
+ check_equal("Add duration to date", date(1999,1,1) + date_duration(365), date(2000,1,1));
+ check_equal("Add zero days", date(1999,1,1) + zeroDays, date(1999,1,1));
   //can't do this...
   //check("Add date to duration", date_duration(365) + date(1999,1,1) == date(2000,1,1));
 
@@ -117,16 +117,16 @@
   {
     date d(2003,Oct,31);
     date_duration dd1(pos_infin), dd2(neg_infin), dd3(not_a_date_time);
- check("date + inf_dur", d + dd1 == date(pos_infin));
- check("date + inf_dur", d + dd2 == date(neg_infin));
- check("date + nan_dur", d + dd3 == date(not_a_date_time));
- check("date - inf_dur", d - dd1 == date(neg_infin));
- check("date - inf_dur", d - dd2 == date(pos_infin));
- check("date - nan_dur", d - dd3 == date(not_a_date_time));
- check("inf_date + inf_dur", date(pos_infin) + dd1 == date(pos_infin));
- check("inf_date - inf_dur", date(pos_infin) - dd1 == date(not_a_date_time));
- check("inf_date + inf_dur", date(neg_infin) + dd1 == date(not_a_date_time));
- check("inf_date - inf_dur", date(neg_infin) - dd1 == date(neg_infin));
+ check_equal("date + inf_dur", d + dd1, date(pos_infin));
+ check_equal("date + inf_dur", d + dd2, date(neg_infin));
+ check_equal("date + nan_dur", d + dd3, date(not_a_date_time));
+ check_equal("date - inf_dur", d - dd1, date(neg_infin));
+ check_equal("date - inf_dur", d - dd2, date(pos_infin));
+ check_equal("date - nan_dur", d - dd3, date(not_a_date_time));
+ check_equal("inf_date + inf_dur", date(pos_infin) + dd1, date(pos_infin));
+ check_equal("inf_date - inf_dur", date(pos_infin) - dd1, date(not_a_date_time));
+ check_equal("inf_date + inf_dur", date(neg_infin) + dd1, date(not_a_date_time));
+ check_equal("inf_date - inf_dur", date(neg_infin) - dd1, date(neg_infin));
   }
 
 
@@ -213,58 +213,58 @@
   check("check infinity nad compare ", d12 != d11);
   date d13(max_date_time);
   check("check infinity - max compare ", d13 < d11);
- check("max date_time value ", d13 == date(9999,Dec, 31));
+ check_equal("max date_time value ", d13, date(9999,Dec, 31));
   std::cout << to_simple_string(d13) << std::endl;
   date d14(min_date_time);
   check("check infinity - min compare ", d14 > d10);
   std::cout << to_simple_string(d14) << std::endl;
- check("min date_time value ", d14 == date(1400,Jan, 1));
+ check_equal("min date_time value ", d14, date(1400,Jan, 1));
+
 
-
   date d15(1400,1,1);
   std::cout << d15.day_of_week().as_long_string() << std::endl;
   check("check infinity - min compare ", d10 < d15);
 
   // most of this testing is in the gregorian_calendar tests
   std::cout << d15.julian_day() << std::endl;
- check("check julian day ", d15.julian_day() == 2232400);
- check("check modjulian day ", d15.modjulian_day() == -167601);
+ check_equal("check julian day ", d15.julian_day(), 2232400);
+ check_equal("check modjulian day ", d15.modjulian_day(), -167601);
   date d16(2004,2,29);
- check("check julian day ", d16.julian_day() == 2453065);
- check("check modjulian day ", d16.modjulian_day() == 53064);
+ check_equal("check julian day ", d16.julian_day(), 2453065);
+ check_equal("check modjulian day ", d16.modjulian_day(), 53064);
 
   // most of this testing is in the gregorian_calendar tests
   date d31(2000, Jun, 1);
- check("check iso week number ", d31.week_number() == 22);
+ check_equal("check iso week number ", d31.week_number(), 22);
   date d32(2000, Aug, 1);
- check("check iso week number ", d32.week_number() == 31);
+ check_equal("check iso week number ", d32.week_number(), 31);
   date d33(2000, Oct, 1);
- check("check iso week number ", d33.week_number() == 39);
+ check_equal("check iso week number ", d33.week_number(), 39);
   date d34(2000, Dec, 1);
- check("check iso week number ", d34.week_number() == 48);
+ check_equal("check iso week number ", d34.week_number(), 48);
   date d35(2000, Dec, 24);
- check("check iso week number ", d35.week_number() == 51);
+ check_equal("check iso week number ", d35.week_number(), 51);
   date d36(2000, Dec, 25);
- check("check iso week number ", d36.week_number() == 52);
+ check_equal("check iso week number ", d36.week_number(), 52);
   date d37(2000, Dec, 31);
- check("check iso week number ", d37.week_number() == 52);
+ check_equal("check iso week number ", d37.week_number(), 52);
   date d38(2001, Jan, 1);
- check("check iso week number ", d38.week_number() == 1);
+ check_equal("check iso week number ", d38.week_number(), 1);
 
   try {
     int dayofyear1 = d38.day_of_year();
- check("check day of year number", dayofyear1 == 1);
- check("check day of year number", d37.day_of_year() == 366);
+ check_equal("check day of year number", dayofyear1, 1);
+ check_equal("check day of year number", d37.day_of_year(), 366);
     date d39(2001,Dec,31);
- check("check day of year number", d39.day_of_year() == 365);
+ check_equal("check day of year number", d39.day_of_year(), 365);
     date d40(2000,Feb,29);
- check("check day of year number", d40.day_of_year() == 60);
+ check_equal("check day of year number", d40.day_of_year(), 60);
     date d41(1400,Jan,1);
- check("check day of year number", d41.day_of_year() == 1);
+ check_equal("check day of year number", d41.day_of_year(), 1);
     date d42(1400,Jan,1);
- check("check day of year number", d42.day_of_year() == 1);
+ check_equal("check day of year number", d42.day_of_year(), 1);
     date d43(2002,Nov,17);
- check("check day of year number", d43.day_of_year() == 321);
+ check_equal("check day of year number", d43.day_of_year(), 321);
   }
   catch(std::exception& e) {
     std::cout << e.what() << std::endl;
@@ -272,10 +272,10 @@
   }
 
   //converts to date and back -- should get same result
- check("tm conversion functions 2000-1-1", date_from_tm(to_tm(d)) == d);
- check("tm conversion functions 1900-1-1", date_from_tm(to_tm(d1)) == d1);
- check("tm conversion functions min date 1400-1-1 ", date_from_tm(to_tm(d14)) == d14);
- check("tm conversion functions max date 9999-12-31", date_from_tm(to_tm(d13)) == d13);
+ check_equal("tm conversion functions 2000-1-1", date_from_tm(to_tm(d)), d);
+ check_equal("tm conversion functions 1900-1-1", date_from_tm(to_tm(d1)), d1);
+ check_equal("tm conversion functions min date 1400-1-1 ", date_from_tm(to_tm(d14)), d14);
+ check_equal("tm conversion functions max date 9999-12-31", date_from_tm(to_tm(d13)), d13);
 
   try{
     date d(neg_infin);
@@ -286,7 +286,7 @@
   }catch(...){
     check("Caught un-expected exception (special_value to_tm)", false);
   }
-
+
   return printTestStats();
 
 }


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