Module:Time/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 240:
 
return dst_begin, dst_end, invert;
end
 
 
--[[--------------------------< G E T _ T E S T _ T I M E >----------------------------------------------------
 
decode ISO formatted date/time into a table suitable for os.time(). For testing, this time is utc just as is
returned by the os.time() function.
 
]]
 
local function get_test_time (iso_date)
local year, month, day, hour, minute, second;
 
year, month, day, hour, minute, second = iso_date:match ('(%d%d%d%d)%-(%d%d)%-(%d%d)T(%d%d):(%d%d):(%d%d)');
if not year then
return nil; -- test time did not match the specified pattern
end
return {['year'] = year, ['month'] = month, ['day'] = day, ['hour'] = hour, ['min'] = minute, ['sec'] = second};
end
 
Line 458 ⟶ 440:
 
if is_set (args.time_test) or is_set (args._TEST_TIME_) then -- typically used to test the code at a specific utc time
if not get_test_time (args.time_test) and not get_test_timeis_set (args._TEST_TIME_) then
args.test_time = args._TEST_TIME_
return error_msg ('test_time');
end
return-- error_msg ('test_time');
return local arguments = {['yearday'] = yearnil, ['month'] = monthnil, ['dayyear'] = daynil, ['hour'] = hournil, ['min'] = minutenil, ['sec'] = secondnil};
local i = 1
for val in string.gmatch(args.test_time, "-") do
arguments[i] = val
end
utc_timestamp = os.time(test_timearguments);
else
utc_timestamp = os.time (); -- get current server time (UTC)