From c6330b64f6930c75c3c12a070a3625b8908f9e4d Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 3 Jan 2014 19:51:58 +0000 Subject: [PATCH] Bugs 1207, 1301 Only apply the fix for time-zone offsetting on Windows, since Unix is handling mktime differently. (Arguably we should also apply a conversion for Unix systems, but the previous logic worked) --- simgear/timing/lowleveltime.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/simgear/timing/lowleveltime.cxx b/simgear/timing/lowleveltime.cxx index 36fd1d35..155b160a 100644 --- a/simgear/timing/lowleveltime.cxx +++ b/simgear/timing/lowleveltime.cxx @@ -1137,12 +1137,21 @@ char *tzstring (const char* string) time_t sgGMTime() { - struct tm now; + // this was created to fix: + // https://code.google.com/p/flightgear-bugs/issues/detail?id=1207 + // however applying the code on Unix causes bug: + // https://code.google.com/p/flightgear-bugs/issues/detail?id=1301 + // One solution would be to deinfe our own 'timegm' as suggested here: + // http://linux.die.net/man/3/timegm + // but for the moment we'll assume time(0) on Unix is UTC, and hence we + // return it directly. + time_t now_sec = time(0); #if defined(SG_WINDOWS) + struct tm now; now = *gmtime(&now_sec); + return mktime(&now); #else - gmtime_r(&now_sec, &now); + return now_sec; #endif - return mktime(&now); -} \ No newline at end of file +} -- 2.39.5