Content deleted Content added
BrandonXLF (talk | contribs) No edit summary |
BrandonXLF (talk | contribs) No edit summary |
||
Line 343:
local function _dst_active (frame)
local dst_begin_ts, dst_end_ts; -- DST begin and end timestamps in UTC▼
if is_set (tz.dst_begins) and is_set (tz.dst_ends) and is_set (tz.dst_time) then -- make sure we have all of the parts
dst_begin_ts, dst_end_ts, invert = make_dst_timestamps (timestamp); -- get begin and end dst timestamps and invert flag
if nil == dst_begin_ts or nil == dst_end_ts then
Line 350 ⟶ 353:
end
if invert then -- southern hemisphere; use beginning and ending of standard time in the comparison
if utc_timestamp >= dst_end_ts and utc_timestamp < dst_begin_ts then -- is current date time standard time?
return 0
else
end
else -- northern hemisphere
if utc_timestamp >= dst_begin_ts and utc_timestamp < dst_end_ts then -- all timestamps are UTC
return 1
else
Line 368 ⟶ 369:
return error_msg ('bad_def', args[1]:upper());
else
return 0 -- dst not observed for this timezone
end
end
local function dst_active (frame) -- call from #invoke
local args = getArgs (frame);
return _dst_active (args)
Line 400:
local args = getArgs (frame);
local utc_timestamp, timestamp; -- current or _TEST_TIME_ timestamps; timestamp is local ST or DST time used in output
▲ local dst_begin_ts, dst_end_ts; -- DST begin and end timestamps in UTC
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 invert; -- true when southern hemisphere
local DF; -- date format flag; the |df= parameter
local is_dst = tonumber(dst_active(frame))
local data = 'Module:Time/data'..set_sandbox(frame) -- make a data module name; sandbox or live▼
▲ 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
Line 481 ⟶ 478:
if is_dst ~= 0 and is_dst ~= 1 then
return is_dst
elseif is_dst ==
tz_abbr = tz.dst_abbr;
else
|