Editing
Module:Birth date and age
Jump to navigation
Jump to search
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!
local p = {} local function pad2digit(num) return string.format("%02d", num) end local function getZodiacSign(day, month) local zodiacSigns = { { name = "Capricorn", start = { day = 22, month = 12 }, end_ = { day = 19, month = 1 } }, { name = "Aquarius", start = { day = 20, month = 1 }, end_ = { day = 18, month = 2 } }, { name = "Pisces", start = { day = 19, month = 2 }, end_ = { day = 20, month = 3 } }, { name = "Aries", start = { day = 21, month = 3 }, end_ = { day = 19, month = 4 } }, { name = "Taurus", start = { day = 20, month = 4 }, end_ = { day = 20, month = 5 } }, { name = "Gemini", start = { day = 21, month = 5 }, end_ = { day = 20, month = 6 } }, { name = "Cancer", start = { day = 21, month = 6 }, end_ = { day = 22, month = 7 } }, { name = "Leo", start = { day = 23, month = 7 }, end_ = { day = 22, month = 8 } }, { name = "Virgo", start = { day = 23, month = 8 }, end_ = { day = 22, month = 9 } }, { name = "Libra", start = { day = 23, month = 9 }, end_ = { day = 22, month = 10} }, { name = "Scorpio", start = { day = 23, month = 10 }, end_ = { day = 21, month = 11} }, { name = "Sagittarius", start = { day = 22, month = 11 }, end_ = { day = 21, month = 12} }, } for _, sign in ipairs(zodiacSigns) do if (month == sign.start.month and day >= sign.start.day) or (month == sign.end_.month and day <= sign.end_.day) then return sign.name end end return nil end local function calculateAge(year, month, day) local currentYear = tonumber(os.date('%Y')) local currentMonth = tonumber(os.date('%m')) local currentDay = tonumber(os.date('%d')) local age = currentYear - year if (currentMonth < month) or (currentMonth == month and currentDay < day) then age = age - 1 end return age end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Birth date and age'}) local year = tonumber(args[1] or args.year) local month = tonumber(args[2] or args.month) local day = tonumber(args[3] or args.day) if not day or not month then return '' end local output = "" local categories = {} local function addZodiac(day, month) local zodiacSign = getZodiacSign(day, month) if zodiacSign then local zodiacCategory = (mw.title.getCurrentTitle().namespace == 0) and string.format('[[Category:%s]]', zodiacSign) or '' return string.format( '<br>Astrology: [[File:%s.svg|13px|link=Category:%s|%s|class=noviewer]]%s', zodiacSign, zodiacSign, zodiacSign, zodiacCategory ) end return "" end if year then local monthName = os.date('%B', os.time({year = year, month = month, day = day})) local birthDate = string.format( "[[:Category:%s %s birthdays|%s %s]] [[:Category:%s births|%s]]", monthName, day, day, monthName, year, year ) local age = calculateAge(year, month, day) local ageString = string.format(" (age %d)", age) output = birthDate .. ageString output = output .. addZodiac(day, month) else local ok, monthName = pcall(function() return os.date('%B', os.time({year = 2000, month = month, day = day})) end) if not ok or not monthName then return '' end categories[#categories + 1] = string.format("[[Category:%s %s birthdays]]", monthName, day) categories[#categories + 1] = "[[Category:Birth year needed]]" output = string.format( "[[:Category:%s %s birthdays|%s %s]]", monthName, day, monthName, day ) output = output .. addZodiac(day, month) end return output .. table.concat(categories, "") end return p
Summary:
Please note that all contributions to Porn Base Central 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
Porn Base Central:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Birth date and age/doc
(
view source
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Tools
What links here
Related changes
Upload file
Page information
In other projects