17db96d56Sopenharmony_ci:mod:`calendar` --- General calendar-related functions 27db96d56Sopenharmony_ci====================================================== 37db96d56Sopenharmony_ci 47db96d56Sopenharmony_ci.. module:: calendar 57db96d56Sopenharmony_ci :synopsis: Functions for working with calendars, including some emulation 67db96d56Sopenharmony_ci of the Unix cal program. 77db96d56Sopenharmony_ci 87db96d56Sopenharmony_ci.. sectionauthor:: Drew Csillag <drew_csillag@geocities.com> 97db96d56Sopenharmony_ci 107db96d56Sopenharmony_ci**Source code:** :source:`Lib/calendar.py` 117db96d56Sopenharmony_ci 127db96d56Sopenharmony_ci-------------- 137db96d56Sopenharmony_ci 147db96d56Sopenharmony_ciThis module allows you to output calendars like the Unix :program:`cal` program, 157db96d56Sopenharmony_ciand provides additional useful functions related to the calendar. By default, 167db96d56Sopenharmony_cithese calendars have Monday as the first day of the week, and Sunday as the last 177db96d56Sopenharmony_ci(the European convention). Use :func:`setfirstweekday` to set the first day of 187db96d56Sopenharmony_cithe week to Sunday (6) or to any other weekday. Parameters that specify dates 197db96d56Sopenharmony_ciare given as integers. For related 207db96d56Sopenharmony_cifunctionality, see also the :mod:`datetime` and :mod:`time` modules. 217db96d56Sopenharmony_ci 227db96d56Sopenharmony_ciThe functions and classes defined in this module 237db96d56Sopenharmony_ciuse an idealized calendar, the current Gregorian calendar extended indefinitely 247db96d56Sopenharmony_ciin both directions. This matches the definition of the "proleptic Gregorian" 257db96d56Sopenharmony_cicalendar in Dershowitz and Reingold's book "Calendrical Calculations", where 267db96d56Sopenharmony_ciit's the base calendar for all computations. Zero and negative years are 277db96d56Sopenharmony_ciinterpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is 287db96d56Sopenharmony_ci2 BC, and so on. 297db96d56Sopenharmony_ci 307db96d56Sopenharmony_ci 317db96d56Sopenharmony_ci.. class:: Calendar(firstweekday=0) 327db96d56Sopenharmony_ci 337db96d56Sopenharmony_ci Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the 347db96d56Sopenharmony_ci first day of the week. :const:`MONDAY` is ``0`` (the default), :const:`SUNDAY` is ``6``. 357db96d56Sopenharmony_ci 367db96d56Sopenharmony_ci A :class:`Calendar` object provides several methods that can be used for 377db96d56Sopenharmony_ci preparing the calendar data for formatting. This class doesn't do any formatting 387db96d56Sopenharmony_ci itself. This is the job of subclasses. 397db96d56Sopenharmony_ci 407db96d56Sopenharmony_ci 417db96d56Sopenharmony_ci :class:`Calendar` instances have the following methods: 427db96d56Sopenharmony_ci 437db96d56Sopenharmony_ci .. method:: iterweekdays() 447db96d56Sopenharmony_ci 457db96d56Sopenharmony_ci Return an iterator for the week day numbers that will be used for one 467db96d56Sopenharmony_ci week. The first value from the iterator will be the same as the value of 477db96d56Sopenharmony_ci the :attr:`firstweekday` property. 487db96d56Sopenharmony_ci 497db96d56Sopenharmony_ci 507db96d56Sopenharmony_ci .. method:: itermonthdates(year, month) 517db96d56Sopenharmony_ci 527db96d56Sopenharmony_ci Return an iterator for the month *month* (1--12) in the year *year*. This 537db96d56Sopenharmony_ci iterator will return all days (as :class:`datetime.date` objects) for the 547db96d56Sopenharmony_ci month and all days before the start of the month or after the end of the 557db96d56Sopenharmony_ci month that are required to get a complete week. 567db96d56Sopenharmony_ci 577db96d56Sopenharmony_ci 587db96d56Sopenharmony_ci .. method:: itermonthdays(year, month) 597db96d56Sopenharmony_ci 607db96d56Sopenharmony_ci Return an iterator for the month *month* in the year *year* similar to 617db96d56Sopenharmony_ci :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` 627db96d56Sopenharmony_ci range. Days returned will simply be day of the month numbers. For the 637db96d56Sopenharmony_ci days outside of the specified month, the day number is ``0``. 647db96d56Sopenharmony_ci 657db96d56Sopenharmony_ci 667db96d56Sopenharmony_ci .. method:: itermonthdays2(year, month) 677db96d56Sopenharmony_ci 687db96d56Sopenharmony_ci Return an iterator for the month *month* in the year *year* similar to 697db96d56Sopenharmony_ci :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` 707db96d56Sopenharmony_ci range. Days returned will be tuples consisting of a day of the month 717db96d56Sopenharmony_ci number and a week day number. 727db96d56Sopenharmony_ci 737db96d56Sopenharmony_ci 747db96d56Sopenharmony_ci .. method:: itermonthdays3(year, month) 757db96d56Sopenharmony_ci 767db96d56Sopenharmony_ci Return an iterator for the month *month* in the year *year* similar to 777db96d56Sopenharmony_ci :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` 787db96d56Sopenharmony_ci range. Days returned will be tuples consisting of a year, a month and a day 797db96d56Sopenharmony_ci of the month numbers. 807db96d56Sopenharmony_ci 817db96d56Sopenharmony_ci .. versionadded:: 3.7 827db96d56Sopenharmony_ci 837db96d56Sopenharmony_ci 847db96d56Sopenharmony_ci .. method:: itermonthdays4(year, month) 857db96d56Sopenharmony_ci 867db96d56Sopenharmony_ci Return an iterator for the month *month* in the year *year* similar to 877db96d56Sopenharmony_ci :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` 887db96d56Sopenharmony_ci range. Days returned will be tuples consisting of a year, a month, a day 897db96d56Sopenharmony_ci of the month, and a day of the week numbers. 907db96d56Sopenharmony_ci 917db96d56Sopenharmony_ci .. versionadded:: 3.7 927db96d56Sopenharmony_ci 937db96d56Sopenharmony_ci 947db96d56Sopenharmony_ci .. method:: monthdatescalendar(year, month) 957db96d56Sopenharmony_ci 967db96d56Sopenharmony_ci Return a list of the weeks in the month *month* of the *year* as full 977db96d56Sopenharmony_ci weeks. Weeks are lists of seven :class:`datetime.date` objects. 987db96d56Sopenharmony_ci 997db96d56Sopenharmony_ci 1007db96d56Sopenharmony_ci .. method:: monthdays2calendar(year, month) 1017db96d56Sopenharmony_ci 1027db96d56Sopenharmony_ci Return a list of the weeks in the month *month* of the *year* as full 1037db96d56Sopenharmony_ci weeks. Weeks are lists of seven tuples of day numbers and weekday 1047db96d56Sopenharmony_ci numbers. 1057db96d56Sopenharmony_ci 1067db96d56Sopenharmony_ci 1077db96d56Sopenharmony_ci .. method:: monthdayscalendar(year, month) 1087db96d56Sopenharmony_ci 1097db96d56Sopenharmony_ci Return a list of the weeks in the month *month* of the *year* as full 1107db96d56Sopenharmony_ci weeks. Weeks are lists of seven day numbers. 1117db96d56Sopenharmony_ci 1127db96d56Sopenharmony_ci 1137db96d56Sopenharmony_ci .. method:: yeardatescalendar(year, width=3) 1147db96d56Sopenharmony_ci 1157db96d56Sopenharmony_ci Return the data for the specified year ready for formatting. The return 1167db96d56Sopenharmony_ci value is a list of month rows. Each month row contains up to *width* 1177db96d56Sopenharmony_ci months (defaulting to 3). Each month contains between 4 and 6 weeks and 1187db96d56Sopenharmony_ci each week contains 1--7 days. Days are :class:`datetime.date` objects. 1197db96d56Sopenharmony_ci 1207db96d56Sopenharmony_ci 1217db96d56Sopenharmony_ci .. method:: yeardays2calendar(year, width=3) 1227db96d56Sopenharmony_ci 1237db96d56Sopenharmony_ci Return the data for the specified year ready for formatting (similar to 1247db96d56Sopenharmony_ci :meth:`yeardatescalendar`). Entries in the week lists are tuples of day 1257db96d56Sopenharmony_ci numbers and weekday numbers. Day numbers outside this month are zero. 1267db96d56Sopenharmony_ci 1277db96d56Sopenharmony_ci 1287db96d56Sopenharmony_ci .. method:: yeardayscalendar(year, width=3) 1297db96d56Sopenharmony_ci 1307db96d56Sopenharmony_ci Return the data for the specified year ready for formatting (similar to 1317db96d56Sopenharmony_ci :meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day 1327db96d56Sopenharmony_ci numbers outside this month are zero. 1337db96d56Sopenharmony_ci 1347db96d56Sopenharmony_ci 1357db96d56Sopenharmony_ci.. class:: TextCalendar(firstweekday=0) 1367db96d56Sopenharmony_ci 1377db96d56Sopenharmony_ci This class can be used to generate plain text calendars. 1387db96d56Sopenharmony_ci 1397db96d56Sopenharmony_ci :class:`TextCalendar` instances have the following methods: 1407db96d56Sopenharmony_ci 1417db96d56Sopenharmony_ci .. method:: formatmonth(theyear, themonth, w=0, l=0) 1427db96d56Sopenharmony_ci 1437db96d56Sopenharmony_ci Return a month's calendar in a multi-line string. If *w* is provided, it 1447db96d56Sopenharmony_ci specifies the width of the date columns, which are centered. If *l* is 1457db96d56Sopenharmony_ci given, it specifies the number of lines that each week will use. Depends 1467db96d56Sopenharmony_ci on the first weekday as specified in the constructor or set by the 1477db96d56Sopenharmony_ci :meth:`setfirstweekday` method. 1487db96d56Sopenharmony_ci 1497db96d56Sopenharmony_ci 1507db96d56Sopenharmony_ci .. method:: prmonth(theyear, themonth, w=0, l=0) 1517db96d56Sopenharmony_ci 1527db96d56Sopenharmony_ci Print a month's calendar as returned by :meth:`formatmonth`. 1537db96d56Sopenharmony_ci 1547db96d56Sopenharmony_ci 1557db96d56Sopenharmony_ci .. method:: formatyear(theyear, w=2, l=1, c=6, m=3) 1567db96d56Sopenharmony_ci 1577db96d56Sopenharmony_ci Return a *m*-column calendar for an entire year as a multi-line string. 1587db96d56Sopenharmony_ci Optional parameters *w*, *l*, and *c* are for date column width, lines per 1597db96d56Sopenharmony_ci week, and number of spaces between month columns, respectively. Depends on 1607db96d56Sopenharmony_ci the first weekday as specified in the constructor or set by the 1617db96d56Sopenharmony_ci :meth:`setfirstweekday` method. The earliest year for which a calendar 1627db96d56Sopenharmony_ci can be generated is platform-dependent. 1637db96d56Sopenharmony_ci 1647db96d56Sopenharmony_ci 1657db96d56Sopenharmony_ci .. method:: pryear(theyear, w=2, l=1, c=6, m=3) 1667db96d56Sopenharmony_ci 1677db96d56Sopenharmony_ci Print the calendar for an entire year as returned by :meth:`formatyear`. 1687db96d56Sopenharmony_ci 1697db96d56Sopenharmony_ci 1707db96d56Sopenharmony_ci.. class:: HTMLCalendar(firstweekday=0) 1717db96d56Sopenharmony_ci 1727db96d56Sopenharmony_ci This class can be used to generate HTML calendars. 1737db96d56Sopenharmony_ci 1747db96d56Sopenharmony_ci 1757db96d56Sopenharmony_ci :class:`!HTMLCalendar` instances have the following methods: 1767db96d56Sopenharmony_ci 1777db96d56Sopenharmony_ci .. method:: formatmonth(theyear, themonth, withyear=True) 1787db96d56Sopenharmony_ci 1797db96d56Sopenharmony_ci Return a month's calendar as an HTML table. If *withyear* is true the year 1807db96d56Sopenharmony_ci will be included in the header, otherwise just the month name will be 1817db96d56Sopenharmony_ci used. 1827db96d56Sopenharmony_ci 1837db96d56Sopenharmony_ci 1847db96d56Sopenharmony_ci .. method:: formatyear(theyear, width=3) 1857db96d56Sopenharmony_ci 1867db96d56Sopenharmony_ci Return a year's calendar as an HTML table. *width* (defaulting to 3) 1877db96d56Sopenharmony_ci specifies the number of months per row. 1887db96d56Sopenharmony_ci 1897db96d56Sopenharmony_ci 1907db96d56Sopenharmony_ci .. method:: formatyearpage(theyear, width=3, css='calendar.css', encoding=None) 1917db96d56Sopenharmony_ci 1927db96d56Sopenharmony_ci Return a year's calendar as a complete HTML page. *width* (defaulting to 1937db96d56Sopenharmony_ci 3) specifies the number of months per row. *css* is the name for the 1947db96d56Sopenharmony_ci cascading style sheet to be used. :const:`None` can be passed if no style 1957db96d56Sopenharmony_ci sheet should be used. *encoding* specifies the encoding to be used for the 1967db96d56Sopenharmony_ci output (defaulting to the system default encoding). 1977db96d56Sopenharmony_ci 1987db96d56Sopenharmony_ci 1997db96d56Sopenharmony_ci :class:`!HTMLCalendar` has the following attributes you can override to 2007db96d56Sopenharmony_ci customize the CSS classes used by the calendar: 2017db96d56Sopenharmony_ci 2027db96d56Sopenharmony_ci .. attribute:: cssclasses 2037db96d56Sopenharmony_ci 2047db96d56Sopenharmony_ci A list of CSS classes used for each weekday. The default class list is:: 2057db96d56Sopenharmony_ci 2067db96d56Sopenharmony_ci cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] 2077db96d56Sopenharmony_ci 2087db96d56Sopenharmony_ci more styles can be added for each day:: 2097db96d56Sopenharmony_ci 2107db96d56Sopenharmony_ci cssclasses = ["mon text-bold", "tue", "wed", "thu", "fri", "sat", "sun red"] 2117db96d56Sopenharmony_ci 2127db96d56Sopenharmony_ci Note that the length of this list must be seven items. 2137db96d56Sopenharmony_ci 2147db96d56Sopenharmony_ci 2157db96d56Sopenharmony_ci .. attribute:: cssclass_noday 2167db96d56Sopenharmony_ci 2177db96d56Sopenharmony_ci The CSS class for a weekday occurring in the previous or coming month. 2187db96d56Sopenharmony_ci 2197db96d56Sopenharmony_ci .. versionadded:: 3.7 2207db96d56Sopenharmony_ci 2217db96d56Sopenharmony_ci 2227db96d56Sopenharmony_ci .. attribute:: cssclasses_weekday_head 2237db96d56Sopenharmony_ci 2247db96d56Sopenharmony_ci A list of CSS classes used for weekday names in the header row. 2257db96d56Sopenharmony_ci The default is the same as :attr:`cssclasses`. 2267db96d56Sopenharmony_ci 2277db96d56Sopenharmony_ci .. versionadded:: 3.7 2287db96d56Sopenharmony_ci 2297db96d56Sopenharmony_ci 2307db96d56Sopenharmony_ci .. attribute:: cssclass_month_head 2317db96d56Sopenharmony_ci 2327db96d56Sopenharmony_ci The month's head CSS class (used by :meth:`formatmonthname`). 2337db96d56Sopenharmony_ci The default value is ``"month"``. 2347db96d56Sopenharmony_ci 2357db96d56Sopenharmony_ci .. versionadded:: 3.7 2367db96d56Sopenharmony_ci 2377db96d56Sopenharmony_ci 2387db96d56Sopenharmony_ci .. attribute:: cssclass_month 2397db96d56Sopenharmony_ci 2407db96d56Sopenharmony_ci The CSS class for the whole month's table (used by :meth:`formatmonth`). 2417db96d56Sopenharmony_ci The default value is ``"month"``. 2427db96d56Sopenharmony_ci 2437db96d56Sopenharmony_ci .. versionadded:: 3.7 2447db96d56Sopenharmony_ci 2457db96d56Sopenharmony_ci 2467db96d56Sopenharmony_ci .. attribute:: cssclass_year 2477db96d56Sopenharmony_ci 2487db96d56Sopenharmony_ci The CSS class for the whole year's table of tables (used by 2497db96d56Sopenharmony_ci :meth:`formatyear`). The default value is ``"year"``. 2507db96d56Sopenharmony_ci 2517db96d56Sopenharmony_ci .. versionadded:: 3.7 2527db96d56Sopenharmony_ci 2537db96d56Sopenharmony_ci 2547db96d56Sopenharmony_ci .. attribute:: cssclass_year_head 2557db96d56Sopenharmony_ci 2567db96d56Sopenharmony_ci The CSS class for the table head for the whole year (used by 2577db96d56Sopenharmony_ci :meth:`formatyear`). The default value is ``"year"``. 2587db96d56Sopenharmony_ci 2597db96d56Sopenharmony_ci .. versionadded:: 3.7 2607db96d56Sopenharmony_ci 2617db96d56Sopenharmony_ci 2627db96d56Sopenharmony_ci Note that although the naming for the above described class attributes is 2637db96d56Sopenharmony_ci singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the 2647db96d56Sopenharmony_ci single CSS class with a space separated list of CSS classes, for example:: 2657db96d56Sopenharmony_ci 2667db96d56Sopenharmony_ci "text-bold text-red" 2677db96d56Sopenharmony_ci 2687db96d56Sopenharmony_ci Here is an example how :class:`!HTMLCalendar` can be customized:: 2697db96d56Sopenharmony_ci 2707db96d56Sopenharmony_ci class CustomHTMLCal(calendar.HTMLCalendar): 2717db96d56Sopenharmony_ci cssclasses = [style + " text-nowrap" for style in 2727db96d56Sopenharmony_ci calendar.HTMLCalendar.cssclasses] 2737db96d56Sopenharmony_ci cssclass_month_head = "text-center month-head" 2747db96d56Sopenharmony_ci cssclass_month = "text-center month" 2757db96d56Sopenharmony_ci cssclass_year = "text-italic lead" 2767db96d56Sopenharmony_ci 2777db96d56Sopenharmony_ci 2787db96d56Sopenharmony_ci.. class:: LocaleTextCalendar(firstweekday=0, locale=None) 2797db96d56Sopenharmony_ci 2807db96d56Sopenharmony_ci This subclass of :class:`TextCalendar` can be passed a locale name in the 2817db96d56Sopenharmony_ci constructor and will return month and weekday names in the specified locale. 2827db96d56Sopenharmony_ci 2837db96d56Sopenharmony_ci 2847db96d56Sopenharmony_ci.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None) 2857db96d56Sopenharmony_ci 2867db96d56Sopenharmony_ci This subclass of :class:`HTMLCalendar` can be passed a locale name in the 2877db96d56Sopenharmony_ci constructor and will return month and weekday names in the specified 2887db96d56Sopenharmony_ci locale. 2897db96d56Sopenharmony_ci 2907db96d56Sopenharmony_ci.. note:: 2917db96d56Sopenharmony_ci 2927db96d56Sopenharmony_ci The constructor, :meth:`formatweekday` and :meth:`formatmonthname` methods 2937db96d56Sopenharmony_ci of these two classes temporarily change the ``LC_TIME`` locale to the given 2947db96d56Sopenharmony_ci *locale*. Because the current locale is a process-wide setting, they are 2957db96d56Sopenharmony_ci not thread-safe. 2967db96d56Sopenharmony_ci 2977db96d56Sopenharmony_ci 2987db96d56Sopenharmony_ciFor simple text calendars this module provides the following functions. 2997db96d56Sopenharmony_ci 3007db96d56Sopenharmony_ci.. function:: setfirstweekday(weekday) 3017db96d56Sopenharmony_ci 3027db96d56Sopenharmony_ci Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The 3037db96d56Sopenharmony_ci values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:`THURSDAY`, 3047db96d56Sopenharmony_ci :const:`FRIDAY`, :const:`SATURDAY`, and :const:`SUNDAY` are provided for 3057db96d56Sopenharmony_ci convenience. For example, to set the first weekday to Sunday:: 3067db96d56Sopenharmony_ci 3077db96d56Sopenharmony_ci import calendar 3087db96d56Sopenharmony_ci calendar.setfirstweekday(calendar.SUNDAY) 3097db96d56Sopenharmony_ci 3107db96d56Sopenharmony_ci 3117db96d56Sopenharmony_ci.. function:: firstweekday() 3127db96d56Sopenharmony_ci 3137db96d56Sopenharmony_ci Returns the current setting for the weekday to start each week. 3147db96d56Sopenharmony_ci 3157db96d56Sopenharmony_ci 3167db96d56Sopenharmony_ci.. function:: isleap(year) 3177db96d56Sopenharmony_ci 3187db96d56Sopenharmony_ci Returns :const:`True` if *year* is a leap year, otherwise :const:`False`. 3197db96d56Sopenharmony_ci 3207db96d56Sopenharmony_ci 3217db96d56Sopenharmony_ci.. function:: leapdays(y1, y2) 3227db96d56Sopenharmony_ci 3237db96d56Sopenharmony_ci Returns the number of leap years in the range from *y1* to *y2* (exclusive), 3247db96d56Sopenharmony_ci where *y1* and *y2* are years. 3257db96d56Sopenharmony_ci 3267db96d56Sopenharmony_ci This function works for ranges spanning a century change. 3277db96d56Sopenharmony_ci 3287db96d56Sopenharmony_ci 3297db96d56Sopenharmony_ci.. function:: weekday(year, month, day) 3307db96d56Sopenharmony_ci 3317db96d56Sopenharmony_ci Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), 3327db96d56Sopenharmony_ci *month* (``1``--``12``), *day* (``1``--``31``). 3337db96d56Sopenharmony_ci 3347db96d56Sopenharmony_ci 3357db96d56Sopenharmony_ci.. function:: weekheader(n) 3367db96d56Sopenharmony_ci 3377db96d56Sopenharmony_ci Return a header containing abbreviated weekday names. *n* specifies the width in 3387db96d56Sopenharmony_ci characters for one weekday. 3397db96d56Sopenharmony_ci 3407db96d56Sopenharmony_ci 3417db96d56Sopenharmony_ci.. function:: monthrange(year, month) 3427db96d56Sopenharmony_ci 3437db96d56Sopenharmony_ci Returns weekday of first day of the month and number of days in month, for the 3447db96d56Sopenharmony_ci specified *year* and *month*. 3457db96d56Sopenharmony_ci 3467db96d56Sopenharmony_ci 3477db96d56Sopenharmony_ci.. function:: monthcalendar(year, month) 3487db96d56Sopenharmony_ci 3497db96d56Sopenharmony_ci Returns a matrix representing a month's calendar. Each row represents a week; 3507db96d56Sopenharmony_ci days outside of the month are represented by zeros. Each week begins with Monday 3517db96d56Sopenharmony_ci unless set by :func:`setfirstweekday`. 3527db96d56Sopenharmony_ci 3537db96d56Sopenharmony_ci 3547db96d56Sopenharmony_ci.. function:: prmonth(theyear, themonth, w=0, l=0) 3557db96d56Sopenharmony_ci 3567db96d56Sopenharmony_ci Prints a month's calendar as returned by :func:`month`. 3577db96d56Sopenharmony_ci 3587db96d56Sopenharmony_ci 3597db96d56Sopenharmony_ci.. function:: month(theyear, themonth, w=0, l=0) 3607db96d56Sopenharmony_ci 3617db96d56Sopenharmony_ci Returns a month's calendar in a multi-line string using the :meth:`formatmonth` 3627db96d56Sopenharmony_ci of the :class:`TextCalendar` class. 3637db96d56Sopenharmony_ci 3647db96d56Sopenharmony_ci 3657db96d56Sopenharmony_ci.. function:: prcal(year, w=0, l=0, c=6, m=3) 3667db96d56Sopenharmony_ci 3677db96d56Sopenharmony_ci Prints the calendar for an entire year as returned by :func:`calendar`. 3687db96d56Sopenharmony_ci 3697db96d56Sopenharmony_ci 3707db96d56Sopenharmony_ci.. function:: calendar(year, w=2, l=1, c=6, m=3) 3717db96d56Sopenharmony_ci 3727db96d56Sopenharmony_ci Returns a 3-column calendar for an entire year as a multi-line string using 3737db96d56Sopenharmony_ci the :meth:`formatyear` of the :class:`TextCalendar` class. 3747db96d56Sopenharmony_ci 3757db96d56Sopenharmony_ci 3767db96d56Sopenharmony_ci.. function:: timegm(tuple) 3777db96d56Sopenharmony_ci 3787db96d56Sopenharmony_ci An unrelated but handy function that takes a time tuple such as returned by 3797db96d56Sopenharmony_ci the :func:`~time.gmtime` function in the :mod:`time` module, and returns the 3807db96d56Sopenharmony_ci corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX 3817db96d56Sopenharmony_ci encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each others' 3827db96d56Sopenharmony_ci inverse. 3837db96d56Sopenharmony_ci 3847db96d56Sopenharmony_ci 3857db96d56Sopenharmony_ciThe :mod:`calendar` module exports the following data attributes: 3867db96d56Sopenharmony_ci 3877db96d56Sopenharmony_ci.. data:: day_name 3887db96d56Sopenharmony_ci 3897db96d56Sopenharmony_ci An array that represents the days of the week in the current locale. 3907db96d56Sopenharmony_ci 3917db96d56Sopenharmony_ci 3927db96d56Sopenharmony_ci.. data:: day_abbr 3937db96d56Sopenharmony_ci 3947db96d56Sopenharmony_ci An array that represents the abbreviated days of the week in the current locale. 3957db96d56Sopenharmony_ci 3967db96d56Sopenharmony_ci 3977db96d56Sopenharmony_ci.. data:: month_name 3987db96d56Sopenharmony_ci 3997db96d56Sopenharmony_ci An array that represents the months of the year in the current locale. This 4007db96d56Sopenharmony_ci follows normal convention of January being month number 1, so it has a length of 4017db96d56Sopenharmony_ci 13 and ``month_name[0]`` is the empty string. 4027db96d56Sopenharmony_ci 4037db96d56Sopenharmony_ci 4047db96d56Sopenharmony_ci.. data:: month_abbr 4057db96d56Sopenharmony_ci 4067db96d56Sopenharmony_ci An array that represents the abbreviated months of the year in the current 4077db96d56Sopenharmony_ci locale. This follows normal convention of January being month number 1, so it 4087db96d56Sopenharmony_ci has a length of 13 and ``month_abbr[0]`` is the empty string. 4097db96d56Sopenharmony_ci 4107db96d56Sopenharmony_ci.. data:: MONDAY 4117db96d56Sopenharmony_ci TUESDAY 4127db96d56Sopenharmony_ci WEDNESDAY 4137db96d56Sopenharmony_ci THURSDAY 4147db96d56Sopenharmony_ci FRIDAY 4157db96d56Sopenharmony_ci SATURDAY 4167db96d56Sopenharmony_ci SUNDAY 4177db96d56Sopenharmony_ci 4187db96d56Sopenharmony_ci Aliases for day numbers, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``. 4197db96d56Sopenharmony_ci 4207db96d56Sopenharmony_ci.. seealso:: 4217db96d56Sopenharmony_ci 4227db96d56Sopenharmony_ci Module :mod:`datetime` 4237db96d56Sopenharmony_ci Object-oriented interface to dates and times with similar functionality to the 4247db96d56Sopenharmony_ci :mod:`time` module. 4257db96d56Sopenharmony_ci 4267db96d56Sopenharmony_ci Module :mod:`time` 4277db96d56Sopenharmony_ci Low-level time related functions. 428