37,397
עריכות
חלוקת קונטרסים (שיחה | תרומות) (ויקיפדיה) |
חלוקת קונטרסים (שיחה | תרומות) (עדכון מויקיפדיה: https://he.wikipedia.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%AA%D7%90%D7%A8%D7%99%D7%9A) |
||
שורה 164: | שורה 164: | ||
end | end | ||
-- | --offset | ||
if offset ~= nil then | if offset ~= nil then | ||
if offset == 'Z' then | if offset == 'Z' then | ||
שורה 806: | שורה 806: | ||
local outputPrefix = '' | local outputPrefix = '' | ||
local parts = mw.text.split(dateRangeStr,' | local parts = mw.text.split(dateRangeStr,' *[–%-] *') | ||
assert(#parts==2 or #parts==1, "Date range expected format is from - to or from (e.g from - now)") | assert(#parts==2 or #parts==1, "Date range expected format is from - to or from (e.g from - now)") | ||
שורה 899: | שורה 899: | ||
return dif | return dif | ||
else | else | ||
local res = outputPrefix..lang:formatDuration(dif, diffFormat) | |||
-- post process formatDuration which is not good enough | |||
res= mw.ustring.gsub(res,"כ־([א-ת])","כ%1") | |||
res= mw.ustring.gsub(res,"וגם ([0-9])","ו־%1") | |||
res= mw.ustring.gsub(res,"וגם ([א-ת])","ו%1") | |||
return res | |||
end | end | ||
end | end | ||
שורה 924: | שורה 929: | ||
-- the following translations are needed because the underline function | -- the following translations are needed because the underline function | ||
-- local format is wierd | -- local format is wierd | ||
str = mw.ustring.gsub(str, | str = mw.ustring.gsub(str, "(כ)־([א-ת])", "%1%2") | ||
if frame.args[2] == "גיל" then | if frame.args[2] == "גיל" then | ||
שורה 978: | שורה 980: | ||
end | end | ||
end | |||
function linkStrDateUnsafe(frame) | |||
local dateStr = frame.args[1] | |||
local linkedDateStr = dateStr | |||
-- Strip [ and ] chars | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '%[', '') | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '%]', '') | |||
-- Link D M Y, return [[D M]] [[Y]] | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '^(%d+ %a+) (%d+)$', '[[%1]] [[%2]]') | |||
-- Link D M, return [[D M]] | |||
if mw.ustring.find(linkedDateStr, '%[') == nil then | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '^(%d+) (%a+)$', '[[%1 %2]]') | |||
end | |||
-- Link M Y, return [[M]] [[Y]] | |||
if mw.ustring.find(linkedDateStr, '%[') == nil then | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '^(%a+) (%d+)$', '[[%1]] [[%2]]') | |||
end | |||
-- Link Y, return [[Y]] | |||
if mw.ustring.find(linkedDateStr, '%[') == nil then | |||
linkedDateStr = mw.ustring.gsub(linkedDateStr, '^(%d+)$', '[[%1]]') | |||
end | |||
-- Unknown date string format, return the original string | |||
if mw.ustring.find(linkedDateStr, '%[') == nil then | |||
linkedDateStr = dateStr | |||
end | |||
return linkedDateStr | |||
end | end | ||
שורה 983: | שורה 1,012: | ||
Date['חשב טווח'] = parseDateRangeSafe; | Date['חשב טווח'] = parseDateRangeSafe; | ||
Date['parseDateRange'] = parseDateRange; | Date['parseDateRange'] = parseDateRange; | ||
Date['מקושר'] = linkStrDateUnsafe; | |||
return Date | return Date |