אונטערשייד צווישן ווערסיעס פון "יחידה:דאטום"

קפיצה לניווט קפיצה לחיפוש
260 בייטן צוגעלייגט ,  פֿאַר 2 יאָר
אויך MDY (אפריל 2, 1990) זאל ארבעטן
ק (תנא קמא האט אריבערגעפירט בלאט יחידה:תאריך צו יחידה:דאטום אן לאזן א ווייטערפירונג)
(אויך MDY (אפריל 2, 1990) זאל ארבעטן)
צייכן: צוריקגעשטעלט
שורה 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


שורה 430: שורה 466:
]]
]]
function Date.newFromWikitext( wikitext )
function Date.newFromWikitext( wikitext )
local months = {
['יאנואר']= 1,
['פעברואר']= 2,
['מערץ']= 3,
['אפריל']= 4,
['מאי']= 5,
['יוני']= 6,
['יולי']= 7,
['אויגוסט']= 8,
['סעפטעמבער']= 9,
['אקטאבער']= 10,
['נאוועמבער']= 11,
['דעצעמבער']= 12
}
local calendar = nil
local calendar = nil
if mw.ustring.find( wikitext, '<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>' ) then
if mw.ustring.find( wikitext, '<small>%(%[%[יוליאנישער קאלענדאר%|יוליאניש%]%]%)</small>' ) then
שורה 459: שורה 481:
-- BC to minus
-- BC to minus
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) לפנה[\"״]ס" , "-%1")
wikitext = mw.ustring.gsub( wikitext, "([0-9]+) לפנה[\"״]ס" , "-%1")
for a in pairs(months) do
wikitext = mw.ustring.gsub(wikitext, ' ?ב?'..a, ' ' .. months[a])
end


if mw.ustring.match(wikitext, '^המאה ה[־-]%d+$') then
if mw.ustring.match(wikitext, '^המאה ה[־-]%d+$') then
שורה 468: שורה 486:
                 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 there are alphabet chars return nil (unexpected character)
 
assert(not mw.ustring.find(wikitext, '%a'), "Unexpected format")
local parts = mw.text.split(mw.text.trim(wikitext),' ')
local parts = mw.text.split(mw.text.trim(wikitext),' ')


שורה 476: שורה 493:
if #parts==3 then -- DMY date
if #parts==3 then -- DMY date
definition.year = tonumber(parts[3])
definition.year = tonumber(parts[3])
definition.month = tonumber(parts[2])
definition.day, definition.month = monthDay({parts[1], parts[2]})
definition.day = tonumber(parts[1])
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: שורה 499:
definition.precision = Date.PRECISION.DAY
definition.precision = Date.PRECISION.DAY
elseif  #parts==2 then -- MY date
elseif  #parts==2 then -- MY date
definition.year = tonumber(parts[2])
definition.month, definition.year = monthDay(parts, true)
definition.month = tonumber(parts[1])
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")

נאוויגאציע מעניו