تبديل البحث
بحث
تبديل القائمة
1.2M
95
256
3.5M
أرابيكا
الموسوعة
الصفحة الرئيسة
الأحداث الجارية
أحدث التغييرات
أحدث التغييرات الأساسية
صفحات خاصة
رفع ملف
تصفح
المواضيع
أبجدي
بوابات
مقالة عشوائية
تصفح من غير إنترنت
مشاركة
تواصل مع أرابيكا
مساعدة
الميدان
sitesupport
في مشاريع أخرى
Toggle preferences menu
إشعارات
تبديل القائمة الشخصية
غير مسجل للدخول
سيكون عنوان الآيبي الخاص بك مرئيًا للعامة إذا قمت بإجراء أي تعديلات.
user-interface-preferences
أدوات شخصية
إنشاء حساب
دخول
عرض مصدر وحدة:مدة
من أرابيكا، الموسوعة العربية الحرة
معاينة
اقرأ
عرض المصدر
تاريخ
associated-pages
وحدة
نقاش
المزيد من الإجراءات
→
وحدة:مدة
ليس لك صلاحية تعديل هذه الصفحة، للسبب التالي:
الفعل الذي اعتزمته مقصور على المستخدمين أعضاء المجموعة:
مستخدمون
.
نص الصفحة:
local p = {} -- liste des mois, écriture exacte et simplifiée, en minuscule local liste_mois = { { "يناير", "جانفي", "janvier", "jan.", "janv.", "jan", "janv", "january", nJour = 31 }, { "فبراير", "فيفري", "février", "fevrier", "fev.", "fev", "fév.", "fév", "february", nJour = 28 }, { "مارس", "mars", "mar.", "mar", "march", nJour = 31 }, { "أبريل", "أفريل", "avril", "avr.", "avr", "apr", "april", nJour = 30 }, { "مايو", "ماي", "mai", "may", nJour = 31 }, { "يونيو", "جوان", "juin", "jun", "june", nJour = 30 }, { "يوليو", "جويلية", "juillet", "juil.", "juil", "juill.", "juill", "jul", "july", nJour = 31 }, { "أغسطس", "أوت", "août", "aout", "aou", "aug", "august", nJour = 31 }, { "سبتمبر", "septembre", "sept.", "sept", "sep.", "sep", "september", nJour = 30 }, { "أكتوبر", "octobre", "oct.", "oct", "october", nJour = 31 }, { "نوفمبر", "novembre", "nov.", "nov", "november", nJour = 30 }, { "ديسمبر", "décembre", "decembre", "déc.", "dec.", "dec", "déc", "december", nJour = 31 }, } local function joursMois( m, a ) a = a or 1 if m == 0 then return 31 elseif m == 2 then b = ( a % 4 == 0 ) and ( ( a % 100 ~= 0 ) or ( a % 400 == 0 ) ) return 28 + ( b and 1 or 0 ) else return liste_mois[m].nJour end end function erreur( texte ) local cat = '[[Catégorie:Page utilisant un modèle avec une syntaxe erronée|Durée]]' local message = '<span class="error">erreur : ' .. texte .. '</span>' local ns = mw.title.getCurrentTitle().namespace if ns == 0 then return message .. cat else return message end end --- local function determinationMois( mois ) if tonumber( mois ) then local num = math.floor( tonumber( mois ) ) if num > 0 and num <= 12 then return num end elseif type( mois ) == 'string' and mw.text.trim( mois ) ~= '' then local nom = mw.ustring.lower( mois ) for num = 1, 12 do local i = 1 while liste_mois[num][i] do if liste_mois[num][i] == nom then return num end i = i + 1 end end end end function p._duree( args ) local maintenant = os.date( '!*t' ) local fuseau = mw.getContentLanguage():formatDate("Z", nil, true)/3600 if maintenant.hour + fuseau > 23 then maintenant.day = maintenant.day + 1 end local params = {} local precision = 'يوم' local jour1 = tonumber( args[1] ) if not jour1 then precision = 'شهر' jour1 = maintenant.day end local mois1 = determinationMois( args[2] ) if not mois1 then if precision == 'شهر' then precision = 'سنة' mois1 = maintenant.month else return erreur( 'شهر غير مقبول (' .. ( args[2] or '' ) .. ')' ) end end local annee1 = tonumber( args[3] ) if not annee1 then if precision == 'سنة' then return else annee1 = maintenant.year end end local jour2 = tonumber( args[4] ) or maintenant.day local mois2 = determinationMois( args[5] ) or maintenant.month local annee2 = tonumber( args[6]) or maintenant.year local tri = os.difftime( os.time{ year = annee2, month = mois2, day = jour2 }, os.time{ year = annee1, month = mois1, day = jour1 } ) / 86400 if tri < 0 then return erreur( 'مدة أصغر من 0' ) end tri = 0 .. tostring( tri ) tri = string.rep( '&', 16 - #tri ) .. tri local njour = jour2 - jour1 local nmois = mois2 - mois1 local nannee = annee2 - annee1 if njour < 0 then nmois = nmois - 1 njour = njour + joursMois( mois2 - 1, annee2 ) end if nmois < 0 then nannee = nannee - 1 nmois = nmois + 12 end local result = {} local function add( nombre, singulier, pluriel, deux, un ) if nombre > 0 and nombre ~= 2 and nombre ~= 1 then local texte = pluriel if nombre>10 then texte = singulier end table.insert( result, nombre .. ' ' .. texte ) else if nombre == 2 then table.insert( result, deux) end if nombre == 1 then table.insert( result, un ) end end end add( nannee, 'سنةً' , 'سنواتٍ' , 'سنتان' , 'سنةً واحدةً') if precision ~= 'سنة' then add( nmois , 'شهرًا' , 'أشهرٍ' ,'شهران' ,'شهرًا واحدًا') end if precision == 'يوم' then add( njour , 'يومًا' ,'أيامٍ' , 'يومان' ,'يومًا واحدًا') end if #result == 0 then result[1] = 'أقل من ' .. precision tri = 0 end return mw.text.tag{ name = 'span', attrs = { class = 'datasortkey', ['data-sort-value'] = tri }, content = mw.text.listToText( result, ' و', ' و' ) } end function p.duree( frame ) local args = frame:getParent().args for i = 1, 6 do if tonumber( args[i] ) == 0 then args[i] = '' end end return p._duree( args ) end return p
6 تضمينات في هذه الصفحة
وحدة:Arguments
(
عرض المصدر
)
وحدة:توثيق
(
عرض المصدر
)
وحدة:توثيق/styles.css
(
عرض المصدر
)
وحدة:توثيق/ضبط
(
عرض المصدر
)
وحدة:مدة
(
عرض المصدر
)
وحدة:مدة/شرح
(
عرض المصدر
)
ارجع إلى
وحدة:مدة
.
عرض مصدر وحدة:مدة
من أرابيكا، الموسوعة العربية الحرة