From d7eb1fc540ae0603ad79f9a3f9ca9faca6aeb713 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 7 Apr 2025 08:20:08 -0400 Subject: [PATCH] One more tweak to the get_date_time function (Issue #115) --- pdfio-value.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pdfio-value.c b/pdfio-value.c index 5f02bc8..28c1eb5 100644 --- a/pdfio-value.c +++ b/pdfio-value.c @@ -870,9 +870,15 @@ get_date_time(const char *s) // I - PDF date/time value return (0); # if defined(HAVE_TM_GMTOFF) + // Adjust the time value using the "tm_gmtoff" and "tm_isdst" members. As + // noted by M-HT on Github, this DST hack will fail in timezones where the + // DST offset is not one hour, such as Australia/Lord_Howe. Fortunately, + // this is unusual and most systems support the "timegm" function... t += dateval.tm_gmtoff - 3600 * dateval.tm_isdst; # else - t += timezone - 3600 * dateval.tm_isdst; + // Adjust the time value using the even more legacy "timezone" variable, + // which also reflects any DST offset... + t += timezone; # endif // HAVE_TM_GMTOFF #endif // _WIN32