Module:Navbox timeline: Difference between revisions

Attempting to introduce months again
Replaced month text with numbers
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:


-- Get month abbreviation
-- Get month abbreviation
local function getMonthAbbr(month)
local function getMonthNum(month)
local months = {'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
return tostring(month)
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'}
return months[month] or ''
end
end


-- Parse date string (supports YYYY, YYYY-MM, or YYYY-YYYY formats)
-- Parse date string (supports YYYY, YYYY-MM, or YYYY-YYYY formats)
Line 266: Line 265:
:cssText(args.monthstyle)
:cssText(args.monthstyle)
:cssText('width:' .. monthWidth .. '%')
:cssText('width:' .. monthWidth .. '%')
:wikitext(getMonthAbbr(monthNum))
:wikitext(getMonthNum(monthNum))
yearStart = yearStart + 1
yearStart = yearStart + 1
Line 354: Line 353:
targs.templatestyles = 'Module:Navbox timeline/styles.css'
targs.templatestyles = 'Module:Navbox timeline/styles.css'
targs.list1 = tostring(wrapper)
targs.list1 = tostring(wrapper)
targs.bodyclass = (targs.bodyclass or '') .. ' timeline-container' -- Add this line
return navbox(targs)
return navbox(targs)