Bug #148
getSysTime does not return the gmtOffset under linux
0%
Description
according to the man page for getsystemtime, the tz parameter is deprecated and not used, thus the timezone value is always zero.
Files
History
Updated by Andreas Smas over 14 years ago
- Status changed from New to Fixed
- Found in version set to worksforme
It's certainly filled in on my 2.6.31 kernel
Result from getSysTime HTSP method:
time (S64) = 1268777255
timezone (S64) = -60
Updated by Geoffrey McRae - over 14 years ago
- Status changed from Fixed to Need feedback
- Found in version deleted (
worksforme)
See: http://www.kernel.org/doc/man-pages/online/pages/man2/gettimeofday.2.html
"The use of the timezone structure is obsolete; the tz argument should normally be specified as NULL. The tz_dsttime field has never been used under Linux; it has not been and will not be supported by libc or glibc. Each and every occurrence of this field in the kernel source (other than the declaration) is a bug."
Sample Code:
#include <stdio.h> #include <sys/time.h> int main(int argc, char *argv[]) { struct timeval tv; struct timezone tz; memset(&tz, 0xff, sizeof(struct timezone)); printf("%d %d\n", tz.tz_minuteswest, tz.tz_dsttime); }
Outputs:
0 0
Kernel:
xbmc:~# uname -a Linux xbmc 2.6.32-bpo.4-amd64 #1 SMP Thu Apr 8 10:20:24 UTC 2010 x86_64 GNU/Linux
Date output:
xbmc:~# date Wed Apr 28 17:30:52 EST 2010
Updated by Geoffrey McRae - over 14 years ago
Whoops, posted the wrong test code, that ofc wont ever work, here is the correct code
#include <stdio.h> #include <sys/time.h> #include <string.h> int main(int argc, char *argv[]) { struct timeval tv; struct timezone tz; memset(&tz, 0xff, sizeof(struct timezone)); gettimeofday(&tv, &tz); printf("%d %d\n", tz.tz_minuteswest, tz.tz_dsttime); }
Updated by Geoffrey McRae - over 14 years ago
Here is the correct way to get the timezone offset:
#include <time.h> #include <stdio.h> int main(int argc, char *argv[]) { tzset(); printf("%d\n", timezone); }
Returns
-36000
Which for me is 10 hours as I am GMT+10
Updated by Geoffrey McRae - over 14 years ago
Better patch attached, calls tzset in main as it is not re-entrant.
Updated by Andreas Smas about 14 years ago
- Status changed from Need feedback to Fixed
- Found in version set to fixed
Fixed in r5180