local umdata = require ('Module:Hijri/umalqura data')
local adjust_data = require('Module:Hijri/adjustment data')
local umstartyear = 1318

local function gregorian2jd(y, m, d)
    local jd, century

    if y < 1 then
        y = y + 1
    end

    if m > 2 then
        m = m + 1
        y = y + 4800
    else
        m = m + 13
        y = y + 4799
    end
    century = math.floor(y / 100)
    return (y * 365 - 32167 + math.floor(y / 4) - century + math.floor(century / 4) + math.floor(7834 * m / 256) + d)
end

if adjust_data and #adjust_data>0 then
	for yk,yv in pairs(adjust_data) do
	    for mk,mv in pairs(yv) do
	        local uk = (yk-umstartyear)*12 + mk -1
	        if type(mv) == 'table' then
	            umdata[uk] = gregorian2jd(mv[1],mv[2],mv[3]) - 2400000
	        elseif mv >-2 and mv <2 then
	            umdata[uk] = umdata[uk] - mv
	        end
	    end
	end
end

return umdata