Module:DateDiff: Difference between revisions
Jump to navigation
Jump to search
(username removed) (Created page with "local p={} function p.DateDiff(frame) args=frame:getParent().args fromdate = os.time{year=args[1],month=args[2],day=args[3],hour=16} -- 7:00 AM UTC+9 if args[4] ~= nil then todate = os.time() else todate = os.time{year=args[4],month=args[5],day=args[6],hour=16} -- 7:00 AM UTC+9 end diff = math.floor(os.difftime(todate,fromdate) / 86400) return diff end return p") |
m (Protected "Module:DateDiff": structural page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p={} | local p={} | ||
function | local function _DateDiff(y1,m1,d1,y2,m2,d2) | ||
fromdate = os.time{year=y1,month=m1,day=d1,hour=16} -- 7:00 AM UTC+9 | |||
fromdate = os.time{year= | if y2 ~= nil then | ||
if | todate = os.time{year=y2,month=m2,day=d2,hour=16} -- 7:00 AM UTC+9 | ||
else | |||
todate = os.time() | todate = os.time() | ||
end | end | ||
diff = math.floor(os.difftime(todate,fromdate) / 86400) | diff = math.floor(os.difftime(todate,fromdate) / 86400) | ||
return diff | return diff | ||
end | |||
function p.DateDiff(frame) | |||
args=frame:getParent().args | |||
return _DateDiff(args[1],args[2],args[3],args[4],args[5],args[6]) | |||
end | end | ||
return p | return p |
Latest revision as of 00:06, 24 June 2023
Documentation for this module may be created at Module:DateDiff/doc
local p={}
local function _DateDiff(y1,m1,d1,y2,m2,d2)
fromdate = os.time{year=y1,month=m1,day=d1,hour=16} -- 7:00 AM UTC+9
if y2 ~= nil then
todate = os.time{year=y2,month=m2,day=d2,hour=16} -- 7:00 AM UTC+9
else
todate = os.time()
end
diff = math.floor(os.difftime(todate,fromdate) / 86400)
return diff
end
function p.DateDiff(frame)
args=frame:getParent().args
return _DateDiff(args[1],args[2],args[3],args[4],args[5],args[6])
end
return p