Content deleted Content added
No edit summary |
cleanup my messes; |
||
Line 20:
dayabbr[i] = v:sub(1, 2)
end
local monthname = {}
Line 37 ⟶ 29:
end
end
local function isleap(year)
return '1' == lang_obj:formatDate ('L', tostring(year));
end
--[[
returns 1 to 7; 1 == Sunday; TODO: error check inputs
--]]
local function dayofweek(year, month, day)
return lang_obj:formatDate ('w', year .. '-' .. month .. '-' .. day) + 1;
end
Line 77 ⟶ 50:
local year = props.year
if isleap(year) then daysinmonth[2] = 29 end
local firstday =
local monthcal = {}
local hdr_year = props.show_year and year or '';
table.insert(monthcal, '<table class="mcal">')
table.insert(monthcal, '<tr class="mcalhdr">')
table.insert(monthcal, '<th class="mcal" colspan="7">' .. monthname[mnum] .. ' ' .. hdr_year .. '</th>')
table.insert(monthcal, '</tr>')
Line 136 ⟶ 108:
local function calendar(props)
if props.month then
▲ props.show_year = true; -- show year in individual month calendars
▲ return displaymonth(props, props.month);
else
return displayyear(props)
end
Line 202 ⟶ 142:
--]]
function p.calendar(frame)
local args=getArgs (frame);
local cal_props = {}; -- separate calendar properties table to preserve arguments as originally provided
Line 220 ⟶ 153:
if not mnum then -- month provided as some sort of text string
if args.month == "current" then
cal_props.month = this_month_num
cal_props.year = this_year_num
Line 227 ⟶ 158:
mnum = this_month_num - 1
if mnum == 0 then
cal_props.month = 12 -- december last year
cal_props.year = this_year_num - 1 -- last year
Line 237 ⟶ 166:
mnum = this_month_num + 1
if mnum == 13 then
cal_props.month = 1 -- january next year
cal_props.year = this_year_num + 1 -- next year
Line 245 ⟶ 172:
end
else
local good
good, cal_props.month = pcall (lang_obj.formatDate, lang_obj, 'n', args.month);
Line 259 ⟶ 185:
end
end
-- TODO: add all other args{} from template or invoke to cal_props{} modified as appropriate
return calendar(cal_props)
end
|