Module:Sandbox/Subiloblee

local p = {} -- p stands for package

function p.dmy(frame)
	local n = 0
	local s = frame.args.text
	local txt = ""
	local sec = ""
	local word = 0
	local BA = frame.args.BA or ""
	local form = frame.args.form or "iso"
	if BA~= "" then BA = " " .. BA end
    while n<=#s do
    	n = n + 1
    	if string.match(string.sub(s,n,n),"%d")~=nil or string.match(string.sub(s,n,n),"%a")~=nil then sec = sec .. string.sub(s,n,n) else
    		word = word + 1
    		if tonumber(sec)==nil and tonumber(string.sub(sec,1,#sec-2))==nil then 
    		    if sec=="January" then if not month then month = "1" end txt = txt .. "1 <-Month<br>" end
    		    if sec=="February" then if not month then month = "2" end txt = txt .. "2 <-Month<br>" end
    		    if sec=="March" then if not month then month = "3" end txt = txt .. "3 <-Month<br>" end
    		    if sec=="April" then if not month then month = "4" end txt = txt .. "4 <-Month<br>" end
    		    if sec=="May" then if not month then month = "5" end txt = txt .. "5 <-Month<br>" end
    		    if sec=="June" then if not month then month = "6" end txt = txt .. "6 <-Month<br>" end
    		    if sec=="July" then if not month then month = "7" end txt = txt .. "7 <-Month<br>" end
    		    if sec=="August" then if not month then month = "8" end txt = txt .. "8 <-Month<br>" end
    		    if sec=="September" then if not month then month = "9" end txt = txt .. "9 <-Month<br>" end
    		    if sec=="October" then if not month then month = "10" end txt = txt .. "10 <-Month<br>" end
    		    if sec=="November" then if not month then month = "11" end txt = txt .. "11 <-Month<br>" end
    		    if sec=="December" then if not month then month = "12" end txt = txt .. "12 <-Month<br>" end
    		    if sec~="January" and sec~="February" and sec~="March" and sec~="April" and sec~="May" and sec~="June" and sec~="July" and 
    		    sec~="August" and sec~="September" and sec~="October" and sec~="November" and sec~="December" then txt = txt .. sec .. "<br>" end
    		end
		    if tonumber(sec)~=nil then 
		    	if tonumber(sec)<=31 then if not num then num = sec end txt = txt .. sec .. " <-Number<br>" end
		    	if tonumber(sec)>31 then if not yr then yr = sec end txt = txt .. sec .. " <-Year<br>" end
		    end
		    if tonumber(sec)==nil and tonumber(string.sub(sec,1,#sec-2)) ~= nil and tonumber(string.sub(sec,1,#sec-2))<=31 then 
		        if not num then num = string.sub(sec,1,#sec-2) end 
		        txt = txt .. string.sub(sec,1,#sec-2) .. " <-Number<br>"
		    end
		    if tonumber(sec)==nil and tonumber(string.sub(sec,1,#sec-2)) ~= nil and tonumber(string.sub(sec,1,#sec-2))>31 then 
		    	txt = txt .. sec .. "<br>"
		    end
		    sec = ""
    	end
    end 
    txt = txt .. sec 
    if num == "31" and month == "4" or "6" or "9" or "11" then num = 1 
    	month = month+1 end 
    if month == "2" and num > "29" then num = num - 28 
    	month = month+1 end 
  
    if yr and month and num then 
    	if form == "dmy" then if month == "1" then month = "January" end
    		if month == "2" then month = "February" end
    		if month == "3" then month = "March" end
    		if month == "4" then month = "April" end
    		if month == "5" then month = "May" end
    		if month == "6" then month = "June" end
    		if month == "7" then month = "July" end
    		if month == "8" then month = "August" end
    		if month == "9" then month = "September" end
    		if month == "10" then month = "October" end
    		if month == "11" then month = "November" end
    		if month == "12" then month = "December" end
    		txt = txt .. num .. "-" .. month .. "-" .. yr .. BA .. "<br>" end
    	if form == "mdy" then 
    		if month == "1" then month = "January" end
    		if month == "2" then month = "February" end
    		if month == "3" then month = "March" end
    		if month == "4" then month = "April" end
    		if month == "5" then month = "May" end
    		if month == "6" then month = "June" end
    		if month == "7" then month = "July" end
    		if month == "8" then month = "August" end
    		if month == "9" then month = "September" end
    		if month == "10" then month = "October" end
    		if month == "11" then month = "November" end
    		if month == "12" then month = "December" end
    		txt = txt .. month .. "-" .. num .. "-" .. yr .. BA .. "<br>" end 
    	if form == "y" then txt = txt .. yr .. BA .. "<br>" end
    	if form == "iso" then txt = txt .. yr .. "-" .. month .. "-" .. num .. BA .. "<br>" end
    	if form ~= "dmy" and form ~= "myd" and form ~= "y" and form ~= "iso" then txt = txt .. "incorrect formate<br>" end
    	else txt = txt .. "invalid date<br>" end
    return word .. " word(s)<br>" .. txt .. frame.args.text
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.