X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fdatetime.lua;h=a1f62a48563ed48fc2d30c5c1f5e8b94c66e0e17;hb=686b9bc986730e2265700d1fcbb4df5b701565fd;hp=76efc21bffff53431a4bceeb16f5bde8b0e60cc5;hpb=10c4815964c8903f8e2e1f44ec154f6790a5ac29;p=prosody.git diff --git a/util/datetime.lua b/util/datetime.lua index 76efc21b..a1f62a48 100644 --- a/util/datetime.lua +++ b/util/datetime.lua @@ -36,7 +36,7 @@ end function parse(s) if s then 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+%-].*)$"); + 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 tzd_offset = 0; @@ -48,8 +48,8 @@ function parse(s) tzd_offset = h * 60 * 60 + m * 60; if sign == "-" then tzd_offset = -tzd_offset; end end - sec = sec + time_offset + tzd_offset; - return os_time({year=year, month=month, day=day, hour=hour, min=min, sec=sec}); + sec = (sec + time_offset) - tzd_offset; + return os_time({year=year, month=month, day=day, hour=hour, min=min, sec=sec, isdst=false}); end end end