Correctly manipulate tm_gmtoff the way qt_timezone() needs.
Follow-up to 91d3298
: qt_timezone() expects the number of seconds west
of UTC, whereas tm_gmtoff returns the number of seconds east of UTC, and
contrary to the timezone variable it is not oblivious to DST.
We have to account for those two facts and make sure we return a value
compatible with what timezone would have.
Change-Id: Iacb9077f50d4c847ac09e5a7e952d0e4cd22da1b
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b3fcac3e0c
commit
cd681c45de
@ -2208,7 +2208,17 @@ static int qt_timezone()
|
||||
time_t clock = time(NULL);
|
||||
struct tm t;
|
||||
localtime_r(&clock, &t);
|
||||
return t.tm_gmtoff;
|
||||
// QTBUG-36080 Workaround for systems without the POSIX timezone
|
||||
// variable. This solution is not very efficient but fixing it is up to
|
||||
// the libc implementations.
|
||||
//
|
||||
// tm_gmtoff has some important differences compared to the timezone
|
||||
// variable:
|
||||
// - It returns the number of seconds east of UTC, and we want the
|
||||
// number of seconds west of UTC.
|
||||
// - It also takes DST into account, so we need to adjust it to always
|
||||
// get the Standard Time offset.
|
||||
return -t.tm_gmtoff + (t.tm_isdst ? SECS_PER_HOUR : 0L);
|
||||
#else
|
||||
return timezone;
|
||||
#endif // Q_OS_WIN
|
||||
|
Loading…
Reference in New Issue
Block a user