יחידה:תאריך: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מ 3 גרסאות של הדף wikipedia:he:יחידה:תאריך יובאו |
||
| (12 גרסאות ביניים של 4 משתמשים אינן מוצגות) | |||
| שורה 164: | שורה 164: | ||
end | end | ||
-- | --offset | ||
if offset ~= nil then | if offset ~= nil then | ||
if offset == 'Z' then | if offset == 'Z' then | ||
| שורה 337: | שורה 337: | ||
t2 = Date.julianToGregorian(t2) | t2 = Date.julianToGregorian(t2) | ||
else | else | ||
error(" | error("Calendars don't match", 2) | ||
end | end | ||
end | end | ||
| שורה 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)") | ||
| שורה 901: | שורה 901: | ||
local res = outputPrefix..lang:formatDuration(dif, diffFormat) | local res = outputPrefix..lang:formatDuration(dif, diffFormat) | ||
-- post process formatDuration which is not good enough | -- 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,"וגם ([0-9])","ו־%1") | ||
res= mw.ustring.gsub(res,"וגם ([א-ת])","ו%1") | res= mw.ustring.gsub(res,"וגם ([א-ת])","ו%1") | ||
| שורה 913: | שורה 914: | ||
elseif frame.args[2] == 'שנים' then | elseif frame.args[2] == 'שנים' then | ||
diffFormat = {'years'} | diffFormat = {'years'} | ||
elseif frame.args[2] == 'שנים וימים' then | |||
diffFormat = {'years', 'days'} | |||
elseif frame.args[2] == "הפרש" then | elseif frame.args[2] == "הפרש" then | ||
diffFormat = "raw" | diffFormat = "raw" | ||
| שורה 979: | שורה 982: | ||
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 | ||
| שורה 984: | שורה 1,014: | ||
Date['חשב טווח'] = parseDateRangeSafe; | Date['חשב טווח'] = parseDateRangeSafe; | ||
Date['parseDateRange'] = parseDateRange; | Date['parseDateRange'] = parseDateRange; | ||
Date['מקושר'] = linkStrDateUnsafe; | |||
return Date | return Date | ||