Module:Time/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 354:
end
end
 
--[[--------------------------< D S T _ A C T I V E >----------------------------------------------------------
 
Invokeable version of above
 
]]
 
local function dst_active (frame) -- call from #invoke
local args = getArgs (frame);
local utc_timestamp, timestamp; -- current or time timestamps; timestamp is local ST or DST time used in output
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 tz_aliases = {}
forargs[1] k,v= inargs[1] pairs(aliases_table)or do'utc' -- add dst offsets -- default to tz_aliasesutc
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
Line 370 ⟶ 373:
end
tz = data[tz_aliases[args[1]]];
for k,v in pairs(aliases_table) do -- add dst offsets to tz_aliases
tz = data[dst_tz[args[1]]];
tz_aliases[k] = v
tz = data[tz_data[args[1]]];
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
Line 384 ⟶ 381:
end
 
timestamplocal os_time = os.time ()
local timestamp = os_time + get_utc_offset (); -- make local time timestamp
return is_dst_active(timestamp,utc_timestamp os_time) -- set is_dst to 0 or 1
end
 
Line 558 ⟶ 556:
]]
 
return {
time = time,
dst_active = dst_active,
}