Fixes UTC notification time (now using server TZ)

Fixes #4250
This commit is contained in:
Simone Mainardi 2020-07-31 16:16:19 +02:00
parent b15379d5be
commit 172e632395
2 changed files with 24 additions and 23 deletions

View file

@ -2767,26 +2767,6 @@ end
-- ####################################################
-- @brief Get the frontend timezone offset in seconds
-- @return The offset of the frontend timezone
function getFrontendTzSeconds()
local frontend_tz_offset = nil
if _COOKIE and _COOKIE.tzoffset then
-- The timezone offset can be passed from the client as a cookie.
-- This allows to format the dates in the frontend timezone.
frontend_tz_offset = tonumber(_COOKIE.tzoffset)
end
if frontend_tz_offset == nil then
return 0
end
return frontend_tz_offset
end
-- ####################################################
-- @brief The difference, in seconds, between the local time of this instance and GMT
local server_timezone_diff_seconds
@ -2799,7 +2779,7 @@ local function get_server_timezone_diff_seconds()
local d2 = os.date("!*t", tmp_time)
-- Forcefully set isdst to false otherwise difference won't work during DST
d1.isdst = false
-- Use a minus to have the difference between loca ltime and GMT, rather than between GMT and loca ltime
-- Use a minus to have the difference between local time and GMT, rather than between GMT and loca ltime
server_timezone_diff_seconds = -os.difftime(os.time(d1), os.time(d2))
end
@ -2808,6 +2788,28 @@ end
-- ####################################################
-- @brief Get the frontend timezone offset in seconds
-- @return The offset of the frontend timezone
function getFrontendTzSeconds()
local frontend_tz_offset = nil
if _COOKIE and _COOKIE.tzoffset then
-- The timezone offset can be passed from the client as a cookie.
-- This allows to format the dates in the frontend timezone.
frontend_tz_offset = tonumber(_COOKIE.tzoffset)
end
if frontend_tz_offset == nil then
-- If timezone is not available in the client _COOKIE,
-- server timezone is used as fallback
return -get_server_timezone_diff_seconds()
end
return frontend_tz_offset
end
-- ####################################################
-- @brief Converts a datetime string into an epoch, adjusted with the client time
function makeTimeStamp(d)
local pattern = "(%d+)%/(%d+)%/(%d+) (%d+):(%d+):(%d+)"