Include tzInfo.StandardBias in getCurrentStandardUtcOffset()
It's usually zero, but in principle we should include it (when it's not flagged to be ignored), see https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/ns-timezoneapi-time_zone_information#members https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation for details. Task-number: QTBUG-109974 Change-Id: I8b6e0ea31a1cbd0e88f23ab01854e69258b0056b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
17a59f6613
commit
f5437a9d58
|
|
@ -244,8 +244,14 @@ int getCurrentStandardUtcOffset()
|
|||
{
|
||||
#ifdef Q_OS_WIN
|
||||
TIME_ZONE_INFORMATION tzInfo;
|
||||
GetTimeZoneInformation(&tzInfo);
|
||||
return -tzInfo.Bias * SECS_PER_MIN;
|
||||
if (GetTimeZoneInformation(&tzInfo) != TIME_ZONE_ID_INVALID) {
|
||||
int bias = tzInfo.Bias; // In minutes.
|
||||
// StandardBias is usually zero, but include it if given:
|
||||
if (tzInfo.StandardDate.wMonth) // Zero month means ignore StandardBias.
|
||||
bias += tzInfo.StandardBias;
|
||||
// MS's bias is +ve in the USA, so minutes *behind* UTC - we want seconds *ahead*:
|
||||
return -bias * SECS_PER_MIN;
|
||||
}
|
||||
#else
|
||||
qTzSet();
|
||||
const time_t curr = time(nullptr);
|
||||
|
|
@ -270,9 +276,10 @@ int getCurrentStandardUtcOffset()
|
|||
return curr - qMkTime(&t);
|
||||
}
|
||||
# endif
|
||||
#endif // Platform choice
|
||||
qDebug("Unable to determine current standard time offset from UTC");
|
||||
// We can't tell, presume UTC.
|
||||
return 0;
|
||||
#endif // Platform choice
|
||||
}
|
||||
|
||||
// This is local time's offset (in seconds), at the specified time, including
|
||||
|
|
|
|||
Loading…
Reference in New Issue