mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
parent
b15379d5be
commit
172e632395
2 changed files with 24 additions and 23 deletions
|
|
@ -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+)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue