تضامنًا مع حق الشعب الفلسطيني |
وحدة:DateFunctions
اذهب إلى التنقل
اذهب إلى البحث
استعمال
هذه الوحدة خاصة بالتقويم حيث تجلب أيام الأسبوع، وعدد الأيام في الشهر وغيرها. التقويم المستخدم هو التقويم الميلادي في أسماء الشهور أنظر هنا للمزيد.
{{#invoke:DateFunctions|الوظيفة}}
اليوم والتاريخ
يعرض ما هو اليوم أولا ثم يعرض تاريخه والشهر والسنة.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|اليوم والتاريخ}} |
الخميس, 17 أكتوبر 2024 |
التاريخ
يعرض التاريخ والشهر والسنة بدون اليوم.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|التاريخ}} |
17 أكتوبر 2024 |
الموافق
يعرض اليوم والتاريخ والشهر والسنة.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|الموافق}} |
اليوم هوالخميس, الموافق17 أكتوبر 2024 |
تاريخ اليوم
يعرض تاريخ اليوم فقط.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|تاريخ اليوم}} |
17 |
الشهر الحالي
يعرض الشهر الحالي.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|الشهر الحالي}} |
أكتوبر |
السنة الحالية
يعرض السنة الحالية.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|السنة الحالية}} |
2024 |
getMonthDays
معرفة في الشهر كم يوم مثل 30 أو 31 يوم.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|getMonthDays}} |
31 |
getfirstDayNum
يكشف عن تاريخ اليوم فقط مثل 4 أو 5 ... بدون عرض لشهر أو السنة.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|getfirstDayNum}} |
2 |
getdaynumtest
يعرض أول يوم في الشهر الحالي.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|getdaynumtest}} |
اليوم الأول من شهر:أكتوبر سنة2024 يومالثلاثاء |
تقويم هجري
السنة الهجرية
- يعرض السنة الهجرية الحالية إعتمادا على التقويم الميلادي. حسب المعادلة التالية
- سنة هجرية= [(سنة ميلادية-622)*33] َََ/32
- سوف يظهر الناتج كعدد غير صحيح يحوي على كسور، أستخدمنا math.floor(النتيجة) ليقربها لقيمة أقل.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|السنة الهجرية}} |
1445 |
السنة الهجرية2
- يعرض السنة الهجرية الحالية إعتمادا على التقويم الميلادي. حسب المعادلة التالية
- التاريخ الهجري=(سنة ميلادية-622)\0,97
- سوف يظهر الناتج كعدد غير صحيح يحوي على كسور، أستخدمنا math.floor(النتيجة + 0.5) لتقريب العدد لقيمة أقل إن كان الرقم بعد الفاصلة أقل من 5 إما لو كان غير ذلك يتم التقريب لقيمة أعلى.
توصيف | يظهر |
---|---|
{{#invoke:DateFunctions|السنة الهجرية2}} |
1445 |
p = {}
-- RiciLake comments:
-- It would be better to create the days_in_month table outside the
-- function, like this (using % so it only works in Lua 5.1)
do
local days_in_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local function is_leap_year(year)
return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0)
end
function get_days_in_month(month, year)
if month == 2 and is_leap_year(year) then
return 29
else
return days_in_month[month]
end
end
end
-- الأشهر الميلادية
mhnas = { {['name'] = 'يناير', ['gen'] = 'يناير', ['d'] = 31},
{['name'] = 'فبراير', ['gen'] = 'فبراير', ['d'] = 29},
{['name'] = 'مارس', ['gen'] = 'مارس', ['d'] = 31},
{['name'] = 'أبريل', ['gen'] = 'أبريل', ['d'] = 30},
{['name'] = 'مايو', ['gen'] = 'مايو', ['d'] = 31},
{['name'] = 'يونيو', ['gen'] = 'يونيو', ['d'] = 30},
{['name'] = 'يوليو', ['gen'] = 'يوليو', ['d'] = 31},
{['name'] = 'أغسطس', ['gen'] = 'أغسطس', ['d'] = 31},
{['name'] = 'سبتمبر', ['gen'] = 'سبتمبر', ['d'] = 30},
{['name'] = 'أكتوبر', ['gen'] = 'أكتوبر', ['d'] = 31},
{['name'] = 'نوفمبر', ['gen'] = 'نوفمبر', ['d'] = 30},
{['name'] = 'ديسمبر', ['gen'] = 'ديسمبر', ['d'] = 31},
}
-- السبعة الأسبوع الشبعة
hmera = { 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'الجمعةالسبت', 'الأحد'}
-- الأشهر الهجرية
Hijri = { {['name'] = 'محرم', ['gen'] = 'محرم', ['d'] = 30},
{['name'] = 'صفر', ['gen'] = 'صفر', ['d'] = 29},
{['name'] = 'ربيع الأول', ['gen'] = 'ربيع الأول', ['d'] = 30},
{['name'] = 'ربيع الثاني', ['gen'] = 'ربيع الثاني', ['d'] = 29},
{['name'] = 'جمادى الأولى', ['gen'] = 'جمادى الأولى', ['d'] = 30},
{['name'] = 'جمادى الآخرة', ['gen'] = 'جمادى الآخرة', ['d'] = 29},
{['name'] = 'رجب', ['gen'] = 'رجب', ['d'] = 30},
{['name'] = 'شعبان', ['gen'] = 'شعبان', ['d'] = 29},
{['name'] = 'رمضان', ['gen'] = 'رمضان', ['d'] = 30},
{['name'] = 'شوال', ['gen'] = 'شوال', ['d'] = 29},
{['name'] = 'ذو القعدة', ['gen'] = 'ذو القعدة', ['d'] = 30},
{['name'] = 'ذو الحجة', ['gen'] = 'ذو الحجة', ['d'] = 29-30},
}
-- returns the day of week integer and the name of the week
-- Compatible with Lua 5.0 and 5.1.
-- from sam_lie
function get_day_of_week(dd, mm, yy)
-- local days = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }
-- local days = { 7, 2, 3, 4, 5, 6, 6 }
local mmx = mm
if (mm == 1) then mmx = 13; yy = yy-1 end
if (mm == 2) then mmx = 14; yy = yy-1 end
local val8 = dd + (mmx*2) + math.floor(((mmx+1)*3)/5) + yy + math.floor(yy/4) - math.floor(yy/100) + math.floor(yy/400) + 2
local val9 = math.floor(val8/7)
local dw = val8-(val9*7)
if (dw < 2 ) then
dw = dw + 6
else
dw =dw - 1
end
-- return dw, days[dw]
-- return days[dw]
return dw
end
function p.getfirstDayNum(frame)
local args = frame.args
local year = 0
local month = 0
local osdate = os.date('*t')
if args['سنة'] == nil then
year = osdate.year
else
year = args['سنة']
end
if args['شهر'] == nil then
month = osdate.month
else
local month = args['شهر']
end
return get_day_of_week(1, month, year)
end
function p.getMonthDays(frame)
local args = frame.args
local year = 0
local month = 0
local osdate = os.date('*t')
if args['سنة'] == nil then
year = osdate.year
else
year = args['سنة']
end
if args['شهر'] == nil then
month = osdate.month
else
local month = args['شهر']
end
return get_days_in_month(month, year)
end
-- for debuging with debug console
function p.getdaynumtest()
--args1 = 2013
--args2 = 1
local b = os.date('*t')--,os.time{year=yr,month=mnth+1,day=0})
--return b.year, b.month
return 'اليوم الأول من شهر:' .. mhnas[b.month].gen .. ' سنة' .. b.year .. ' يوم' .. hmera[get_day_of_week(1, b.month, b.year) ]
end
-- يعرض اليوم والتاريخ، مثل الإثنين, 5 سبتمبر 2016
-- يستخدم {{#invoke:DateFunctions|اليوم والتاريخ}}
p['اليوم والتاريخ'] = function ()
local osdate = os.date('*t')
return (hmera[osdate.wday-1] or hmera[7]) .. ', ' .. osdate.day .. ' ' .. mhnas[osdate.month]['gen'] .. ' ' .. osdate.year
end
-- يعرض التاريخ، مثل 5 سبتمبر 2016
-- يستخدم {{#invoke:DateFunctions|التاريخ}}
p['التاريخ'] = function () local osdate = os.date('*t') return osdate.day .. ' ' .. mhnas[osdate.month]['gen'] .. ' ' .. osdate.year end
-- يعرض اليوم إسما، مثل الأحد
-- يستخدم {{#invoke:DateFunctions|اليوم}}
p['اليوم'] = function () local osdate = os.date('*t') return (hmera[osdate.wday-1] or hmera[7]) end
-- يعرض التاريخ، مثل اليوم الأحد الموافق 5 سبتمبر 2016
-- يستخدم {{#invoke:DateFunctions|الموافق}}
p['الموافق'] = function ()
local osdate = os.date('*t')
return 'اليوم هو' .. (hmera[osdate.wday-1] or hmera[7]) .. ', ' .. 'الموافق' .. osdate.day .. ' ' .. mhnas[osdate.month]['gen'] .. ' ' .. osdate.year
end
-- يعرض تاريخ اليوم، مثل 5
-- يستخدم {{#invoke:DateFunctions|تاريخ اليوم}}
p['تاريخ اليوم'] = function ()
local osdate = os.date('*t')
return osdate.day end
-- يعرض الشهر الحالي، مثل أكتوبر
-- يستخدم {{#invoke:DateFunctions|الشهر الحالي}}
p['الشهر الحالي'] = function ()
local osdate = os.date('*t')
return mhnas[osdate.month]['gen'] end
-- يعرض السنة الحالية، مثل 2016
-- يستخدم {{#invoke:DateFunctions|السنة الحالية}}
p['السنة الحالية'] = function ()
local osdate = os.date('*t')
return osdate.year end
-- يعرض الشهر الهجري، مثل محرم أو رمضان
-- يستخدم {{#invoke:DateFunctions|الشهر الهجري}}
p['الشهر الهجري'] = function ()
local osdate = os.date('*t')
return Hijri[osdate.month]['gen']
end
-- يعرض السنة الهجرية الحالية حسب المعادلة: السنة الهجرية=السنة الميلادية-622*33/32
-- يستخدم {{#invoke:DateFunctions|السنة الهجرية}}
p['السنة الهجرية'] = function ()
local osdate = os.date('*t')
h= (osdate.year - 622) * 33 / 32
return math.floor(h)
end
-- يعرض السنة الهجرية الحالية حسب المعادلة: التاريخ الهجري=(1993-622)\0,97
-- يستخدم {{#invoke:DateFunctions|السنة الهجرية2}}
p['السنة الهجرية2'] = function ()
local osdate = os.date('*t')
h= (osdate.year - 622) / 0.97
return math.floor(h + 0.5)
end
-- يعرض الوقت
-- يستخدم {{#invoke:DateFunctions|الوقت}}
p['الوقت'] = function ()
local ostime = os.time('*t')
return os.time
end
return p