View source for Module:DateInterval
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
local p = {}
local function calculateDate(date, interval, time, timezone)
local currentDate = os.time()
local startDate = os.time{year=date.year, month=date.month, day=date.day, hour=time.hour, min=time.minute, sec=0, isdst=false}
if timezone ~= "" then
local timezoneOffset = os.difftime(os.time(os.date("!*t", startDate)), os.time(os.date("*t", startDate)))
local timezoneCustomOffset = tonumber(timezone:match("([%-%+]%d%d):?%d*")) * 3600 or 0
startDate = startDate + timezoneOffset - timezoneCustomOffset
end
local secondsElapsed = currentDate - startDate
local intervalsElapsed = math.floor(secondsElapsed / (86400 * interval))
local newDateTimestamp = startDate + (intervalsElapsed * 86400 * interval)
local newDate = os.date("*t", newDateTimestamp)
return newDate
end
000
1:0
Template used on this page:
Return to Module:DateInterval.