التابع Calendar.yeardatescalendar()‎ في بايثون

من موسوعة حسوب


يعيد التابع البيانات الخاصة بالسنة المعطاة، وتكون هذه البيانات جاهزة للتنسيق.

البنية العامة

yeardatescalendar(year, width=3)

المعاملات

year

السنة المطلوبة.

width

يحدّد المعامل width الحد الأقصى للشهور في كل صفّ، ويأخذ القيمة 3 كقيمة افتراضية.

القيمة المعادة

يعيد التابع البيانات الخاصة بالسنة المعطاة، وتكون هذه البيانات جاهزة للتنسيق. القيمة المعادة هي قائمة من صفوف rows الأشهر.

يتضمّن كل شهر 4 إلى 6 أسابيع ويتضمّن كل أسبوع ‎1-7 أيام، والأيام عبارة عن كائنات datetime.date.


أمثلة

يبين المثال التالي آلية عمل التابع:

>>> from calendar import Calendar
>>> cal = Calendar()
>>> cal.yeardatescalendar(2018)
[[[[datetime.date(2018, 1, 1), datetime.date(2018, 1, 2), datetime.date(2018, 1, 3), datetime.date(2018, 1, 4), datetime.date(2018, 1, 5), datetime.date(2018, 1, 6), datetime.date(2018, 1, 7)], [datetime.date(2018, 1, 8), datetime.date(2018, 1, 9), datetime.date(2018, 1, 10), datetime.date(2018, 1, 11), datetime.date(2018, 1, 12), datetime.date(2018, 1, 13), datetime.date(2018, 1, 14)], [datetime.date(2018, 1, 15), datetime.date(2018, 1, 16), datetime.date(2018, 1, 17), datetime.date(2018, 1, 18), datetime.date(2018, 1, 19), datetime.date(2018, 1, 20), datetime.date(2018, 1, 21)], [datetime.date(2018, 1, 22), datetime.date(2018, 1, 23), datetime.date(2018, 1, 24), datetime.date(2018, 1, 25), datetime.date(2018, 1, 26), datetime.date(2018, 1, 27), datetime.date(2018, 1, 28)], [datetime.date(2018, 1, 29), datetime.date(2018, 1, 30), datetime.date(2018, 1, 31), datetime.date(2018, 2, 1), datetime.date(2018, 2, 2), datetime.date(2018, 2, 3), datetime.date(2018, 2, 4)]], [[datetime.date(2018, 1, 29), datetime.date(2018, 1, 30), datetime.date(2018, 1, 31), datetime.date(2018, 2, 1), datetime.date(2018, 2, 2), datetime.date(2018, 2, 3), datetime.date(2018, 2, 4)], [datetime.date(2018, 2, 5), datetime.date(2018, 2, 6), datetime.date(2018, 2, 7), datetime.date(2018, 2, 8), datetime.date(2018, 2, 9), datetime.date(2018, 2, 10), datetime.date(2018, 2, 11)], [datetime.date(2018, 2, 12), datetime.date(2018, 2, 13), datetime.date(2018, 2, 14), datetime.date(2018, 2, 15), datetime.date(2018, 2, 16), datetime.date(2018, 2, 17), datetime.date(2018, 2, 18)], [datetime.date(2018, 2, 19), datetime.date(2018, 2, 20), datetime.date(2018, 2, 21), datetime.date(2018, 2, 22), datetime.date(2018, 2, 23), datetime.date(2018, 2, 24), datetime.date(2018, 2, 25)], [datetime.date(2018, 2, 26), datetime.date(2018, 2, 27), datetime.date(2018, 2, 28), datetime.date(2018, 3, 1), datetime.date(2018, 3, 2), datetime.date(2018, 3, 3), datetime.date(2018, 3, 4)]], [[datetime.date(2018, 2, 26), datetime.date(2018, 2, 27), datetime.date(2018, 2, 28), datetime.date(2018, 3, 1), datetime.date(2018, 3, 2), datetime.date(2018, 3, 3), datetime.date(2018, 3, 4)], [datetime.date(2018, 3, 5), datetime.date(2018, 3, 6), datetime.date(2018, 3, 7), datetime.date(2018, 3, 8), datetime.date(2018, 3, 9), datetime.date(2018, 3, 10), datetime.date(2018, 3, 11)], [datetime.date(2018, 3, 12), datetime.date(2018, 3, 13), datetime.date(2018, 3, 14), datetime.date(2018, 3, 15), datetime.date(2018, 3, 16), datetime.date(2018, 3, 17), datetime.date(2018, 3, 18)], [datetime.date(2018, 3, 19), datetime.date(2018, 3, 20), datetime.date(2018, 3, 21), datetime.date(2018, 3, 22), datetime.date(2018, 3, 23), datetime.date(2018, 3, 24), datetime.date(2018, 3, 25)], [datetime.date(2018, 3, 26), datetime.date(2018, 3, 27), datetime.date(2018, 3, 28), datetime.date(2018, 3, 29), datetime.date(2018, 3, 30), datetime.date(2018, 3, 31), datetime.date(2018, 4, 1)]]], [[[datetime.date(2018, 3, 26), datetime.date(2018, 3, 27), datetime.date(2018, 3, 28), datetime.date(2018, 3, 29), datetime.date(2018, 3, 30), datetime.date(2018, 3, 31), datetime.date(2018, 4, 1)], [datetime.date(2018, 4, 2), datetime.date(2018, 4, 3), datetime.date(2018, 4, 4), datetime.date(2018, 4, 5), datetime.date(2018, 4, 6), datetime.date(2018, 4, 7), datetime.date(2018, 4, 8)], [datetime.date(2018, 4, 9), datetime.date(2018, 4, 10), datetime.date(2018, 4, 11), datetime.date(2018, 4, 12), datetime.date(2018, 4, 13), datetime.date(2018, 4, 14), datetime.date(2018, 4, 15)], [datetime.date(2018, 4, 16), datetime.date(2018, 4, 17), datetime.date(2018, 4, 18), datetime.date(2018, 4, 19), datetime.date(2018, 4, 20), datetime.date(2018, 4, 21), datetime.date(2018, 4, 22)], [datetime.date(2018, 4, 23), datetime.date(2018, 4, 24), datetime.date(2018, 4, 25), datetime.date(2018, 4, 26), datetime.date(2018, 4, 27), datetime.date(2018, 4, 28), datetime.date(2018, 4, 29)], [datetime.date(2018, 4, 30), datetime.date(2018, 5, 1), datetime.date(2018, 5, 2), datetime.date(2018, 5, 3), datetime.date(2018, 5, 4), datetime.date(2018, 5, 5), datetime.date(2018, 5, 6)]], [[datetime.date(2018, 4, 30), datetime.date(2018, 5, 1), datetime.date(2018, 5, 2), datetime.date(2018, 5, 3), datetime.date(2018, 5, 4), datetime.date(2018, 5, 5), datetime.date(2018, 5, 6)], [datetime.date(2018, 5, 7), datetime.date(2018, 5, 8), datetime.date(2018, 5, 9), datetime.date(2018, 5, 10), datetime.date(2018, 5, 11), datetime.date(2018, 5, 12), datetime.date(2018, 5, 13)], [datetime.date(2018, 5, 14), datetime.date(2018, 5, 15), datetime.date(2018, 5, 16), datetime.date(2018, 5, 17), datetime.date(2018, 5, 18), datetime.date(2018, 5, 19), datetime.date(2018, 5, 20)], [datetime.date(2018, 5, 21), datetime.date(2018, 5, 22), datetime.date(2018, 5, 23), datetime.date(2018, 5, 24), datetime.date(2018, 5, 25), datetime.date(2018, 5, 26), datetime.date(2018, 5, 27)], [datetime.date(2018, 5, 28), datetime.date(2018, 5, 29), datetime.date(2018, 5, 30), datetime.date(2018, 5, 31), datetime.date(2018, 6, 1), datetime.date(2018, 6, 2), datetime.date(2018, 6, 3)]], [[datetime.date(2018, 5, 28), datetime.date(2018, 5, 29), datetime.date(2018, 5, 30), datetime.date(2018, 5, 31), datetime.date(2018, 6, 1), datetime.date(2018, 6, 2), datetime.date(2018, 6, 3)], [datetime.date(2018, 6, 4), datetime.date(2018, 6, 5), datetime.date(2018, 6, 6), datetime.date(2018, 6, 7), datetime.date(2018, 6, 8), datetime.date(2018, 6, 9), datetime.date(2018, 6, 10)], [datetime.date(2018, 6, 11), datetime.date(2018, 6, 12), datetime.date(2018, 6, 13), datetime.date(2018, 6, 14), datetime.date(2018, 6, 15), datetime.date(2018, 6, 16), datetime.date(2018, 6, 17)], [datetime.date(2018, 6, 18), datetime.date(2018, 6, 19), datetime.date(2018, 6, 20), datetime.date(2018, 6, 21), datetime.date(2018, 6, 22), datetime.date(2018, 6, 23), datetime.date(2018, 6, 24)], [datetime.date(2018, 6, 25), datetime.date(2018, 6, 26), datetime.date(2018, 6, 27), datetime.date(2018, 6, 28), datetime.date(2018, 6, 29), datetime.date(2018, 6, 30), datetime.date(2018, 7, 1)]]], [[[datetime.date(2018, 6, 25), datetime.date(2018, 6, 26), datetime.date(2018, 6, 27), datetime.date(2018, 6, 28), datetime.date(2018, 6, 29), datetime.date(2018, 6, 30), datetime.date(2018, 7, 1)], [datetime.date(2018, 7, 2), datetime.date(2018, 7, 3), datetime.date(2018, 7, 4), datetime.date(2018, 7, 5), datetime.date(2018, 7, 6), datetime.date(2018, 7, 7), datetime.date(2018, 7, 8)], [datetime.date(2018, 7, 9), datetime.date(2018, 7, 10), datetime.date(2018, 7, 11), datetime.date(2018, 7, 12), datetime.date(2018, 7, 13), datetime.date(2018, 7, 14), datetime.date(2018, 7, 15)], [datetime.date(2018, 7, 16), datetime.date(2018, 7, 17), datetime.date(2018, 7, 18), datetime.date(2018, 7, 19), datetime.date(2018, 7, 20), datetime.date(2018, 7, 21), datetime.date(2018, 7, 22)], [datetime.date(2018, 7, 23), datetime.date(2018, 7, 24), datetime.date(2018, 7, 25), datetime.date(2018, 7, 26), datetime.date(2018, 7, 27), datetime.date(2018, 7, 28), datetime.date(2018, 7, 29)], [datetime.date(2018, 7, 30), datetime.date(2018, 7, 31), datetime.date(2018, 8, 1), datetime.date(2018, 8, 2), datetime.date(2018, 8, 3), datetime.date(2018, 8, 4), datetime.date(2018, 8, 5)]], [[datetime.date(2018, 7, 30), datetime.date(2018, 7, 31), datetime.date(2018, 8, 1), datetime.date(2018, 8, 2), datetime.date(2018, 8, 3), datetime.date(2018, 8, 4), datetime.date(2018, 8, 5)], [datetime.date(2018, 8, 6), datetime.date(2018, 8, 7), datetime.date(2018, 8, 8), datetime.date(2018, 8, 9), datetime.date(2018, 8, 10), datetime.date(2018, 8, 11), datetime.date(2018, 8, 12)], [datetime.date(2018, 8, 13), datetime.date(2018, 8, 14), datetime.date(2018, 8, 15), datetime.date(2018, 8, 16), datetime.date(2018, 8, 17), datetime.date(2018, 8, 18), datetime.date(2018, 8, 19)], [datetime.date(2018, 8, 20), datetime.date(2018, 8, 21), datetime.date(2018, 8, 22), datetime.date(2018, 8, 23), datetime.date(2018, 8, 24), datetime.date(2018, 8, 25), datetime.date(2018, 8, 26)], [datetime.date(2018, 8, 27), datetime.date(2018, 8, 28), datetime.date(2018, 8, 29), datetime.date(2018, 8, 30), datetime.date(2018, 8, 31), datetime.date(2018, 9, 1), datetime.date(2018, 9, 2)]], [[datetime.date(2018, 8, 27), datetime.date(2018, 8, 28), datetime.date(2018, 8, 29), datetime.date(2018, 8, 30), datetime.date(2018, 8, 31), datetime.date(2018, 9, 1), datetime.date(2018, 9, 2)], [datetime.date(2018, 9, 3), datetime.date(2018, 9, 4), datetime.date(2018, 9, 5), datetime.date(2018, 9, 6), datetime.date(2018, 9, 7), datetime.date(2018, 9, 8), datetime.date(2018, 9, 9)], [datetime.date(2018, 9, 10), datetime.date(2018, 9, 11), datetime.date(2018, 9, 12), datetime.date(2018, 9, 13), datetime.date(2018, 9, 14), datetime.date(2018, 9, 15), datetime.date(2018, 9, 16)], [datetime.date(2018, 9, 17), datetime.date(2018, 9, 18), datetime.date(2018, 9, 19), datetime.date(2018, 9, 20), datetime.date(2018, 9, 21), datetime.date(2018, 9, 22), datetime.date(2018, 9, 23)], [datetime.date(2018, 9, 24), datetime.date(2018, 9, 25), datetime.date(2018, 9, 26), datetime.date(2018, 9, 27), datetime.date(2018, 9, 28), datetime.date(2018, 9, 29), datetime.date(2018, 9, 30)]]], [[[datetime.date(2018, 10, 1), datetime.date(2018, 10, 2), datetime.date(2018, 10, 3), datetime.date(2018, 10, 4), datetime.date(2018, 10, 5), datetime.date(2018, 10, 6), datetime.date(2018, 10, 7)], [datetime.date(2018, 10, 8), datetime.date(2018, 10, 9), datetime.date(2018, 10, 10), datetime.date(2018, 10, 11), datetime.date(2018, 10, 12), datetime.date(2018, 10, 13), datetime.date(2018, 10, 14)], [datetime.date(2018, 10, 15), datetime.date(2018, 10, 16), datetime.date(2018, 10, 17), datetime.date(2018, 10, 18), datetime.date(2018, 10, 19), datetime.date(2018, 10, 20), datetime.date(2018, 10, 21)], [datetime.date(2018, 10, 22), datetime.date(2018, 10, 23), datetime.date(2018, 10, 24), datetime.date(2018, 10, 25), datetime.date(2018, 10, 26), datetime.date(2018, 10, 27), datetime.date(2018, 10, 28)], [datetime.date(2018, 10, 29), datetime.date(2018, 10, 30), datetime.date(2018, 10, 31), datetime.date(2018, 11, 1), datetime.date(2018, 11, 2), datetime.date(2018, 11, 3), datetime.date(2018, 11, 4)]], [[datetime.date(2018, 10, 29), datetime.date(2018, 10, 30), datetime.date(2018, 10, 31), datetime.date(2018, 11, 1), datetime.date(2018, 11, 2), datetime.date(2018, 11, 3), datetime.date(2018, 11, 4)], [datetime.date(2018, 11, 5), datetime.date(2018, 11, 6), datetime.date(2018, 11, 7), datetime.date(2018, 11, 8), datetime.date(2018, 11, 9), datetime.date(2018, 11, 10), datetime.date(2018, 11, 11)], [datetime.date(2018, 11, 12), datetime.date(2018, 11, 13), datetime.date(2018, 11, 14), datetime.date(2018, 11, 15), datetime.date(2018, 11, 16), datetime.date(2018, 11, 17), datetime.date(2018, 11, 18)], [datetime.date(2018, 11, 19), datetime.date(2018, 11, 20), datetime.date(2018, 11, 21), datetime.date(2018, 11, 22), datetime.date(2018, 11, 23), datetime.date(2018, 11, 24), datetime.date(2018, 11, 25)], [datetime.date(2018, 11, 26), datetime.date(2018, 11, 27), datetime.date(2018, 11, 28), datetime.date(2018, 11, 29), datetime.date(2018, 11, 30), datetime.date(2018, 12, 1), datetime.date(2018, 12, 2)]], [[datetime.date(2018, 11, 26), datetime.date(2018, 11, 27), datetime.date(2018, 11, 28), datetime.date(2018, 11, 29), datetime.date(2018, 11, 30), datetime.date(2018, 12, 1), datetime.date(2018, 12, 2)], [datetime.date(2018, 12, 3), datetime.date(2018, 12, 4), datetime.date(2018, 12, 5), datetime.date(2018, 12, 6), datetime.date(2018, 12, 7), datetime.date(2018, 12, 8), datetime.date(2018, 12, 9)], [datetime.date(2018, 12, 10), datetime.date(2018, 12, 11), datetime.date(2018, 12, 12), datetime.date(2018, 12, 13), datetime.date(2018, 12, 14), datetime.date(2018, 12, 15), datetime.date(2018, 12, 16)], [datetime.date(2018, 12, 17), datetime.date(2018, 12, 18), datetime.date(2018, 12, 19), datetime.date(2018, 12, 20), datetime.date(2018, 12, 21), datetime.date(2018, 12, 22), datetime.date(2018, 12, 23)], [datetime.date(2018, 12, 24), datetime.date(2018, 12, 25), datetime.date(2018, 12, 26), datetime.date(2018, 12, 27), datetime.date(2018, 12, 28), datetime.date(2018, 12, 29), datetime.date(2018, 12, 30)], [datetime.date(2018, 12, 31), datetime.date(2019, 1, 1), datetime.date(2019, 1, 2), datetime.date(2019, 1, 3), datetime.date(2019, 1, 4), datetime.date(2019, 1, 5), datetime.date(2019, 1, 6)]]]]

انظر أيضًا

  • التابع yeardays2calendar()‎: يعيد التابع البيانات الخاصة بالسنة المعطاة، وتكون البيانات جاهزة للتنسيق، وتكون العناصر في قوائم الأسابيع عبارة عن صفوف تتضمّن أعداد الأيام وأعداد أيام الأسبوع.
  • التابع yeardayscalendar()‎: يعيد التابع البيانات الخاصة بالسنة المعطاة، وتكون البيانات جاهزة للتنسيق، وتكون العناصر في قوائم الأسابيع عبارة عن صفوف تتضمّن أعداد الأيام.

مصادر

صفحة General calendar-related functions في توثيق بايثون الرسمي.