local function getDateStuff(argsDate)
--[[
Note: This function takes advantage of the formatDate's second argument to
--]]
-- Gets date data.
local dateStuff = {}
local lang = mw.language.getContentLanguage()
dateStuff.argsDate = argsDate ▼
--Year
local year = lang:formatDate('Y', argsDate) ▼
year = tonumber(year)
dateStuff.year = year
-- Month
local month = lang:formatDate('F', argsDate)
dateStuff.month = month
-- Month and year
local monthAndYear = lang:formatDate('F Y', argsDate)
local firstOfMonth = lang:formatDate('01-m-Y', argsDate)
dateStuff.monthAndYear = monthAndYear
▲ dateStuff. argsDate = argsDate ,
-- Previous month and year
dateStuff.previousMonthAndYear year = tonumber(lang:formatDate('F Y', firstOfMonth .. ' -1 month'argsDate)),
▲ local year month = lang:formatDate(' YF', argsDate) ,
-- Next month and year
dateStuff.nextMonthAndYear monthAndYear = lang:formatDate('F Y', firstOfMonth .. ' +1 month'argsDate),
local daysInMonth previousMonthAndYear = lang:formatDate(' jF Y', firstOfMonth .. ' +-1 month -1 day') ,▼
-- Day
local day nextMonthAndYear = lang:formatDate('jF Y', argsDatefirstOfMonth .. ' +1 month'),
day = tonumber(daylang:formatDate('j', argsDate)),
local firstWeekday daysInMonth = tonumber(lang:formatDate(' wj', firstOfMonth ) --.. Sunday' =+1 0,month Saturday-1 = 6day')),▼
dateStuff.day = day
-- DaysWeekday inof the first day of the month
firstWeekday = firstWeekday + 1 -- Make compatible with Lua tables so we add 1. Sunday = 1, Saturday = 7. ▼
▲ local daysInMonth = lang:formatDate('j', firstOfMonth .. ' +1 month -1 day')
firstWeekday = tonumber(lang:formatDate('w', firstOfMonth)) + 1
daysInMonth = tonumber(daysInMonth)
}
dateStuff.daysInMonth = daysInMonth
-- Weekday of the first day of the month
▲ local firstWeekday = lang:formatDate('w', firstOfMonth) -- Sunday = 0, Saturday = 6
firstWeekday = tonumber(firstWeekday)
▲ firstWeekday = firstWeekday + 1 -- Make compatible with Lua tables. Sunday = 1, Saturday = 7.
dateStuff.firstWeekday = firstWeekday
end
|