Module:Calendar date: Difference between revisions

Content deleted Content added
No edit summary
m Reverted edit by 213.147.181.177 (talk) to last version by 130.64.64.65
 
(15 intermediate revisions by 9 users not shown)
Line 1:
--[[
 
Display Gregorian date of a holiday that moves year to year. Date data can be obtained from multiple sources as configured in ~Module:Calendar date/Configuration.jsevents
 
"localfile" = local JSON data file (eg. https://en.wikipedia.org/wiki/TemplateModule:Calendar_date/holidayslocalfiles/Hanukkah.js)
"calculator" = user-supplied date calculator (eg. )
"wikidata" = <tbd> for holidays with their own date entity page such as https://www.wikidata.org/wiki/Q51224536
]]
 
require('Module:No globalsstrict')
 
local p = {}
local cfg -- Data structure from ~/Eventsevents
local eventdata -- Data structure from ~/localfiles/<holiday name>
local track = {} -- Tracking category container
Line 39:
if arg == "" or arg == nil then
return nil
else
return mw.text.trim(arg)
end
return mw.text.trim(arg)
end
local function trimArg2(arg)
if arg == nil then
return nil
else
return mw.text.trim(arg)
end
return mw.text.trim(arg)
end
 
Line 76 ⟶ 74:
if display and ('' ~= display) then
return table.concat ({'[[', link, '|', display, ']]'});
else
return table.concat ({'[[', link, ']]'});
end
return table.concat ({'[[', link, ']]'});
end
else -- no_link
if display and ('' ~= display) then -- if there is display text
return display; -- return that
else
return link or ''; -- return the target article name or empty string
end
return link or ''; -- return the target article name or empty string
end
end
Line 176 ⟶ 172:
if format ~= "infobox" then
return mw.getContentLanguage():formatDate (formatFull[df], date)
else
return mw.getContentLanguage():formatDate (formatInfobox[df], date)
end
return mw.getContentLanguage():formatDate (formatInfobox[df], date)
end
 
Line 291 ⟶ 286:
if startdate == enddate or cfg.days == "1" then -- single date
return prepend1 .. startdate .. endoutoffset .. cite
else
return prepend1 .. startdate .. format .. prepend2 .. enddate .. endoutoffset .. cite
end
return prepend1 .. startdate .. format .. prepend2 .. enddate .. endoutoffset .. cite
end
 
Line 334 ⟶ 328:
--- Determine format type
format = trimArg(args.format)
if not format or format ~= "infobox" then
format = "none"
elseif format ~= "infobox" then
format = "none"
end
 
-- Load configuration file
local eventsfile = mw.loadData ('Module:Calendar date/Eventsevents')
if eventsfile.hebrew_calendar[mw.ustring.upper(holiday)] then
cfg = eventsfile.hebrew_calendar[mw.ustring.upper(holiday)]
elseif eventsfile.christian_events[mw.ustring.upper(holiday)] then
cfg = eventsfile.christian_events[mw.ustring.upper(holiday)]
elseif eventsfile.carnivals[mw.ustring.upper(holiday)] then
cfg = eventsfile.carnivals[mw.ustring.upper(holiday)]
elseif eventsfile.chinese_events[mw.ustring.upper(holiday)] then
cfg = eventsfile.chinese_events[mw.ustring.upper(holiday)]
elseif eventsfile.misc_events[mw.ustring.upper(holiday)] then
cfg = eventsfile.misc_events[mw.ustring.upper(holiday)]
Line 383 ⟶ 381:
cite = trimArg2(args.cite)
if cite then
if (cite ~= "no") then
format cite = "none"
if cfg.datatype == "localfile" then
if cfg.citeurl and cfg.accessdate and cfg.source and cfg.name then
local citetitle = cfg.citetitle
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">{{cite web |url=' .. cfg.citeurl .. ' |title=Dates for ' .. cfg.name .. ' |publisher=' .. cfg.source .. ' |via=[[Template:' .. tname .. '|' .. tname .. ']] and [[Module:' .. tname .. '/localfiles/' .. holiday .. '|' .. holiday .. ']] |accessdate=' .. cfg.accessdate .. '}}</ref>')
if citetitle == nil then
citetitle = 'Dates for ' .. cfg.name
else end
cite = frame:preprocess('<ref name="' .. holiday .. ' dates">{{cite web |url=' .. cfg.citeurl .. ' |title=Dates for ' .. cfg.namecitetitle .. ' |publisher=' .. cfg.source .. ' |via=[[Template:' .. tname .. '|' .. tname .. ']] and [[Module:' .. tname .. '/localfiles/' .. holiday .. '|' .. holiday .. ']] |accessdate=' .. cfg.accessdate .. '}}</ref>')
elseif cfg.datatype == "calculator"source then
cite = (cfg.source and (frame:preprocess('<ref name="' .. holiday .. ' dates">' .. cfg.source:gsub("YYYY", date) .. '</ref>')))
end
else
elseif cfg.datatype == "calculator" then
cite = ""
cite = (cfg.source and (frame:preprocess('<ref name="' .. holiday .. ' dates">' .. cfg.source .. '</ref>')))
end
else