Module:Time/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 2:
local yesno = require('Module:Yesno')
local getArgs = require ('Module:Arguments').getArgs
local data = mw.loadData ('Module:Time/data' .. (mw.getCurrentFrame():getTitle():match ('/sandbox') or '')); -- load the data module
local cfg = {}data.cfg; -- for internationalization
 
local tz = {}; -- holds local copy of the specified timezone table from tz_data{}
local cfg = {}; -- for internationalization
 
 
Line 353 ⟶ 354:
local is_dst_tz;
 
local data = table.concat ({'Module:Time/data', frame:getTitle():find('sandbox', 1, true) and '/sandbox' or ''}); -- 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 = data.tz_aliases; -- get the aliases table
local tz_data = data.tz_data; -- get the tz data table
Line 528 ⟶ 526:
Mimics templates {{Time/GMT offset}}, {{Time/EST offset}}, etc.
 
{{#invoke:Time/sandbox|tz_offset|<tz>}} – for a stand-alone invoke
{{#invoke:Time/sandbox|tz_offset}} – for an invoke in a template (<tz> is first positional parameter in the template call)
 
where <tz> is a timezone abbreviation known to Module:Time/data
 
returns a UTC offset string suitable for use with the {{#time:}} parser function
 
]]
Line 539 ⟶ 540:
return string.format ('%s:%s', tonumber (hours) + 1, minutes); -- return optional sign hh:mm string
end
 
local data = mw.loadData ('Module:Time/data/sandbox'); -- load the data module
cfg = data.cfg; -- get the configuration table
 
local args_t = getArgs (frame); -- fetch arguments; only {{{1}}}, timesone specifier is used
Line 550 ⟶ 548:
 
local timezone = args_t[1]:lower(); -- lowercase for indexing into tz data tables
timezone = data.tz_aliases[timezone] or timezone; -- if <timezone> is an alias, map to its canonical value
 
if not data.tz_data[timezone] then -- timezone specifier not known
Line 555 ⟶ 554:
end
 
-- tz = data.tz_data[timezone]; -- fetch a copy of this timezone's data; <tz> is a page-global table used by functions called from this function
tz = data.tz_aliases[timezone] and data.tz_data[data.tz_aliases[timezone]] or data.tz_data[timezone]; -- fetch a copy of this timezone's data; <tz> is a page-global table used by functions called from this function
local utc_timestamp = os.time (); -- get current server time (UTC) in seconds; used to determine when dst adjustment should be applied
Line 597 ⟶ 595:
if 0 ~= tonumber (minutes) then
return string.format ('%s%s %s %s%s minutes', sign, tonumber(hours), ('1' == hours) and 'hour' or 'hours', sign, tonumber(minutes));
else
return string.format ('%s%s %s', sign, tonumber(hours), ('1' == hours) and 'hour' or 'hours');
end
return retval .. ' + hours'
end