convertHistoryToHijri
لتحويل التاريخ الميلادي إلى هجري
ملاحظة: الطريقة ليست دقيقة 100 %
Syntax
string string string convertHistoryToHijri ( );
Function Source
convertHistoryToHijri = function ( )
local Time = getRealTime ( );
local Day = Time.monthday
local Month = Time.month + 1
local Year = Time.year + 1900
--
if Month == 1 then Last = Day end
if Month == 2 then Last = Day + 30 end
if Month == 3 then Last = Day + 60 end
if Month == 4 then Last = Day + 90 end
if Month == 5 then Last = Day + 120 end
if Month == 6 then Last = Day + 150 end
if Month == 7 then Last = Day + 180 end
if Month == 8 then Last = Day + 210 end
if Month == 9 then Last = Day + 240 end
if Month == 10 then Last = Day + 270 end
if Month == 11 then Last = Day + 300 end
if Month == 12 then Last = Day + 330 end
--
x = math.ceil ( ( Year - 1 ) * 365.25 );
x = x + Last
x = math.abs ( x - 227015 );
x = math.floor ( x * 30 );
xx = x
x = math.floor ( x / 10631 );
m = math.floor ( x * 10631 );
m = math.abs ( m - xx );
x2 = math.floor ( m / 30 );
x2 = math.abs ( x2 - 13 );
--
if x2 >= 1 and x2 <= 30 then x4 = x2 x3 = 1 end
if x2 >= 31 and x2 <= 60 then x4 = x2 - 30 x3 = 2 end
if x2 >= 61 and x2 <= 90 then x4 = x2 - 60 x3 = 3 end
if x2 >= 91 and x2 <= 120 then x4 = x2 - 90 x3 = 4 end
if x2 >= 121 and x2 <= 150 then x4 = x2 - 120 x3 = 5 end
if x2 >= 151 and x2 <= 180 then x4 = x2 - 150 x3 = 6 end
if x2 >= 181 and x2 <= 210 then x4 = x2 - 180 x3 = 7 end
if x2 >= 211 and x2 <= 240 then x4 = x2 - 210 x3 = 8 end
if x2 >= 241 and x2 <= 270 then x4 = x2 - 240 x3 = 9 end
if x2 >= 271 and x2 <= 300 then x4 = x2 - 270 x3 = 10 end
if x2 >= 301 and x2 <= 330 then x4 = x2 - 300 x3 = 11 end
if x2 >= 331 and x2 <= 360 then x4 = x2 - 330 x3 = 12 end
--
return tostring ( x4 ), tostring ( x3 ), tostring ( x + 1 );
end
مثال
setTimer (
function ( )
local Day, Month, Year = convertHistoryToHijri ( );
outputChatBox ( Day .. "/" .. Month .. "/" .. Year .. " هـ" );
end
, 1000
, 1
);
convertHistoryToHijri = function ( )
local Time = getRealTime ( );
local Day = Time.monthday
local Month = Time.month + 1
local Year = Time.year + 1900
--
if Month == 1 then Last = Day end
if Month == 2 then Last = Day + 30 end
if Month == 3 then Last = Day + 60 end
if Month == 4 then Last = Day + 90 end
if Month == 5 then Last = Day + 120 end
if Month == 6 then Last = Day + 150 end
if Month == 7 then Last = Day + 180 end
if Month == 8 then Last = Day + 210 end
if Month == 9 then Last = Day + 240 end
if Month == 10 then Last = Day + 270 end
if Month == 11 then Last = Day + 300 end
if Month == 12 then Last = Day + 330 end
--
x = math.ceil ( ( Year - 1 ) * 365.25 );
x = x + Last
x = math.abs ( x - 227015 );
x = math.floor ( x * 30 );
xx = x
x = math.floor ( x / 10631 );
m = math.floor ( x * 10631 );
m = math.abs ( m - xx );
x2 = math.floor ( m / 30 );
x2 = math.abs ( x2 - 13 );
--
if x2 >= 1 and x2 <= 30 then x4 = x2 x3 = 1 end
if x2 >= 31 and x2 <= 60 then x4 = x2 - 30 x3 = 2 end
if x2 >= 61 and x2 <= 90 then x4 = x2 - 60 x3 = 3 end
if x2 >= 91 and x2 <= 120 then x4 = x2 - 90 x3 = 4 end
if x2 >= 121 and x2 <= 150 then x4 = x2 - 120 x3 = 5 end
if x2 >= 151 and x2 <= 180 then x4 = x2 - 150 x3 = 6 end
if x2 >= 181 and x2 <= 210 then x4 = x2 - 180 x3 = 7 end
if x2 >= 211 and x2 <= 240 then x4 = x2 - 210 x3 = 8 end
if x2 >= 241 and x2 <= 270 then x4 = x2 - 240 x3 = 9 end
if x2 >= 271 and x2 <= 300 then x4 = x2 - 270 x3 = 10 end
if x2 >= 301 and x2 <= 330 then x4 = x2 - 300 x3 = 11 end
if x2 >= 331 and x2 <= 360 then x4 = x2 - 330 x3 = 12 end
--
return tostring ( x4 ), tostring ( x3 ), tostring ( x + 1 );
end