You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extremely rarely, a call to local_microsec_clock::local_time(time_zone_ptr) will return a result about 1 second in the past.
On my local machine, running the following code:
#include<boost/date_time/local_time/local_time.hpp>
#include<iostream>intmain() {
boost::local_time::time_zone_ptr zone(newboost::local_time::posix_time_zone("EST-5"));
for (int i = 0; i < 100'000'000; ++i)
{
boost::local_time::local_date_time t0 = boost::local_time::local_microsec_clock::local_time(zone);
boost::local_time::local_date_time t1 = boost::local_time::local_microsec_clock::local_time(zone);
if (t1 < t0)
{
std::cout << i << ": time went from " << t0 << " to " << t1 << '\n';
}
}
return0;
}
produces ~10-15 incorrect results for 100M calls, or one incorrect result per ~7-10M calls.
The output suggests that this always occurs when the second ticks. The fractional part rolls over, but the seconds do not change.
81899680: time went from 2023-Aug-21 09:17:12.999739 EST to 2023-Aug-21 09:17:12.000740 EST
91444271: time went from 2023-Aug-21 09:17:27.999755 EST to 2023-Aug-21 09:17:27.000752 EST
92719444: time went from 2023-Aug-21 09:17:29.999467 EST to 2023-Aug-21 09:17:29.000465 EST
It looks like the issue is caused by the second ticking between the calls to second_clock::universal_time() and second_clock::local_time(), which causes utc_offset to be off by 1 second.
Extremely rarely, a call to
local_microsec_clock::local_time(time_zone_ptr)
will return a result about 1 second in the past.On my local machine, running the following code:
produces ~10-15 incorrect results for 100M calls, or one incorrect result per ~7-10M calls.
The output suggests that this always occurs when the second ticks. The fractional part rolls over, but the seconds do not change.
It looks like the issue is caused by the second ticking between the calls to
second_clock::universal_time()
andsecond_clock::local_time()
, which causesutc_offset
to be off by 1 second.date_time/include/boost/date_time/microsec_time_clock.hpp
Lines 59 to 66 in 3971490
I intend to submit a PR with a solution soon.
The text was updated successfully, but these errors were encountered: