Difference between revisions of "Module:Birthday"

From Story Lists
Jump to navigation Jump to search
Line 5: Line 5:
local titleText = titleObject.fullText
local titleText = titleObject.fullText


-- "date" variable is a value like "December 9", taken from the page title
local date = mw.ustring.gsub(titleText, "List of characters born on ", "")  
local date = mw.ustring.gsub(titleText, "List of characters born on ", "")  


local month = ""
local month = ""
local day = ""


if(mw.ustring.find(date, "January")) then
if(mw.ustring.find(date, "January")) then
month = 1
month = 1
day = mw.ustring.gsub(date, "January ")
elseif(mw.ustring.find(date, "February")) then
elseif(mw.ustring.find(date, "February")) then
month = 2
month = 2
Line 25: Line 28:
elseif(mw.ustring.find(date, "August")) then
elseif(mw.ustring.find(date, "August")) then
month = 8
month = 8
day = mw.ustring.gsub(date, "August ")
elseif(mw.ustring.find(date, "September")) then
elseif(mw.ustring.find(date, "September")) then
month = 9
month = 9
Line 35: Line 39:
end
end


local result = "This is a list of characters born on " .. date .. " --- test: " .. mw.ustring.find(date, "August") .. "test test" .. month ..  "."
local result = "This is a list of characters born on " .. date .. " --- test: " .. mw.ustring.find(date, "August") .. "test test" .. day ..  "."


local result  = result .. "[[Category:Lists]]"
local result  = result .. "[[Category:Lists]]"

Revision as of 13:28, 9 May 2021

Documentation for this module may be created at Module:Birthday/doc

local p = {}

function p.main(frame)
	local titleObject = mw.title.getCurrentTitle()
	local titleText = titleObject.fullText

	-- "date" variable is a value like "December 9", taken from the page title
	local date = mw.ustring.gsub(titleText, "List of characters born on ", "") 

	local month = ""
	local day = ""

	if(mw.ustring.find(date, "January")) then
		month = 1
		day = mw.ustring.gsub(date, "January ") 
	elseif(mw.ustring.find(date, "February")) then
		month = 2
	elseif(mw.ustring.find(date, "March")) then
		month = 3
	elseif(mw.ustring.find(date, "April")) then
		month = 4
	elseif(mw.ustring.find(date, "May")) then
		month = 5
	elseif(mw.ustring.find(date, "June")) then
		month = 6
	elseif(mw.ustring.find(date, "July")) then
		month = 7
	elseif(mw.ustring.find(date, "August")) then
		month = 8
		day = mw.ustring.gsub(date, "August ") 
	elseif(mw.ustring.find(date, "September")) then
		month = 9
	elseif(mw.ustring.find(date, "October")) then
		month = 10
	elseif(mw.ustring.find(date, "November")) then
		month = 11
	elseif(mw.ustring.find(date, "December")) then
		month = 12
	end

	local result = "This is a list of characters born on " .. date .. " --- test: " .. mw.ustring.find(date, "August") .. "test test" .. day ..  "."

	local result  = result .. "[[Category:Lists]]"
	local result  = result .. "[[Category:Lists of characters by birthday]]"

	return result
end

return p