require('strict');local get_args = require ('Module:Arguments').getArgs;local lang_object = mw.getContentLanguage;
--diff_days|
local function diff_days (frame) local args_t = get_args (frame); local t1 = args_t[1]; -- t1 is 'start' time local t2 = args_t[2]; -- t2 is 'end' time local precision = tonumber (args_t.precision) or 3; -- number of decimal places to show; default is 3 if 0 > precision then return '
invalid precision: ' .. precision .. ''; endif not t1 or not t2 then return '
both of t1 and t2 required'; endlocal good; local time1, time2; -- to hold Unix time stamps representing the dates
good, time1 = pcall (lang_object.formatDate, lang_object, 'U', t1); -- convert t1 value to unix timestamp if not good then return '
invalid time: ' .. t1 .. ''; endgood, time2 = pcall (lang_object.formatDate, lang_object, 'U', t2); -- convert t2 value to unix timestamp if not good then return '
invalid time: ' .. t2 .. ''; endreturn string.format ('%.'.. precision .. 'f', (time2 - time1)/86400);end
----------------------------< E X P O R T E D F U N C T I O N >--------------------------------------------
return