Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Jikat2/datehanding
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--Google Code-in 2017, Create a general date-handling function, made by Om Desai local p = {} p.datehandle = function(frame) local text = frame.args.text or "" local type = frame.args.type or "dmy" local year = "" local day = "" local month = "" local month2 = "" for i in string.gmatch(text, "%w+") do local object, object2 = string.find(i, "%d+") if object then i = string.sub(i, object, object2) end if tonumber(i) then if tonumber(i) < 31 then day = i else year = i end end if string.find("A.D B.C BCE CE",i,1,true) then year = year.." "..i end s = string.sub(i,1,3) local monthcheck = string.find("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",s,1,true) if monthcheck then month = i month2 = (monthcheck + 3)/4 end end local msg = "Invalid Date <br>" if type == "dmy" then msg = day.." "..month.." "..year.."<br>" if year =="" or month=="" or day=="" then msg = "Invalid date <br>" end elseif type == "y" then msg = year.."<br>" if year =="" then msg = "Invalid date <br>" end elseif type == "mdy" then msg = month.." "..day..", "..year.."<br>" if year =="" or month=="" or day =="" then msg = "Invalid date <br>" end elseif type == "iso" then if tonumber(day) < 10 then day = "0"..day end if month2 < 10 then month2 = "0"..month2 end msg = year.."-"..month2.."-"..day.."<br>" if year =="" or month2 =="" or day =="" then msg = "Invalid date <br>" end end return msg end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Jikat2/datehanding/doc
(
edit
)