aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-12-09 23:01:47 +0100
committerKim Alvefur <zash@zash.se>2018-12-09 23:01:47 +0100
commit3d6361261e29f8411f4bec615da1643eae4aa362 (patch)
tree9f543bb3fed58d6e6b3f33c18a2c407a375d8b2b /util
parent010770585cd6899a66fd5373192a94d479e74c86 (diff)
downloadprosody-3d6361261e29f8411f4bec615da1643eae4aa362.tar.gz
prosody-3d6361261e29f8411f4bec615da1643eae4aa362.zip
util.datetime: Make sure timezone difference is calculated correctly (fixes #1262)
If the two os.date() calls happen at either side of a second ticking over there would be a one second error in the calculation.
Diffstat (limited to 'util')
-rw-r--r--util/datetime.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/datetime.lua b/util/datetime.lua
index 06be9fc2..2d27ece4 100644
--- a/util/datetime.lua
+++ b/util/datetime.lua
@@ -38,7 +38,8 @@ local function parse(s)
local year, month, day, hour, min, sec, tzd;
year, month, day, hour, min, sec, tzd = s:match("^(%d%d%d%d)%-?(%d%d)%-?(%d%d)T(%d%d):(%d%d):(%d%d)%.?%d*([Z+%-]?.*)$");
if year then
- local time_offset = os_difftime(os_time(os_date("*t")), os_time(os_date("!*t"))); -- to deal with local timezone
+ local now = os_time();
+ local time_offset = os_difftime(os_time(os_date("*t", now)), os_time(os_date("!*t", now))); -- to deal with local timezone
local tzd_offset = 0;
if tzd ~= "" and tzd ~= "Z" then
local sign, h, m = tzd:match("([+%-])(%d%d):?(%d*)");