[Interest] Relashionship between time_t and QDateTime
qtmailinglist1 at bowensite.com
Tue Aug 27 21:58:09 CEST 2013
> One key is in the "Remarks" section of
> SystemTimeToTzSpecificLocalTime()'s documentation
> > The SystemTimeToTzSpecificLocalTime function may calculate the local time incorrectly under the following conditions:
> > - *The time zone uses a different UTC offset for the old and new years*.
> > - The UTC time to be converted and the calculated local time are in different years.
Thanks for that. It looks like for Windows 7 and later, there's now a SystemTimeToTzSpecificLocalTimeEx (and TzSpecificLocalTimeToSystemTimeEx) which use the dynamic time zone structure. It doesn't list the caveats that SystemTimeToTzSpecificLocalTime mentions, so perhaps its historical accuracy is better (for when DST has changed the rules for the timezone in the past).
It is a little more cumbersome to have those functions only in later versions of Windows - you'd need to LoadLibrary/GetProcAddress to be able to call SystemTimeToTzSpecificLocalTimeEx if you detect Windows 7 or later, and use SystemTimeToTzSpecificLocalTime otherwise (if you try to early bind and just call the function in an "if" statement, you'd get "entry point not found" on older operating systems).
More information about the Interest