function dateOffset(origdate, offset)
local yearMyear, monthMmonth, dayMday = origdate:match ('(%d%d%d%d)-(%d%d)-(%d%d)')
local now = os.time{year = yearMyear, month = monthMmonth, day = dayMday}
local newdate = os.date("%Y-%m-%d", now + (tonumber(offset) * 24 * 3600))
return newdate and newdate or origdate
-- local datesplit = {}
-- datesplit = mw.text.split(origdate, "-")
-- datesplit[1], datesplit[2], datesplit[3] = tonumber(datesplit[1]), tonumber(datesplit[2]), tonumber(datesplit[3])
-- local now = os.time{year = datesplit[1], month = datesplit[2], day = datesplit[3]}
-- local newdate = os.date("%Y-%m-%d", now + (tonumber(offset) * 24 * 3600))
-- return newdate and newdate or origdate
end
|