[Boost-bugs] [Boost C++ Libraries] #4058: total_seconds calculation error

Subject: [Boost-bugs] [Boost C++ Libraries] #4058: total_seconds calculation error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-04-02 10:30:36


#4058: total_seconds calculation error
--------------------------------+-------------------------------------------
 Reporter: knizovoy@… | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: date_time
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
 Method total_seconds() returns negative value for period between
 2010-Jan-1 and 1941-Jan-1.

 Issue reproduces with following code:[[BR]]
 #include <boost/date_time.hpp>[[BR]]
 #include <iostream>[[BR]]

 int main(int argc, char* argv[])[[BR]]
 {[[BR]]
         using namespace std;
         using namespace boost;
         using namespace boost::posix_time;
         using namespace boost::gregorian;

         ptime pt2010(date(2010, Jan, 1));[[BR]]
         ptime pt1942(date(1942, Jan, 1));[[BR]]
         ptime pt1941(date(1941, Jan, 1));[[BR]]

         cout << "seconds since " << to_simple_string(pt1942) << " == " <<
 (pt2010 - pt1942).total_seconds() << endl;[[BR]]
         cout << "seconds since " << to_simple_string(pt1941) << " == " <<
 (pt2010 - pt1941).total_seconds() << endl;[[BR]]

         return 0;[[BR]]
 }[[BR]]

 Output is:[[BR]]
 seconds since 1942-Jan-01 00:00:00 == 2145916800[[BR]]
 seconds since 1941-Jan-01 00:00:00 == '''-2117514496'''[[BR]]

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4058>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC