-- Implements the {{dni}} template //
localp={}
-- Calculates someone's age and formats the date
functionp.calculateAge(frame)
localargs=frame.args
localday=tonumber(args[1])or1
localmonth=tonumber(args[2])or1
localyear=tonumber(args[3])
ifnotyearthenreturn""end
localnowY=tonumber(frame:callParserFunction('#time','Y','now - 3 hours'))
localnowM=tonumber(frame:callParserFunction('#time','n','now - 3 hours'))
localnowD=tonumber(frame:callParserFunction('#time','d','now - 3 hours'))
localage=nowY-year
ifnowM<monthor(nowM==monthandnowD<day)then
age=age-1
end
localmonths={
"January","February","March","April","May","June",
"July","August","September","October","November","December"
}
localformatted=day.." of "..months[month].." of "..year
ifageandage>=0then
formatted=formatted.."<br>("..age..(age==1and" year)"or" years)")
end
returnformatted
end
returnp