מייבאים כמותיים, בדוקי עריכות אוטומטית, ביוראקראטן, אינטערפעיס רעדאקטארן, emailconfirmed, אינטערפעיס אדמיניסטראַטאָרן, מנטרים, סיסאפן, צוות טכני, מייבאים, מעדכנים, אספקלריה רעדאקטארן
102,362
רעדאגירונגען
שרגא (שמועס | ביישטייערונגען) ק (1 רעוויזיע אימפארטירט: אימפארטירט פון די יידישע וויקיפעדיע, זע ביישטייערער ליסטע) |
(דיוק) |
||
| (19 מיטלסטע ווערסיעס פון 4 באַניצער נישט געוויזן.) | |||
| שורה 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 | ||
| שורה 337: | שורה 373: | ||
t2 = Date.julianToGregorian(t2) | t2 = Date.julianToGregorian(t2) | ||
else | else | ||
error(" | error("Calendars don't match", 2) | ||
end | 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>%(%[%[ | if mw.ustring.find( wikitext, '<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>' ) then | ||
calendar = Date.CALENDAR.JULIAN | calendar = Date.CALENDAR.JULIAN | ||
wikitext = mw.ustring.gsub( wikitext, "<small>%(%[%[ | wikitext = mw.ustring.gsub( wikitext, "<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>", "" ) | ||
end | end | ||
| שורה 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") | ||
| שורה 561: | שורה 590: | ||
if (self.precision >= Date.PRECISION.MY100) and (self.precision <= Date.PRECISION.MY) then | if (self.precision >= Date.PRECISION.MY100) and (self.precision <= Date.PRECISION.MY) then | ||
if self.year>0 then | if self.year>0 then | ||
return (self.year/1000000) .. ' | return (self.year/1000000) .. ' מיליאן יאר צום ציילונג' | ||
else | else | ||
return (-self.year/1000000) ..' | return (-self.year/1000000) ..' מיליאן יאר פד"צ' | ||
end | end | ||
elseif (self.precision >=Date.PRECISION.KY100) and (self.precision <= Date.PRECISION.KY) then | elseif (self.precision >=Date.PRECISION.KY100) and (self.precision <= Date.PRECISION.KY) then | ||
| שורה 598: | שורה 627: | ||
else | else | ||
if self.calendar == Date.CALENDAR.JULIAN and self.year > 1583 then | if self.calendar == Date.CALENDAR.JULIAN and self.year > 1583 then | ||
hebrewStr = mw.ustring.format('%d <small>([[ | hebrewStr = mw.ustring.format('%d <small>([[יוליאנישער קאלענדאר|יוליאניש]])</small>', (self.year)) | ||
else | else | ||
hebrewStr = mw.ustring.format('%d', self.year) | hebrewStr = mw.ustring.format('%d', self.year) | ||
| שורה 609: | שורה 638: | ||
return hebrewStr | return hebrewStr | ||
end | end | ||
local months = { 'יאנואר','פעברואר', 'מערץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אויגוסט', 'סעפטעמבער', 'אקטאבער', 'נאוועמבער','דעצעמבער' } | |||
hebrewStr = months[self.month] .. ' ' .. hebrewStr | hebrewStr = months[self.month] .. ' ' .. hebrewStr | ||
| שורה 616: | שורה 645: | ||
return hebrewStr | return hebrewStr | ||
end | end | ||
hebrewStr = mw.ustring.format('%d %s', self.day, hebrewStr) | |||
--hour | --hour | ||
| שורה 737: | שורה 766: | ||
local fd = '' | local fd = '' | ||
if self.precision >= Date.PRECISION.DAY then | if self.precision >= Date.PRECISION.DAY then | ||
fd = self.year < 0 and (-1 * self.year) .. ' | fd = self.year < 0 and (-1 * self.year) .. ' פד"צ' or fd .. self.year | ||
if options.link then fd = '[[' .. fd .. ']]' end | if options.link then fd = '[[' .. fd .. ']]' end | ||
local d = '2000-' .. prepend(self.month, '0', 2) .. '-' .. prepend(self.day, '0', 2) | local d = '2000-' .. prepend(self.month, '0', 2) .. '-' .. prepend(self.day, '0', 2) | ||
| שורה 743: | שורה 772: | ||
fd = fd .. '. ' .. lang:formatDate(options.link and '[[j xg]]' or 'j xg', d) | fd = fd .. '. ' .. lang:formatDate(options.link and '[[j xg]]' or 'j xg', d) | ||
elseif self.precision >= Date.PRECISION.MONTH then | elseif self.precision >= Date.PRECISION.MONTH then | ||
fd = self.year < 0 and (-1 * self.year) .. ' | fd = self.year < 0 and (-1 * self.year) .. ' פד"צ' or fd .. self.year | ||
local month = mw.getContentLanguage():formatDate('F', '2000-' .. self.month) | local month = mw.getContentLanguage():formatDate('F', '2000-' .. self.month) | ||
if options.link then fd = '[[' .. fd .. ']]' end | if options.link then fd = '[[' .. fd .. ']]' end | ||
fd = month .. ' ' .. fd | fd = month .. ' ' .. fd | ||
elseif self.precision >= Date.PRECISION.YEAR then | elseif self.precision >= Date.PRECISION.YEAR then | ||
fd = self.year < 0 and (-1 * self.year) .. ' | fd = self.year < 0 and (-1 * self.year) .. ' פד"צ' or fd .. self.year | ||
if options.link ~= 'nem' then fd = '[[' .. fd .. ']]' end | if options.link ~= 'nem' then fd = '[[' .. fd .. ']]' end | ||
elseif self.precision == Date.PRECISION.YEAR10 then | elseif self.precision == Date.PRECISION.YEAR10 then | ||
local year = math.floor((self.year < 0 and -1 * self.year or self.year) / 10) * 10 | local year = math.floor((self.year < 0 and -1 * self.year or self.year) / 10) * 10 | ||
fd = 'שנות ה-' .. tostring(year%100) .. ' של המאה ה-'.. tostring(ceil(year/100)) | fd = 'שנות ה-' .. tostring(year%100) .. ' של המאה ה-'.. tostring(ceil(year/100)) | ||
fd = self.year < 0 and year .. ' | fd = self.year < 0 and year .. ' פד"צ' or tostring(year) | ||
elseif self.precision == Date.PRECISION.YEAR100 then | elseif self.precision == Date.PRECISION.YEAR100 then | ||
if self.year < 0 then | if self.year < 0 then | ||
fd = 'המאה ה-' .. math.floor(-1 * self.year / 100) .. ' | fd = 'המאה ה-' .. math.floor(-1 * self.year / 100) .. ' פד"צ' | ||
else | else | ||
fd = 'המאה ה-' ..math.floor(self.year / 100) | fd = 'המאה ה-' ..math.floor(self.year / 100) | ||
| שורה 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 | ||
| שורה 864: | שורה 893: | ||
readableInterval['years'] = readableInterval['years'] or 0 | readableInterval['years'] = readableInterval['years'] or 0 | ||
if not (guessLevel==NO_GUESS) and not (guessLevel==DAY_GUESS and hasYears and #diffFormat==1 and readableInterval['days']>31) then | if not (guessLevel==NO_GUESS) and not (guessLevel==DAY_GUESS and hasYears and #diffFormat==1 and readableInterval['days']>31) then | ||
outputPrefix=' | outputPrefix='בערך ' | ||
end | end | ||
if inclusive then | if inclusive then | ||
| שורה 912: | שורה 941: | ||
if frame.args[2] == 'ימים' then | if frame.args[2] == 'ימים' then | ||
diffFormat = {'days'} | diffFormat = {'days'} | ||
elseif frame.args[2] == ' | 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" | ||
| שורה 940: | שורה 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 | ||
end | end | ||
if str == " | if str == "יאר" then | ||
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 | ||
| שורה 956: | שורה 987: | ||
return str | return str | ||
else | else | ||
return frame.args['error'] or '<span class="scribunto-error"> | return frame.args['error'] or '<span class="scribunto-error">דאטום פעלער: '..res..'</span>[[קאטעגאריע:בלעטער מיט דאטום פעלערן]]' | ||
end | end | ||
end | end | ||
| שורה 962: | שורה 993: | ||
function parseStrDateSafe(frame) | function parseStrDateSafe(frame) | ||
local dateType = frame.args[2] | local dateType = frame.args[2] | ||
if dateType ==' | if dateType =='יאר' then | ||
dateType = 'Y' | dateType = 'Y' | ||
elseif dateType==' | elseif dateType=='מאנאט' then | ||
dateType = 'M' | dateType = 'M' | ||
elseif dateType==' | elseif dateType=='טאג' then | ||
dateType='D' | dateType='D' | ||
end | end | ||
| שורה 973: | שורה 1,004: | ||
if success then | if success then | ||
if dateType=='Y' and mw.ustring.sub( res, 0, 1)=='-' then | if dateType=='Y' and mw.ustring.sub( res, 0, 1)=='-' then | ||
res = mw.ustring.sub( res, 2).. ' | res = mw.ustring.sub( res, 2).. ' פד"צ' | ||
end | end | ||
return res | return res | ||
else | else | ||
return frame.args['error'] or '<span class="scribunto-error"> | return frame.args['error'] or '<span class="scribunto-error">דאטום פעלער: '..res..'</span>[[קאטעגאריע:בלעטער מיט דאטום פעלערן]]' | ||
end | end | ||
| שורה 1,009: | שורה 1,040: | ||
end | end | ||
Date[' | Date['רעכן'] = parseStrDateSafe; | ||
Date[' | Date['רעכן אפשטאנד'] = parseDateRangeSafe; | ||
Date['parseDateRange'] = parseDateRange; | Date['parseDateRange'] = parseDateRange; | ||
Date['מקושר'] = linkStrDateUnsafe; | Date['מקושר'] = linkStrDateUnsafe; | ||
return Date | return Date | ||
רעדאגירונגען