وحدة:CopticDate
يمكن إنشاء صفحة توثيق الوحدة في وحدة:CopticDate/شرح
local p = {};
function p.toCoptic(frame) -- {{#invoke:CopticDate|toCoptic|year|month|day}}
local intYear = frame.args[1]
local intMonth = frame.args[2]
local intDay = frame.args[3]
local SeparatorString = frame.args[4]
local StringFormat = frame.args[5]
if SeparatorString == nil or SeparatorString == "" then
SeparatorString = " "
end
local aMonth = math.floor(math.abs((14 - intMonth) / 12))
local jYear = intYear + 4800 - aMonth
local jMonth = intMonth + 12 * aMonth - 3
local julianDate = intDay + math.floor(math.abs((153 * jMonth + 2) / 5)) + 365 * jYear + math.floor(math.abs(jYear / 4)) - math.floor(math.abs(jYear / 100)) + math.floor(math.abs(jYear / 400)) - 32045
local julianBase = math.floor(math.abs(julianDate + 0.5)) + 124
local baseYear = (4 * julianBase + 3) / 1461
local baseLeap = ((4 * julianBase + 3) % 1461) / 4
local baseMonth = baseLeap / 30
local baseDay = baseLeap % 30
local finalDay = math.floor(math.abs(baseDay + 1))
local finalMonth = math.floor(math.abs((baseMonth % 13) + 1))
local finalYear = math.floor(math.abs(baseYear - 4996 + (13 - finalMonth) / 13))
local finalMonthString = { "[[توت (شهر)|توت]]", "[[بابه]]", "[[هاتور]]", "[[كياك]]", "[[طوبه(شهر)|طوبه]]", "[[امشير]]", "[[بارمهات]]", "[[بارموده]]", "[[بشنس]]", "[[بؤونه]]", "[[ابيب]]", "[[مسرا]]", "[[نسيئ (شهر قبطى)|نسيئ]]" }
if StringFormat == nil or StringFormat == "" then
return(finalDay .. SeparatorString .. finalMonth .. SeparatorString .. finalYear)
else
return(finalDay .. SeparatorString .. finalMonthString[finalMonth] .. SeparatorString .. finalYear)
end
end
function p.toEgyptianDate(frame) -- {{#invoke:CopticDate|toEgyptianDate|year|month|day|[يوم - اسم شهر - شهر - سنه مصرى - سنه قبطى ]}}
local intYear = frame.args[1]
local intMonth = frame.args[2]
local intDay = frame.args[3]
local arrgumentString = frame.args[4]
local aMonth = math.floor(math.abs((14 - intMonth) / 12))
local jYear = intYear + 4800 - aMonth
local jMonth = intMonth + 12 * aMonth - 3
local julianDate = intDay + math.floor(math.abs((153 * jMonth + 2) / 5)) + 365 * jYear + math.floor(math.abs(jYear / 4)) - math.floor(math.abs(jYear / 100)) + math.floor(math.abs(jYear / 400)) - 32045
local julianBase = math.floor(math.abs(julianDate + 0.5)) + 124
local baseYear = (4 * julianBase + 3) / 1461
local baseLeap = ((4 * julianBase + 3) % 1461) / 4
local baseMonth = baseLeap / 30
local baseDay = baseLeap % 30
local finalDay = math.floor(math.abs(baseDay + 1))
local finalMonth = math.floor(math.abs((baseMonth % 13) + 1))
local finalYear = math.floor(math.abs(baseYear - 4996 + (13 - finalMonth) / 13))
local finalMonthString = { "[[توت (شهر)|توت]]", "[[بابه]]", "[[هاتور]]", "[[كياك]]", "[[طوبه(شهر)|طوبه]]", "[[امشير]]", "[[بارمهات]]", "[[بارموده]]", "[[بشنس]]", "[[بؤونه]]", "[[ابيب]]", "[[مسرا]]", "[[نسيئ (شهر قبطى)|نسيئ]]" }
if arrgumentString == "يوم" then
return(finalDay)
elseif arrgumentString == "شهر" then
return(finalMonth)
elseif arrgumentString == "اسم شهر" then
return(finalMonthString[finalMonth])
elseif arrgumentString == "سنه قبطى" then
return(finalYear)
elseif arrgumentString == "سنه مصرى" then
return(finalYear+4525)
else
return(finalDay .. SeparatorString .. finalMonthString[finalMonth] .. SeparatorString .. finalYear)
end
end
return p