Content deleted Content added
BrandonXLF (talk | contribs) Undid revision 863172694 by BrandonXLF (talk) |
BrandonXLF (talk | contribs) No edit summary |
||
Line 355:
end
local function dst_active (frame)
local args = getArgs (frame);
local utc_timestamp, timestamp; -- current or time timestamps; timestamp is local ST or DST time used in output
return is_dst_active (timestamp,utc_timestamp)▼
local tz_abbr; -- select ST or DST timezone abbreviaion used in output
local time_string; -- holds output time/date in |df= format
local utc_offset; -- true when southern hemisphere
local is_dst; -- wether or not dst is active
local data = 'Module:Time/data'..set_sandbox(frame) -- make a data module name; sandbox or live
data = mw.loadData (data); -- load the data module
cfg = data.cfg; -- get the configuration table
local formats = data.formats;
local tz_aliases = {}
local aliases_table = data.tz_aliases; -- get the aliases table
local dst_table = data.dst_tz;
local tz_data = data.tz_data; -- get the tz data table
for k,v in pairs(dst_table) do -- add dst offsets to tz_aliases
tz_aliases[k] = v
end
for k,v in pairs(aliases_table) do -- add dst offsets to tz_aliases
tz_aliases[k] = v
end
if not args[1] then
args[1] = 'utc'; -- default to utc
end
tz = tz_aliases[args[1]] and tz_data[tz_aliases[args[1]]] or tz_data[args[1]]; -- make a local copy of the timezone table from tz_data{}
if not tz then
return error_msg ('unknown_tz', args[1]); -- if the timezone given isn't in module:time/data(/sandbox)
end
utc_timestamp = os.time (); -- get current server time (UTC)
utc_offset = get_utc_offset (); -- utc offset for specified timezone in seconds
timestamp = utc_timestamp + utc_offset; -- make local time timestamp
end
|