From 1136a88362c92be37aee1d3388e7ce541a6ca391 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <ajohnson@redneon.com>
Date: Wed, 24 Feb 2016 21:10:08 +1030
Subject: [PATCH 3/4] pdfinfo: convert dates to local time zone

---
 utils/pdfinfo.cc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc
index 5a9745f..82b73b7 100644
--- a/utils/pdfinfo.cc
+++ b/utils/pdfinfo.cc
@@ -446,6 +446,7 @@ static void printInfoDate(Dict *infoDict, const char *key, const char *text) {
   int year, mon, day, hour, min, sec, tz_hour, tz_minute;
   char tz;
   struct tm tmStruct;
+  time_t time;
   char buf[256];
 
   if (infoDict->lookup(key, &obj)->isString()) {
@@ -463,8 +464,14 @@ static void printInfoDate(Dict *infoDict, const char *key, const char *text) {
       tmStruct.tm_yday = -1;
       tmStruct.tm_isdst = -1;
       // compute the tm_wday and tm_yday fields
-      if (mktime(&tmStruct) != (time_t)-1 &&
-	  strftime(buf, sizeof(buf), "%c", &tmStruct)) {
+      time = timegm(&tmStruct);
+      if (time != (time_t)-1) {
+	int offset = (tz_hour*60 + tz_minute)*60;
+	if (tz == '-')
+	  offset *= -1;
+	time -= offset;
+	localtime_r(&time, &tmStruct);
+	strftime(buf, sizeof(buf), "%c %Z", &tmStruct);
 	fputs(buf, stdout);
       } else {
 	fputs(s, stdout);
-- 
2.1.4