{
ASN1_TIME *timestamp_asn1 = NULL;
struct tm *timestamp_tm = NULL;
-#ifndef USE_TIMEGM
+#if defined(__DJGPP__)
+ char *tz = NULL;
+#elif !defined(USE_TIMEGM)
time_t timestamp_local;
#endif
time_t timestamp_utc;
ASN1_TIME_free(timestamp_asn1);
return -1;
}
+ ASN1_TIME_free(timestamp_asn1);
+
+#if defined(__DJGPP__)
+ /*
+ * This is NOT thread-safe. Do not use this method for platforms other
+ * than djgpp.
+ */
+ tz = getenv("TZ");
+ if (tz != NULL) {
+ tz = OPENSSL_strdup(tz);
+ if (tz == NULL) {
+ OPENSSL_free(timestamp_tm);
+ return -1;
+ }
+ }
+ setenv("TZ", "UTC", 1);
+
+ timestamp_utc = mktime(timestamp_tm);
-#ifdef USE_TIMEGM
+ if (tz != NULL) {
+ setenv("TZ", tz, 1);
+ OPENSSL_free(tz);
+ } else {
+ unsetenv("TZ");
+ }
+#elif defined(USE_TIMEGM)
timestamp_utc = timegm(timestamp_tm);
- OPENSSL_free(timestamp_tm);
#else
timestamp_local = mktime(timestamp_tm);
- OPENSSL_free(timestamp_tm);
-
timestamp_utc = timestamp_local - timezone;
#endif
+ OPENSSL_free(timestamp_tm);
- ASN1_TIME_free(timestamp_asn1);
return timestamp_utc;
}