--Infobox biography 1. Sets default colors and styles 2. Finds any input fields for death and birth dates and formats the date according to Swedish standard and calculates and displays age or age at deathlocal p = ;
-- Default style -------------local default_bodystyle='border-spacing:3px;width:22em;border:1px solid #AAAAAA; border-top:0px;'local default_titlestyle='border:1px solid #AAAAAA; border-bottom:0px;background:#ccd9e8;padding-top:5px;padding-bottom:5px;'local default_labelstyle= local default_headerstyle='background:#BFD2EB;'local default_belowstyle='background:#BFD2EB;'------------------------------
local Infobox = require('Module:Infobox')local DateHelper = require('Module:Sandbox/AlphaZeta/test3')
function p.infobox(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame
-- Check all data fields to find and format -- Birthdate (marked with @birth@) -- Death date (marked with @death@) -- Other dates (marked with @date@) local birthDateField local deathDateField local birth_date= local death_date= for name, value in pairs(inputargs) do if (name:sub(1,4)
'@birth@' then birthDateField=name birth_date=value:sub(8) inputargs[name]=DateHelper.format(birth_date,'link',true) elseif value:sub(1,7)
'@date@' then inputargs[name]=DateHelper.format(value:sub(7),,true) elseif value:sub(1,10)
-- calcuate age, either alive or dead local ageAlive= local ageDeath= if birth_date~=nil and birth_date~= then if death_date
then ageAlive=DateHelper.yearsBetween(birth_date) if ageAlive~= then ageAlive=' ('..ageAlive..')' end else ageDeath=DateHelper.yearsBetween(birth_date,death_date) if ageDeath~= then ageDeath=' ('..ageDeath..')' end end end -- add age to date fields if birthDateField~=nil then inputargs[birthDateField]=inputargs[birthDateField]..ageAlive end if deathDateField~=nil then inputargs[deathDateField]=inputargs[deathDateField]..ageDeath end return Infobox.infobox(inputargs)end return p