Boost C++ Libraries: Ticket #6045: Date/Time: dst_calculator::local_is_dst doesn't deal with DST changeover at end of day https://svn.boost.org/trac10/ticket/6045 <p> Hello boosters, </p> <p> dst_calculator::local_is_dst assumes that the hour lost in the "forward" DST changeover (in Spring, when DST begins) fully occurs within a single day. If your time zone rule specifies that DST begins at 23:59:99.999 on October 15th, with a duration of an hour, and you attempt to create a ptime for 00:00:00.000 on October 16th, it will succeed even though it ought to return invalid_time_label. </p> <p> I admit that this seems like an odd case, and personally I would expect all DST offsets to be in the 0h-3h range. However if you are creating custom time zones based on the win32 time zone information, the <a class="missing wiki">GetTimeZoneInformation</a> API returns a TIME_ZONE_INFORMATION struct with values returned a millisecond before midnight. Specifically this happens with Brasilian standard/daylight time. </p> <p> For now I am "cleaning up" these odd values returned from windows, but boost probably should do this calculation correctly to begin with. </p> <p> I can provide a repro case if need be, although I think the behaviour of the code in question is pretty clear. </p> <p> Thanks, </p> <p> Matt Adam </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6045 Trac 1.4.3 anonymous Tue, 08 Nov 2011 16:03:58 GMT component changed; owner set https://svn.boost.org/trac10/ticket/6045#comment:1 https://svn.boost.org/trac10/ticket/6045#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">az_sw_dude</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">date_time</span> </li> </ul> Ticket jpettiss@… Tue, 03 Mar 2015 15:07:36 GMT <link>https://svn.boost.org/trac10/ticket/6045#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6045#comment:2</guid> <description> <p> DST ended at midnight in Brazil this year on February 22nd. For this timezone, <code>dst_local_end_time()</code> returns the correct value, but a <code>local_date_time</code> constructed from time_t in that timezone returns true for <code>is_dst()</code> for up to an hour after that point. This is due to the logic in <code>dst_calculator::local_is_dst()</code> assuming that if the date is different, then no time distance calculations have to be performed. In this timezone, 2015/02/21 23:30:00 labels two different points, one which happens before the DST change, one which happens after. </p> <pre class="wiki"> time_zone_ptr tz(new posix_time_zone("BRT3BRST,M10.3.0/0,M2.5.0/0")); //America/Sao_Paulo ptime pt = from_time_t( -1 + (time_t)tz-&gt;dst_local_end_time() ); assert( local_date_time(pt, tz).is_dst() ); //dst has not ended yet pt = from_time_t( 1 + (time_t)tz-&gt;dst_local_end_time() ); assert( !local_date_time(pt, tz).is_dst() ); //fails pt = from_time_t( 3600 + (time_t)tz-&gt;dst_local_end_time() ); assert( !local_date_time(pt, tz).is_dst() ); //dst has ended </pre> </description> <category>Ticket</category> </item> </channel> </rss>