From d27e19a25112978af17e1b9953c2bfe0a6bda2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Kr=C3=BCger?= Date: Sun, 12 Jul 2020 16:48:25 +0200 Subject: [PATCH] Deal with Windows strftime timezone issues --- luametalatex-back-pdf.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/luametalatex-back-pdf.lua b/luametalatex-back-pdf.lua index 11f661a..2d6c7aa 100644 --- a/luametalatex-back-pdf.lua +++ b/luametalatex-back-pdf.lua @@ -94,7 +94,36 @@ local infodir = "" local namesdir = "" local catalogdir = "" local catalog_openaction -local creationdate = os.date("D:%Y%m%d%H%M%S%z"):gsub("+0000$", "Z"):gsub("%d%d$", "'%0") +local creationdate = os.date("D:%Y%m%d%H%M%S") +do + local time0 = os.time() + local tz = os.date('%z', time0) + if tz:match'^[+-]%d%d%d%d$' then + if tz:sub(1) == '0000' then + tz = 'Z' + else + tz = tz:sub(1,3) .. "'" .. tz:sub(4) + end + else + local utc_time = os.date('!*t') + utc_time.isdst = nil + local time1 = os.time(utc_time) + local offset = time1-time0 + if offset == 0 then + tz = 'Z' + else + if offset > 0 then + tz = '-' + else + tz = '+' + offset = -offset + end + offset = offset // 60 + tz = string.format("%s%02i'%02i", tz, offset//60, offset%60) + end + end + creationdate = creationdate .. tz +end local function write_infodir(p) local additional = "" if not string.find(infodir, "/CreationDate", 1, false) then