From 6139f05eb299194d7d7b5fd6ca1f1fc3a41d5d73 Mon Sep 17 00:00:00 2001 From: Jakub Kucharski Date: Tue, 16 Feb 2016 12:17:09 +0100 Subject: [PATCH] cpp: return UTC dates --- cpp/poppler-private.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp index 3c3fe95..1a5657d 100644 --- a/cpp/poppler-private.cpp +++ b/cpp/poppler-private.cpp @@ -116,6 +116,33 @@ GooString* detail::ustring_to_unicode_GooString(const ustring &str) return goo; } +static time_t +utc_mktime (struct tm *tm) +{ + time_t ret; + + char *tz = getenv("TZ"); + if (tz) { + tz = strdup(tz); + } + + setenv("TZ", "", 1); + tzset(); + + ret = mktime(tm); + + if (tz) { + setenv("TZ", tz, 1); + free(tz); + } else { + unsetenv("TZ"); + } + + tzset(); + + return ret; +} + time_type detail::convert_date(const char *date) { int year, mon, day, hour, min, sec, tzHours, tzMins; @@ -136,5 +163,5 @@ time_type detail::convert_date(const char *date) time.tm_wday = -1; time.tm_yday = -1; time.tm_isdst = -1; - return mktime(&time); + return utc_mktime(&time); } -- 2.7.1