Subject: [Boost-bugs] [Boost C++ Libraries] #10285: local_time is not monotonic
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-01 08:03:44
#10285: local_time is not monotonic
-----------------------------------------+------------------------
Reporter: Gaetano Mendola <mendola@â¦> | Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
-----------------------------------------+------------------------
The following snippet seems to generate non monotonic local_date.
I'm using boost 1.55 on linux.
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
int main() {
const boost::local_time::time_zone_ptr theTimeZone(
new boost::local_time::posix_time_zone(
"CET+01CEST+01,M3.5.0/02:00,M10.5.0/03:00")
);
boost::local_time::local_date_time myOldValue(
boost::local_time::local_microsec_clock::local_time(theTimeZone));
for (size_t i = 0; ; ++i) {
const boost::local_time::local_date_time myLocalTime =
boost::local_time::local_microsec_clock::local_time(theTimeZone);
if (myLocalTime < myOldValue) {
std::cout << myOldValue << std::endl;
std::cout << myLocalTime << std::endl;
std::cout <<
boost::local_time::local_microsec_clock::local_time(theTimeZone) <<
std::endl;
std::cout << "====================" << std::endl;
}
myOldValue = myLocalTime;
}
}
As you can see the program is not supposed to print anything ever,
however this is what I'm getting:
2014-Jul-31 00:24:56.005625 CEST
2014-Jul-31 00:24:55.005631 CEST <== 1 second back
2014-Jul-31 00:24:56.005946 CEST
====================
2014-Jul-31 00:24:58.005625 CEST
2014-Jul-31 00:24:57.005629 CEST <== 1 second back
2014-Jul-31 00:24:58.005824 CEST
====================
2014-Jul-31 00:25:02.005624 CEST
2014-Jul-31 00:25:01.005628 CEST <== 1 second back
2014-Jul-31 00:25:02.005838 CEST
====================
2014-Jul-31 00:25:04.005625 CEST
2014-Jul-31 00:25:03.005630 CEST <== 1 second back
2014-Jul-31 00:25:04.005826 CEST
====================
2014-Jul-31 00:25:06.005624 CEST
2014-Jul-31 00:25:05.005633 CEST <== 1 second back
2014-Jul-31 00:25:06.005853 CEST
====================
2014-Jul-31 00:25:07.005625 CEST
2014-Jul-31 00:25:06.005631 CEST <== 1 second back
2014-Jul-31 00:25:07.005846 CEST
====================
2014-Jul-31 00:25:12.005625 CEST
2014-Jul-31 00:25:11.005631 CEST <== 1 second back
2014-Jul-31 00:25:12.005822 CEST
====================
as you can see when the local_date is near 0.005631 second fraction it
goes back of one second and then forward again on the following call.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10285> 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:16 UTC