מייבאים כמותיים, בדוקי עריכות אוטומטית, ביוראקראטן, אינטערפעיס רעדאקטארן, emailconfirmed, אינטערפעיס אדמיניסטראַטאָרן, מנטרים, סיסאפן, צוות טכני, מייבאים, מעדכנים, אספקלריה רעדאקטארן
102,362
רעדאגירונגען
ק (תנא קמא האט אריבערגעפירט בלאט יחידה:תאריך צו יחידה:דאטום אן לאזן א ווייטערפירונג) |
(דיוק) |
||
| (11 מיטלסטע ווערסיעס פון 2 באַניצער נישט געוויזן.) | |||
| שורה 261: | שורה 261: | ||
return year, month, day | return year, month, day | ||
end | |||
--[[ get month name and day (as numeric string), in either order, and return their numbers as day, month | |||
if optional parameter 'reverse' is true, return month first | |||
]]-- | |||
local function monthDay(dateTable, reverse) | |||
local months = { | |||
['יאנואר']= 1, | |||
['פעברואר']= 2, | |||
['מערץ']= 3, | |||
['אפריל']= 4, | |||
['מאי']= 5, | |||
['יוני']= 6, | |||
['יולי']= 7, | |||
['אויגוסט']= 8, | |||
['סעפטעמבער']= 9, | |||
['אקטאבער']= 10, | |||
['נאוועמבער']= 11, | |||
['דעצעמבער']= 12 | |||
} | |||
local month = nil | |||
local day = nil | |||
for _, value in ipairs(dateTable) do | |||
if months[value] then | |||
month = months[value] | |||
else | |||
day = tonumber(value) | |||
end | |||
end | |||
if reverse then | |||
return month, day | |||
else | |||
return day, month | |||
end | |||
end | end | ||
| שורה 422: | שורה 458: | ||
return Date.new( definition ) | return Date.new( definition ) | ||
end | |||
local function extractNumbers(inputString) | |||
local numbers = inputString:match("^(%d+[%s%d-]*)") | |||
return numbers or "" | |||
end | end | ||
| שורה 430: | שורה 471: | ||
]] | ]] | ||
function Date.newFromWikitext( wikitext ) | function Date.newFromWikitext( wikitext ) | ||
local calendar = nil | local calendar = nil | ||
if mw.ustring.find( wikitext, '<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>' ) then | if mw.ustring.find( wikitext, '<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>' ) then | ||
| שורה 456: | שורה 483: | ||
wikitext = mw.ustring.gsub(wikitext, "‏","") | wikitext = mw.ustring.gsub(wikitext, "‏","") | ||
wikitext = mw.ustring.gsub(wikitext, "‎","") | wikitext = mw.ustring.gsub(wikitext, "‎","") | ||
wikitext = mw.ustring.gsub(wikitext, ",","") | |||
-- BC to minus | -- BC to minus | ||
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) לפנה[\"״]ס" , "-%1") | wikitext = mw.ustring.gsub( wikitext, "([0-9]+) לפנה[\"״]ס" , "-%1") | ||
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) אא[\"״]ר" , "-%1") | |||
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) בצ[\"״]ר" , "-%1") | |||
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) פד[\"״]צ" , "-%1") | |||
if mw.ustring.match(wikitext, '^המאה ה[־-]%d+$') then | if mw.ustring.match(wikitext, '^המאה ה[־-]%d+$') then | ||
| שורה 468: | שורה 495: | ||
return Date.new( { year=tonumber(yearStr)*100, month=0, day=0, precision= Date.PRECISION.YEAR100 } ) | return Date.new( { year=tonumber(yearStr)*100, month=0, day=0, precision= Date.PRECISION.YEAR100 } ) | ||
end | end | ||
if mw.ustring.match(wikitext, "%d+['ס]?ט[ען]ר? י") then | |||
local yearStr = mw.ustring.match(wikitext, "(%d+)['ס]?ט[ען]ר? י") | |||
return Date.new( { year=tonumber(yearStr)*100, month=0, day=0, precision= Date.PRECISION.YEAR100 } ) | |||
end | |||
local parts = mw.text.split(mw.text.trim(wikitext),' ') | local parts = mw.text.split(mw.text.trim(wikitext),' ') | ||
| שורה 476: | שורה 507: | ||
if #parts==3 then -- DMY date | if #parts==3 then -- DMY date | ||
definition.year = tonumber(parts[3]) | definition.year = tonumber(parts[3]) | ||
definition.month = | definition.day, definition.month = monthDay({parts[1], parts[2]}) | ||
assert(definition.year, "Could not recognize year") | assert(definition.year, "Could not recognize year") | ||
assert(definition.month<13 and definition.month>0, "Could not recognize month number") | assert(definition.month<13 and definition.month>0, "Could not recognize month number") | ||
| שורה 483: | שורה 513: | ||
definition.precision = Date.PRECISION.DAY | definition.precision = Date.PRECISION.DAY | ||
elseif #parts==2 then -- MY date | elseif #parts==2 then -- MY date | ||
definition. | definition.month, definition.year = monthDay(parts, true) | ||
definition.precision = Date.PRECISION.MONTH | definition.precision = Date.PRECISION.MONTH | ||
assert(definition.year<1e7, "Could not recognize year") | assert(definition.year<1e7, "Could not recognize year") | ||
| שורה 812: | שורה 841: | ||
local t1 = Date.newFromWikitext( parts[1] ) | local t1 = Date.newFromWikitext( parts[1] ) | ||
local t2 | local t2 | ||
local useCurrent = #parts<2 or (parts[2] == ' | local useCurrent = #parts<2 or (parts[2] == 'היינט' or parts[2]=='הווה' or parts[2]=='אנגייענד' or parts[2]=='איצט') | ||
if not useCurrent then | if not useCurrent then | ||
| שורה 942: | שורה 971: | ||
str= mw.ustring.gsub(str,"כ(.+)","%1"); | str= mw.ustring.gsub(str,"כ(.+)","%1"); | ||
str= mw.ustring.gsub(str,"־(.+)","%1"); | str= mw.ustring.gsub(str,"־(.+)","%1"); | ||
str= mw.ustring.gsub(str," | str= mw.ustring.gsub(str," יאָרן","") | ||
if str == "שנתיים" then | if str == "שנתיים" then | ||
str = 2 | str = 2 | ||
| שורה 949: | שורה 978: | ||
str = 1 | str = 1 | ||
end | end | ||
str = mw.ustring.gsub(str," | str = mw.ustring.gsub(str," יאָר", "") | ||
if tonumber(str) > 0 and | if tonumber(str) > 0 and | ||
tonumber(parseDateRange(frame.args[1], "raw", inclusive)) < 0 then | tonumber(parseDateRange(frame.args[1], "raw", inclusive)) < 0 then | ||
רעדאגירונגען