Opened 11 years ago
Last modified 8 years ago
#6045 new Bugs
Date/Time: dst_calculator::local_is_dst doesn't deal with DST changeover at end of day
| Reported by: | Owned by: | az_sw_dude | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | date_time |
| Version: | Boost 1.47.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
Hello boosters,
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.
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 GetTimeZoneInformation API returns a TIME_ZONE_INFORMATION struct with values returned a millisecond before midnight. Specifically this happens with Brasilian standard/daylight time.
For now I am "cleaning up" these odd values returned from windows, but boost probably should do this calculation correctly to begin with.
I can provide a repro case if need be, although I think the behaviour of the code in question is pretty clear.
Thanks,
Matt Adam
Change History (2)
comment:1 by , 11 years ago
| Component: | None → date_time |
|---|---|
| Owner: | set to |

DST ended at midnight in Brazil this year on February 22nd. For this timezone,
dst_local_end_time()returns the correct value, but alocal_date_timeconstructed from time_t in that timezone returns true foris_dst()for up to an hour after that point. This is due to the logic indst_calculator::local_is_dst()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.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->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->dst_local_end_time() ); assert( !local_date_time(pt, tz).is_dst() ); //fails pt = from_time_t( 3600 + (time_t)tz->dst_local_end_time() ); assert( !local_date_time(pt, tz).is_dst() ); //dst has ended