[Interest] Relashionship between time_t and QDateTime

Daniel Bowen qtmailinglist1 at bowensite.com
Tue Aug 27 22:32:44 CEST 2013


One other note:

> And since daylight saving transition dates and time tend to slightly drift
from 
> year to year, there's absolutely no guarantees of getting correct time 
> conversion results; in general case 1-hour error is nearly inevitable.

The timezone structure on Windows tracks the ST->DT and DT->ST rules for the
transition, not an absolute date - like 02:00 on the first Sunday in April
(http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).a
spx).  So, if the rules haven't changed, but the absolute dates have from
one year to the next, I think you'll still get the right answer if you use
SystemTimeToTzSpecificLocalTime.  But, when the rules change, like they did
in the US in 2007 (http://aa.usno.navy.mil/faq/docs/daylight_time.php),
that's when it would be wrong to calculate the local time using the current
year's rules for some range of dates, and you'd need
SystemTimeToTzSpecificLocalTimeEx.

So, to test, you could use a UTC FILETIME for a date/time on March 31, 2006,
have your system set to one of the timezones in the US that follows daylight
savings, then try to convert that to local time.  If it's following the
current rules, the conversion will be an hour too early.  If it's
historically accurate, it will be correct.

-Daniel




More information about the Interest mailing list