יחידה:Citation/CS1: הבדלים בין גרסאות בדף
אין תקציר עריכה |
מאין תקציר עריכה |
||
| שורה 8: | שורה 8: | ||
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance | properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance | ||
} | } | ||
function local_date( | |||
return mw.getContentLanguage():formatDate(format, | |||
function local_date( date_string, format ) | |||
if format==nil then | |||
if date_string:match("^%d%d%d%d%-%d%d%-%d%d$") then --year month day format | |||
format = 'j xg Y' | |||
elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month day, year | |||
format = 'j xg Y' | |||
elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-initial: day month year | |||
format = 'j xg Y' | |||
elseif date_string:match("^%a+ +%d%d%d%d%a?$") then -- month/season year | |||
format='F Y' | |||
--list of accepted formats derived from Citation/CS1/Date validation - in case we may want to localize them later | |||
--elseif date_string:match("^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial day range: month day–day, year; days are separated by endash | |||
--elseif date_string:match("^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-range-initial: day–day month year; days are separated by endash | |||
--elseif date_string:match("^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-range: day month - day month year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$") then -- month initial month-day-range: month day – month day, year; uses spaced endash | |||
--elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-year-range: day month year - day month year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month initial month-day-year-range: month day, year – month day, year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d–%d%d%a?$") then -- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$") then -- special case Winter/Summer year-year; year separated with unspaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$") then -- month/season year - month/season year; separated by spaced endash | |||
--elseif date_string:match ("^%a+–%a+ +[1-9]%d%d%d%a?$") then -- month/season range year; months separated by endash | |||
--elseif date_string:match("^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$") then -- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999 | |||
--elseif date_string:match("^[1-9]%d%d%d–%d%d%a?$") then -- Year range: YYYY–YY; separated by unspaced endash | |||
--elseif date_string:match("^[1-9]%d%d%d?%a?$") then -- year; here accept either YYY or YYYY | |||
else | |||
--return date_string | |||
error('Unsupported format') | |||
end | |||
end | |||
return mw.getContentLanguage():formatDate(format, date_string) | |||
end | end | ||
| שורה 1,681: | שורה 1,712: | ||
local IsValidDate, LocalDate | local IsValidDate, LocalDate | ||
local DateFormat = | local DateFormat = nil | ||
-- Set postscript default. | -- Set postscript default. | ||
if not is_set (PostScript) then -- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and | if not is_set (PostScript) then -- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and | ||