On Windows, time() is returning a value which if offset by the
selected time-zone. Provide a variant which is always in GMT.
return strncpy (p, string, needed);
}
+
+time_t sgGMTime()
+{
+ struct tm now;
+ time_t now_sec = time(0);
+#if defined(SG_WINDOWS)
+ now = *gmtime(&now_sec);
+#else
+ gmtime_r(&now_sec, &now);
+#endif
+ return mktime(&now);
+}
\ No newline at end of file
/* adapted from <time.h> */
struct tm * fgLocaltime (const time_t *t, const char *tzName);
+/* version of time() which returns a value in GMT/UTC, without
+ any timezone adjustment. Necessary on Windows where calling time()
+ returns a value in the local time-zone. */
+time_t sgGMTime();
+
/* Prototype for the internal function to get information based on TZ. */
extern struct tm *fgtz_convert (const time_t *t, int use_localtime,
struct tm *tp, const char *tzName);