Module:Time/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 25:
]]
 
local function substitute (msg, argsargs_t)
return argsargs_t and mw.message.newRawMessage (msg, argsargs_t):plain() or msg;
end
 
Line 33:
 
create an error message
<args_t> is a sequence where [1] is template name and [2] is substituted error message
 
]]
 
local function error_msg (msg, argargs_t)
return substitute (cfg.err_msg, substitute (cfg.err_text[msg], arg)args_t);
end
 
Line 377:
if not ((DF_cust_a and DF_cust_p) or -- DF_cust_a xor DF_cust_p
(not DF_cust_a and not DF_cust_p))then
return error_msg ({'Time', cfg.err_text['bad_df_pair']}); -- both are required
end
 
Line 392:
local s, t = mw.ustring.match (tz.utc_offset, '(±)(%d%d:%d%d)'); -- ± only valid for offset 00:00
if s and '00:00' ~= t then
return error_msg ({'Time', cfg.err_text['bad_sign']});
end
tz.df = 'iso';
Line 399:
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 ({'Time', substitute (cfg.err_text['unknown_tz'], args[1])}); -- if the timezone given isn't in module:time/data(/sandbox)
end
end
Line 406:
DF = DF:lower(); -- normalize to lower case
if not cfg.df_vals[DF] then
return error_msg ({'Time', substitute (cfg.err_text['bad_format'], DF)});
end
 
Line 412:
local test_time = get_test_time (args._TEST_TIME_);
if not test_time then
return error_msg ({'Time', cfg.err_text['test_time']});
end
 
Line 432:
 
if nil == dst_begin_ts or nil == dst_end_ts then
return error_msg ({'Time', cfg.err_text['bad_dst']});
end
Line 451:
end
elseif is_set (tz.dst_begins) or is_set (tz.dst_ends) or is_set (tz.dst_time) then -- if some but not all not all parts then emit error message
return error_msg ({'Time', substitute (cfg.err_text['bad_def'], argsargs_t[1]:upper())});
else
tz_abbr = tz.abbr; -- dst not observed for this timezone
Line 501:
 
if not is_set (tz.article) then -- if some but not all not all parts then emit error message
return error_msg ({'Time', substitute (cfg.err_text['bad_def'], argsargs_t[1]:upper())});
end
Line 544:
 
if not args_t[1] then -- no timezone specifier
return error_msg ({'UTC offset', cfg.err_text['missing_tz']}); -- abandon with error message
end
 
Line 551:
 
if not data.tz_data[timezone] then -- timezone specifier not known
return error_msg ({'UTC offset', substitute (cfg.err_text['unknown_tz'], {timezone})}); -- abandon with error message
end
 
Line 564:
 
if nil == dst_begin_ts or nil == dst_end_ts then -- if either of these are nil
return error_msg ({'UTC offset', cfg.err_text['bad_dst']}); -- abandon with error message
end
 
Line 582:
 
elseif is_set (tz.dst_begins) or is_set (tz.dst_ends) or is_set (tz.dst_time) then -- if some but not all not all parts then emit error message
return error_msg ({'UTC offset', substitute (cfg.err_text['bad_def'], argsargs_t[1]:upper())});
 
else -- timezone does not use dst
utc_offset = tz.utc_offset; -- return timezone-offset from utc
end