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

381 בייטן צוגעלייגט ,  פֿאַר 4 חדשים
מספר לאותיות function should output ה'תשס"ו for 5766, not תתתתתתתתתתתתתתקסו
(געמאכט אז ב'תקט"ז זאל ווערן 2516 אנשטאט 518, און אראפגענומען אומבאנוצטע פונקציעס)
(מספר לאותיות function should output ה'תשס"ו for 5766, not תתתתתתתתתתתתתתקסו)
 
(איין צווישנדיגע ווערסיע פונעם זעלבן באַניצער נישט געוויזן)
שורה 38: שורה 38:
     -- Check for a thousands separator (apostrophe)
     -- Check for a thousands separator (apostrophe)
     local thousands, rest = s:match("^(.-)'(.*)$")
     local thousands, rest = s:match("^(.-)'(.*)$")
     if thousands then
     if thousands and rest ~= "" then
         local total = 0
         local total = 0
         local thousandsValue = 0
         local thousandsValue = 0
שורה 60: שורה 60:
end
end


local mispar_lotiot = function( num, geresh )
local mispar_lotiot = function(num, geresh)
        local res, toadd = '', 0
    local res = ''
         while num > 0 do
 
            if num >= 400 then toadd = 400
    -- Handle thousands
            elseif num >= 100 then toadd = num - num % 100
    local thousands = math.floor(num / 1000)
            elseif num >= 10 then toadd = num - num % 10
    local remainder = num % 1000
            else toadd = num end
 
             res = res .. tab[toadd]
    if thousands > 0 then
            num = num - toadd
         res = res .. tab[thousands] .. "'"
    end
 
    local n = remainder
    while n > 0 do
        local toadd = 0
        if n >= 400 then
            toadd = 400
        elseif n >= 100 then
            toadd = n - n % 100
        elseif n >= 10 then
            toadd = n - n % 10
        else
             toadd = n
         end
         end
         res = mw.ustring.gsub( res, 'יה', 'טו' )
         res = res .. tab[toadd]
        res = mw.ustring.gsub( res, 'יו', 'טז' )
        n = n - toadd
         res = mw.ustring.gsub( res, '(.)(.)$', '%1' .. (geresh or '') .. '%2' )
    end
         return res
 
    -- Special case for 15 and 16
    res = mw.ustring.gsub(res, 'יה', 'טו')
    res = mw.ustring.gsub(res, 'יו', 'טז')
 
    -- Add geresh or gershayim if needed
    if mw.ustring.len(res) > 1 then
         res = mw.ustring.gsub(res, '(.)(.)$', '%1' .. (geresh or '"') .. '%2')
    else
         res = res .. (geresh or "'")
    end
 
    return res
end
end