Subject: [Boost-bugs] [Boost C++ Libraries] #7840: Failure in posix_time_zone when specifying start date as Jn
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-01-02 02:10:13
#7840: Failure in posix_time_zone when specifying start date as Jn
-------------------------------------------+--------------------------------
Reporter: andrew.lang@⦠| Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost 1.50.0 | Severity: Problem
Keywords: |
-------------------------------------------+--------------------------------
If you use the time zone specification "CST-2CDT,J365/00,J1/00" to create
a boost::local_time::posix_time_zone, it fails with an exception.
The problem appears to be in
boost\date_time\local_time\posix_time_zone.hpp, julian_no_leap(...). The
conversion of the start date uses this loop which has a "less than or
equal" clause:
while(sd >= calendar::end_of_month_day(year,sm)){
sd -= calendar::end_of_month_day(year,sm++);
}
sd is the converted start specifier (365 in this case); sm is the current
month (initialized to 1). The loop continues until sd=0 and sm=13, at
which point end_of_month_day() throws an exception.
Conversion of the end date uses an almost identical loop except that its
while clause is "strictly less than":
while(ed > calendar::end_of_month_day(year,em)){
ed -= calendar::end_of_month_day(year,em++);
}
So the specifier "CST-2CDT,J1/00,J365/00" leaves ed=31 and em=12 as you
would hope.
In fact any start specifier at the end of a month (J31, J59,...J334) will
fail later because it will result in sd=0 which is outside the range of
1..31.
This code is identical in boost 1.52.0. The fix appears to be just to use
"strictly less than" in both loops.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7840> 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:11 UTC