Boost C++ Libraries: Ticket #7840: Failure in posix_time_zone when specifying start date as Jn https://svn.boost.org/trac10/ticket/7840 <p> 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. </p> <p> 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: </p> <blockquote> <p> while(sd &gt;= calendar::end_of_month_day(year,sm)){ </p> <blockquote> <p> sd -= calendar::end_of_month_day(year,sm++); </p> </blockquote> <p> } </p> </blockquote> <p> 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. </p> <p> Conversion of the end date uses an almost identical loop except that its while clause is "strictly less than": </p> <blockquote> <p> while(ed &gt; calendar::end_of_month_day(year,em)){ </p> <blockquote> <p> ed -= calendar::end_of_month_day(year,em++); </p> </blockquote> <p> } </p> </blockquote> <p> So the specifier "CST-2CDT,J1/00,J365/00" leaves ed=31 and em=12 as you would hope. </p> <p> 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. </p> <p> This code is identical in boost 1.52.0. The fix appears to be just to use "strictly less than" in both loops. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7840 Trac 1.4.3 genevivewoo@… Sat, 12 Jan 2013 19:30:09 GMT attachment set https://svn.boost.org/trac10/ticket/7840 https://svn.boost.org/trac10/ticket/7840 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket7840-01112013.patch</span> </li> </ul> Ticket