Spaces:
Sleeping
Sleeping
| <html lang="en" data-content_root="../"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <meta property="og:title" content="calendar — General calendar-related functions" /> | |
| <meta property="og:type" content="website" /> | |
| <meta property="og:url" content="https://docs.python.org/3/library/calendar.html" /> | |
| <meta property="og:site_name" content="Python documentation" /> | |
| <meta property="og:description" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." /> | |
| <meta property="og:image:width" content="1146" /> | |
| <meta property="og:image:height" content="600" /> | |
| <meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_calendar_7181f47a.png" /> | |
| <meta property="og:image:alt" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." /> | |
| <meta name="description" content="Source code: Lib/calendar.py This module allows you to output calendars like the Unix cal program, and provides additional useful functions related to the calendar. By default, these calendars have..." /> | |
| <meta name="twitter:card" content="summary_large_image" /> | |
| <meta name="theme-color" content="#3776ab"> | |
| <title>calendar — General calendar-related functions — Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" /> | |
| <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" /> | |
| <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" /> | |
| <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" /> | |
| <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" /> | |
| <script src="../_static/documentation_options.js?v=6b7c9ff5"></script> | |
| <script src="../_static/doctools.js?v=9bcbadda"></script> | |
| <script src="../_static/sphinx_highlight.js?v=dc90522c"></script> | |
| <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script> | |
| <script src="../_static/sidebar.js"></script> | |
| <link rel="search" type="application/opensearchdescription+xml" | |
| title="Search within Python 3.15.0a6 documentation" | |
| href="../_static/opensearch.xml"/> | |
| <link rel="author" title="About these documents" href="../about.html" /> | |
| <link rel="index" title="Index" href="../genindex.html" /> | |
| <link rel="search" title="Search" href="../search.html" /> | |
| <link rel="copyright" title="Copyright" href="../copyright.html" /> | |
| <link rel="next" title="collections — Container datatypes" href="collections.html" /> | |
| <link rel="prev" title="zoneinfo — IANA time zone support" href="zoneinfo.html" /> | |
| <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script> | |
| <link rel="canonical" href="https://docs.python.org/3/library/calendar.html"> | |
| <style> | |
| @media only screen { | |
| table.full-width-table { | |
| width: 100%; | |
| } | |
| } | |
| </style> | |
| <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css"> | |
| <link rel="shortcut icon" type="image/png" href="../_static/py.svg"> | |
| <script type="text/javascript" src="../_static/copybutton.js"></script> | |
| <script type="text/javascript" src="../_static/menu.js"></script> | |
| <script type="text/javascript" src="../_static/search-focus.js"></script> | |
| <script type="text/javascript" src="../_static/themetoggle.js"></script> | |
| <script type="text/javascript" src="../_static/rtd_switcher.js"></script> | |
| <meta name="readthedocs-addons-api-version" content="1"> | |
| </head> | |
| <body> | |
| <div class="mobile-nav"> | |
| <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation" | |
| aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu"> | |
| <nav class="nav-content" role="navigation"> | |
| <label for="menuToggler" class="toggler__label"> | |
| <span></span> | |
| </label> | |
| <span class="nav-items-wrapper"> | |
| <a href="https://www.python.org/" class="nav-logo"> | |
| <img src="../_static/py.svg" alt="Python logo"> | |
| </a> | |
| <span class="version_switcher_placeholder"></span> | |
| <form role="search" class="search" action="../search.html" method="get"> | |
| <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon"> | |
| <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path> | |
| </svg> | |
| <input placeholder="Quick search" aria-label="Quick search" type="search" name="q"> | |
| <input type="submit" value="Go"> | |
| </form> | |
| </span> | |
| </nav> | |
| <div class="menu-wrapper"> | |
| <nav class="menu" role="navigation" aria-label="main navigation"> | |
| <div class="language_switcher_placeholder"></div> | |
| <label class="theme-selector-label"> | |
| Theme | |
| <select class="theme-selector" oninput="activateTheme(this.value)"> | |
| <option value="auto" selected>Auto</option> | |
| <option value="light">Light</option> | |
| <option value="dark">Dark</option> | |
| </select> | |
| </label> | |
| <div> | |
| <h3><a href="../contents.html">Table of Contents</a></h3> | |
| <ul> | |
| <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a><ul> | |
| <li><a class="reference internal" href="#command-line-usage">Command-line usage</a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4>Previous topic</h4> | |
| <p class="topless"><a href="zoneinfo.html" | |
| title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zoneinfo</span></code> — IANA time zone support</a></p> | |
| </div> | |
| <div> | |
| <h4>Next topic</h4> | |
| <p class="topless"><a href="collections.html" | |
| title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> — Container datatypes</a></p> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const title = document.querySelector('meta[property="og:title"]').content; | |
| const elements = document.querySelectorAll('.improvepage'); | |
| const pageurl = window.location.href.split('?')[0]; | |
| elements.forEach(element => { | |
| const url = new URL(element.href.split('?')[0].replace("-nojs", "")); | |
| url.searchParams.set('pagetitle', title); | |
| url.searchParams.set('pageurl', pageurl); | |
| url.searchParams.set('pagesource', "library/calendar.rst"); | |
| element.href = url.toString(); | |
| }); | |
| }); | |
| </script> | |
| <div role="note" aria-label="source link"> | |
| <h3>This page</h3> | |
| <ul class="this-page-menu"> | |
| <li><a href="../bugs.html">Report a bug</a></li> | |
| <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li> | |
| <li> | |
| <a href="https://github.com/python/cpython/blob/main/Doc/library/calendar.rst?plain=1" | |
| rel="nofollow">Show source | |
| </a> | |
| </li> | |
| </ul> | |
| </div> | |
| </nav> | |
| </div> | |
| </div> | |
| <div class="related" role="navigation" aria-label="Related"> | |
| <h3>Navigation</h3> | |
| <ul> | |
| <li class="right" style="margin-right: 10px"> | |
| <a href="../genindex.html" title="General Index" | |
| accesskey="I">index</a></li> | |
| <li class="right" > | |
| <a href="../py-modindex.html" title="Python Module Index" | |
| >modules</a> |</li> | |
| <li class="right" > | |
| <a href="collections.html" title="collections — Container datatypes" | |
| accesskey="N">next</a> |</li> | |
| <li class="right" > | |
| <a href="zoneinfo.html" title="zoneinfo — IANA time zone support" | |
| accesskey="P">previous</a> |</li> | |
| <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li> | |
| <li><a href="https://www.python.org/">Python</a> »</li> | |
| <li class="switchers"> | |
| <div class="language_switcher_placeholder"></div> | |
| <div class="version_switcher_placeholder"></div> | |
| </li> | |
| <li> | |
| </li> | |
| <li id="cpython-language-and-version"> | |
| <a href="../index.html">3.15.0a6 Documentation</a> » | |
| </li> | |
| <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> | |
| <li class="nav-item nav-item-2"><a href="datatypes.html" accesskey="U">Data Types</a> »</li> | |
| <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a></li> | |
| <li class="right"> | |
| <div class="inline-search" role="search"> | |
| <form class="inline-search" action="../search.html" method="get"> | |
| <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box"> | |
| <input type="submit" value="Go"> | |
| </form> | |
| </div> | |
| | | |
| </li> | |
| <li class="right"> | |
| <label class="theme-selector-label"> | |
| Theme | |
| <select class="theme-selector" oninput="activateTheme(this.value)"> | |
| <option value="auto" selected>Auto</option> | |
| <option value="light">Light</option> | |
| <option value="dark">Dark</option> | |
| </select> | |
| </label> |</li> | |
| </ul> | |
| </div> | |
| <div class="document"> | |
| <div class="documentwrapper"> | |
| <div class="bodywrapper"> | |
| <div class="body" role="main"> | |
| <section id="module-calendar"> | |
| <span id="calendar-general-calendar-related-functions"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions<a class="headerlink" href="#module-calendar" title="Link to this heading">¶</a></h1> | |
| <p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/calendar.py">Lib/calendar.py</a></p> | |
| <hr class="docutils" /> | |
| <p>This module allows you to output calendars like the Unix <strong class="program">cal</strong> program, | |
| and provides additional useful functions related to the calendar. By default, | |
| these calendars have Monday as the first day of the week, and Sunday as the last | |
| (the European convention). Use <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> to set the first day of | |
| the week to Sunday (6) or to any other weekday. Parameters that specify dates | |
| are given as integers. For related | |
| functionality, see also the <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a> and <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> modules.</p> | |
| <p>The functions and classes defined in this module | |
| use an idealized calendar, the current Gregorian calendar extended indefinitely | |
| in both directions. This matches the definition of the “proleptic Gregorian” | |
| calendar in Dershowitz and Reingold’s book “Calendrical Calculations”, where | |
| it’s the base calendar for all computations. Zero and negative years are | |
| interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is | |
| 2 BC, and so on.</p> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.Calendar"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Creates a <code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> object. <em>firstweekday</em> is an integer specifying the | |
| first day of the week. <a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">MONDAY</span></code></a> is <code class="docutils literal notranslate"><span class="pre">0</span></code> (the default), <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SUNDAY</span></code></a> is <code class="docutils literal notranslate"><span class="pre">6</span></code>.</p> | |
| <p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> object provides several methods that can be used for | |
| preparing the calendar data for formatting. This class doesn’t do any formatting | |
| itself. This is the job of subclasses.</p> | |
| <p><code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code> instances have the following methods and attributes:</p> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.firstweekday"> | |
| <span class="sig-name descname"><span class="pre">firstweekday</span></span><a class="headerlink" href="#calendar.Calendar.firstweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>The first weekday as an integer (0–6).</p> | |
| <p>This property can also be set and read using | |
| <a class="reference internal" href="#calendar.Calendar.setfirstweekday" title="calendar.Calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> and | |
| <a class="reference internal" href="#calendar.Calendar.getfirstweekday" title="calendar.Calendar.getfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getfirstweekday()</span></code></a> respectively.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.getfirstweekday"> | |
| <span class="sig-name descname"><span class="pre">getfirstweekday</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.getfirstweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> for the current first weekday (0–6).</p> | |
| <p>Identical to reading the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.setfirstweekday"> | |
| <span class="sig-name descname"><span class="pre">setfirstweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.setfirstweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Set the first weekday to <em>firstweekday</em>, passed as an <a class="reference internal" href="functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> (0–6)</p> | |
| <p>Identical to setting the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.iterweekdays"> | |
| <span class="sig-name descname"><span class="pre">iterweekdays</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.iterweekdays" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the week day numbers that will be used for one | |
| week. The first value from the iterator will be the same as the value of | |
| the <a class="reference internal" href="#calendar.Calendar.firstweekday" title="calendar.Calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> property.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.itermonthdates"> | |
| <span class="sig-name descname"><span class="pre">itermonthdates</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdates" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the month <em>month</em> (1–12) in the year <em>year</em>. This | |
| iterator will return all days (as <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects) for the | |
| month and all days before the start of the month or after the end of the | |
| month that are required to get a complete week.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.itermonthdays"> | |
| <span class="sig-name descname"><span class="pre">itermonthdays</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to | |
| <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> | |
| range. Days returned will simply be day of the month numbers. For the | |
| days outside of the specified month, the day number is <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.itermonthdays2"> | |
| <span class="sig-name descname"><span class="pre">itermonthdays2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays2" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to | |
| <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> | |
| range. Days returned will be tuples consisting of a day of the month | |
| number and a week day number.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.itermonthdays3"> | |
| <span class="sig-name descname"><span class="pre">itermonthdays3</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays3" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to | |
| <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> | |
| range. Days returned will be tuples consisting of a year, a month and a day | |
| of the month numbers.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.itermonthdays4"> | |
| <span class="sig-name descname"><span class="pre">itermonthdays4</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays4" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return an iterator for the month <em>month</em> in the year <em>year</em> similar to | |
| <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a>, but not restricted by the <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> | |
| range. Days returned will be tuples consisting of a year, a month, a day | |
| of the month, and a day of the week numbers.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.monthdatescalendar"> | |
| <span class="sig-name descname"><span class="pre">monthdatescalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdatescalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full | |
| weeks. Weeks are lists of seven <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.monthdays2calendar"> | |
| <span class="sig-name descname"><span class="pre">monthdays2calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdays2calendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full | |
| weeks. Weeks are lists of seven tuples of day numbers and weekday | |
| numbers.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.monthdayscalendar"> | |
| <span class="sig-name descname"><span class="pre">monthdayscalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdayscalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a list of the weeks in the month <em>month</em> of the <em>year</em> as full | |
| weeks. Weeks are lists of seven day numbers.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.yeardatescalendar"> | |
| <span class="sig-name descname"><span class="pre">yeardatescalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardatescalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return the data for the specified year ready for formatting. The return | |
| value is a list of month rows. Each month row contains up to <em>width</em> | |
| months (defaulting to 3). Each month contains between 4 and 6 weeks and | |
| each week contains 1–7 days. Days are <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> objects.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.yeardays2calendar"> | |
| <span class="sig-name descname"><span class="pre">yeardays2calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardays2calendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return the data for the specified year ready for formatting (similar to | |
| <a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a>). Entries in the week lists are tuples of day | |
| numbers and weekday numbers. Day numbers outside this month are zero.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.Calendar.yeardayscalendar"> | |
| <span class="sig-name descname"><span class="pre">yeardayscalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardayscalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return the data for the specified year ready for formatting (similar to | |
| <a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a>). Entries in the week lists are day numbers. Day | |
| numbers outside this month are zero.</p> | |
| </dd></dl> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">TextCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>This class can be used to generate plain text calendars.</p> | |
| <p><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code> instances have the following methods:</p> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.prweek"> | |
| <span class="sig-name descname"><span class="pre">prweek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theweek</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.prweek" title="Link to this definition">¶</a></dt> | |
| <dd><p>Print a week’s calendar as returned by <a class="reference internal" href="#calendar.TextCalendar.formatweek" title="calendar.TextCalendar.formatweek"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatweek()</span></code></a> and without a | |
| final newline.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatday"> | |
| <span class="sig-name descname"><span class="pre">formatday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a string representing a single day formatted with the given <em>width</em>. | |
| If <em>theday</em> is <code class="docutils literal notranslate"><span class="pre">0</span></code>, return a string of spaces of | |
| the specified width, representing an empty day. The <em>weekday</em> parameter | |
| is unused.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatweek"> | |
| <span class="sig-name descname"><span class="pre">formatweek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theweek</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweek" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a single week in a string with no newline. If <em>w</em> is provided, it | |
| specifies the width of the date columns, which are centered. Depends | |
| on the first weekday as specified in the constructor or set by the | |
| <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatweekday"> | |
| <span class="sig-name descname"><span class="pre">formatweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a string representing the name of a single weekday formatted to | |
| the specified <em>width</em>. The <em>weekday</em> parameter is an integer representing | |
| the day of the week, where <code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday and <code class="docutils literal notranslate"><span class="pre">6</span></code> is Sunday.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatweekheader"> | |
| <span class="sig-name descname"><span class="pre">formatweekheader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">width</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatweekheader" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a string containing the header row of weekday names, formatted | |
| with the given <em>width</em> for each column. The names depend on the locale | |
| settings and are padded to the specified width.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatmonth"> | |
| <span class="sig-name descname"><span class="pre">formatmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatmonth" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a month’s calendar in a multi-line string. If <em>w</em> is provided, it | |
| specifies the width of the date columns, which are centered. If <em>l</em> is | |
| given, it specifies the number of lines that each week will use. Depends | |
| on the first weekday as specified in the constructor or set by the | |
| <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatmonthname"> | |
| <span class="sig-name descname"><span class="pre">formatmonthname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatmonthname" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a string representing the month’s name centered within the | |
| specified <em>width</em>. If <em>withyear</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, include the year in the | |
| output. The <em>theyear</em> and <em>themonth</em> parameters specify the year | |
| and month for the name to be formatted respectively.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.prmonth"> | |
| <span class="sig-name descname"><span class="pre">prmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.prmonth" title="Link to this definition">¶</a></dt> | |
| <dd><p>Print a month’s calendar as returned by <a class="reference internal" href="#calendar.TextCalendar.formatmonth" title="calendar.TextCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a>.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.formatyear"> | |
| <span class="sig-name descname"><span class="pre">formatyear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatyear" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a <em>m</em>-column calendar for an entire year as a multi-line string. | |
| Optional parameters <em>w</em>, <em>l</em>, and <em>c</em> are for date column width, lines per | |
| week, and number of spaces between month columns, respectively. Depends on | |
| the first weekday as specified in the constructor or set by the | |
| <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> method. The earliest year for which a calendar | |
| can be generated is platform-dependent.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.TextCalendar.pryear"> | |
| <span class="sig-name descname"><span class="pre">pryear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.pryear" title="Link to this definition">¶</a></dt> | |
| <dd><p>Print the calendar for an entire year as returned by <a class="reference internal" href="#calendar.TextCalendar.formatyear" title="calendar.TextCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>.</p> | |
| </dd></dl> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">HTMLCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>This class can be used to generate HTML calendars.</p> | |
| <p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> instances have the following methods:</p> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.formatmonth"> | |
| <span class="sig-name descname"><span class="pre">formatmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatmonth" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a month’s calendar as an HTML table. If <em>withyear</em> is true the year | |
| will be included in the header, otherwise just the month name will be | |
| used.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.formatyear"> | |
| <span class="sig-name descname"><span class="pre">formatyear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyear" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a year’s calendar as an HTML table. <em>width</em> (defaulting to 3) | |
| specifies the number of months per row.</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.formatyearpage"> | |
| <span class="sig-name descname"><span class="pre">formatyearpage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">css</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'calendar.css'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyearpage" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a year’s calendar as a complete HTML page. <em>width</em> (defaulting to | |
| 3) specifies the number of months per row. <em>css</em> is the name for the | |
| cascading style sheet to be used. <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> can be passed if no style | |
| sheet should be used. <em>encoding</em> specifies the encoding to be used for the | |
| output (defaulting to <code class="docutils literal notranslate"><span class="pre">'utf-8'</span></code>).</p> | |
| </dd></dl> | |
| <dl class="py method"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.formatmonthname"> | |
| <span class="sig-name descname"><span class="pre">formatmonthname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">withyear</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatmonthname" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a month name as an HTML table row. If <em>withyear</em> is true the year | |
| will be included in the row, otherwise just the month name will be | |
| used.</p> | |
| </dd></dl> | |
| <p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> has the following attributes you can override to | |
| customize the CSS classes used by the calendar:</p> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclasses"> | |
| <span class="sig-name descname"><span class="pre">cssclasses</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses" title="Link to this definition">¶</a></dt> | |
| <dd><p>A list of CSS classes used for each weekday. The default class list is:</p> | |
| <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"mon"</span><span class="p">,</span> <span class="s2">"tue"</span><span class="p">,</span> <span class="s2">"wed"</span><span class="p">,</span> <span class="s2">"thu"</span><span class="p">,</span> <span class="s2">"fri"</span><span class="p">,</span> <span class="s2">"sat"</span><span class="p">,</span> <span class="s2">"sun"</span><span class="p">]</span> | |
| </pre></div> | |
| </div> | |
| <p>more styles can be added for each day:</p> | |
| <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"mon text-bold"</span><span class="p">,</span> <span class="s2">"tue"</span><span class="p">,</span> <span class="s2">"wed"</span><span class="p">,</span> <span class="s2">"thu"</span><span class="p">,</span> <span class="s2">"fri"</span><span class="p">,</span> <span class="s2">"sat"</span><span class="p">,</span> <span class="s2">"sun red"</span><span class="p">]</span> | |
| </pre></div> | |
| </div> | |
| <p>Note that the length of this list must be seven items.</p> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_noday"> | |
| <span class="sig-name descname"><span class="pre">cssclass_noday</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_noday" title="Link to this definition">¶</a></dt> | |
| <dd><p>The CSS class for a weekday occurring in the previous or coming month.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclasses_weekday_head"> | |
| <span class="sig-name descname"><span class="pre">cssclasses_weekday_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses_weekday_head" title="Link to this definition">¶</a></dt> | |
| <dd><p>A list of CSS classes used for weekday names in the header row. | |
| The default is the same as <a class="reference internal" href="#calendar.HTMLCalendar.cssclasses" title="calendar.HTMLCalendar.cssclasses"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cssclasses</span></code></a>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_month_head"> | |
| <span class="sig-name descname"><span class="pre">cssclass_month_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month_head" title="Link to this definition">¶</a></dt> | |
| <dd><p>The month’s head CSS class (used by <a class="reference internal" href="#calendar.HTMLCalendar.formatmonthname" title="calendar.HTMLCalendar.formatmonthname"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code></a>). | |
| The default value is <code class="docutils literal notranslate"><span class="pre">"month"</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_month"> | |
| <span class="sig-name descname"><span class="pre">cssclass_month</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month" title="Link to this definition">¶</a></dt> | |
| <dd><p>The CSS class for the whole month’s table (used by <a class="reference internal" href="#calendar.HTMLCalendar.formatmonth" title="calendar.HTMLCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a>). | |
| The default value is <code class="docutils literal notranslate"><span class="pre">"month"</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_year"> | |
| <span class="sig-name descname"><span class="pre">cssclass_year</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year" title="Link to this definition">¶</a></dt> | |
| <dd><p>The CSS class for the whole year’s table of tables (used by | |
| <a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>). The default value is <code class="docutils literal notranslate"><span class="pre">"year"</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.HTMLCalendar.cssclass_year_head"> | |
| <span class="sig-name descname"><span class="pre">cssclass_year_head</span></span><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year_head" title="Link to this definition">¶</a></dt> | |
| <dd><p>The CSS class for the table head for the whole year (used by | |
| <a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a>). The default value is <code class="docutils literal notranslate"><span class="pre">"year"</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.7.</span></p> | |
| </div> | |
| </dd></dl> | |
| <p>Note that although the naming for the above described class attributes is | |
| singular (e.g. <code class="docutils literal notranslate"><span class="pre">cssclass_month</span></code> <code class="docutils literal notranslate"><span class="pre">cssclass_noday</span></code>), one can replace the | |
| single CSS class with a space separated list of CSS classes, for example:</p> | |
| <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="s2">"text-bold text-red"</span> | |
| </pre></div> | |
| </div> | |
| <p>Here is an example how <code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> can be customized:</p> | |
| <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">CustomHTMLCal</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="p">):</span> | |
| <span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="n">style</span> <span class="o">+</span> <span class="s2">" text-nowrap"</span> <span class="k">for</span> <span class="n">style</span> <span class="ow">in</span> | |
| <span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="o">.</span><span class="n">cssclasses</span><span class="p">]</span> | |
| <span class="n">cssclass_month_head</span> <span class="o">=</span> <span class="s2">"text-center month-head"</span> | |
| <span class="n">cssclass_month</span> <span class="o">=</span> <span class="s2">"text-center month"</span> | |
| <span class="n">cssclass_year</span> <span class="o">=</span> <span class="s2">"text-italic lead"</span> | |
| </pre></div> | |
| </div> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.LocaleTextCalendar"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">LocaleTextCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleTextCalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>This subclass of <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> can be passed a locale name in the | |
| constructor and will return month and weekday names in the specified locale.</p> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.LocaleHTMLCalendar"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">LocaleHTMLCalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">firstweekday</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleHTMLCalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>This subclass of <a class="reference internal" href="#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code></a> can be passed a locale name in the | |
| constructor and will return month and weekday names in the specified | |
| locale.</p> | |
| </dd></dl> | |
| <div class="admonition note"> | |
| <p class="admonition-title">Note</p> | |
| <p>The constructor, <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatweekday()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code> methods | |
| of these two classes temporarily change the <code class="docutils literal notranslate"><span class="pre">LC_TIME</span></code> locale to the given | |
| <em>locale</em>. Because the current locale is a process-wide setting, they are | |
| not thread-safe.</p> | |
| </div> | |
| <p>For simple text calendars this module provides the following functions.</p> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.setfirstweekday"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">setfirstweekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.setfirstweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Sets the weekday (<code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday, <code class="docutils literal notranslate"><span class="pre">6</span></code> is Sunday) to start each week. The | |
| values <a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">MONDAY</span></code></a>, <a class="reference internal" href="#calendar.TUESDAY" title="calendar.TUESDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">TUESDAY</span></code></a>, <a class="reference internal" href="#calendar.WEDNESDAY" title="calendar.WEDNESDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">WEDNESDAY</span></code></a>, <a class="reference internal" href="#calendar.THURSDAY" title="calendar.THURSDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">THURSDAY</span></code></a>, | |
| <a class="reference internal" href="#calendar.FRIDAY" title="calendar.FRIDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">FRIDAY</span></code></a>, <a class="reference internal" href="#calendar.SATURDAY" title="calendar.SATURDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SATURDAY</span></code></a>, and <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-const docutils literal notranslate"><span class="pre">SUNDAY</span></code></a> are provided for | |
| convenience. For example, to set the first weekday to Sunday:</p> | |
| <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span> | |
| <span class="n">calendar</span><span class="o">.</span><span class="n">setfirstweekday</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">SUNDAY</span><span class="p">)</span> | |
| </pre></div> | |
| </div> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.firstweekday"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">firstweekday</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.firstweekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns the current setting for the weekday to start each week.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.isleap"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">isleap</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.isleap" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns <a class="reference internal" href="constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a> if <em>year</em> is a leap year, otherwise <a class="reference internal" href="constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a>.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.leapdays"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">leapdays</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.leapdays" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns the number of leap years in the range from <em>y1</em> to <em>y2</em> (exclusive), | |
| where <em>y1</em> and <em>y2</em> are years.</p> | |
| <p>This function works for ranges spanning a century change.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.weekday"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">weekday</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">day</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns the day of the week (<code class="docutils literal notranslate"><span class="pre">0</span></code> is Monday) for <em>year</em> (<code class="docutils literal notranslate"><span class="pre">1970</span></code>–…), | |
| <em>month</em> (<code class="docutils literal notranslate"><span class="pre">1</span></code>–<code class="docutils literal notranslate"><span class="pre">12</span></code>), <em>day</em> (<code class="docutils literal notranslate"><span class="pre">1</span></code>–<code class="docutils literal notranslate"><span class="pre">31</span></code>).</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.weekheader"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">weekheader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekheader" title="Link to this definition">¶</a></dt> | |
| <dd><p>Return a header containing abbreviated weekday names. <em>n</em> specifies the width in | |
| characters for one weekday.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.monthrange"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">monthrange</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthrange" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns weekday of first day of the month and number of days in month, for the | |
| specified <em>year</em> and <em>month</em>.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.monthcalendar"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">monthcalendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthcalendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns a matrix representing a month’s calendar. Each row represents a week; | |
| days outside of the month are represented by zeros. Each week begins with Monday | |
| unless set by <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a>.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.prmonth"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">prmonth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prmonth" title="Link to this definition">¶</a></dt> | |
| <dd><p>Prints a month’s calendar as returned by <a class="reference internal" href="#calendar.month" title="calendar.month"><code class="xref py py-func docutils literal notranslate"><span class="pre">month()</span></code></a>.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.month"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">theyear</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">themonth</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.month" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns a month’s calendar in a multi-line string using the <a class="reference internal" href="#calendar.TextCalendar.formatmonth" title="calendar.TextCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a> | |
| of the <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> class.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.prcal"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">prcal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prcal" title="Link to this definition">¶</a></dt> | |
| <dd><p>Prints the calendar for an entire year as returned by <a class="reference internal" href="#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-func docutils literal notranslate"><span class="pre">calendar()</span></code></a>.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.calendar"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">calendar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">year</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">w</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">l</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">c</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">m</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.calendar" title="Link to this definition">¶</a></dt> | |
| <dd><p>Returns a 3-column calendar for an entire year as a multi-line string using | |
| the <a class="reference internal" href="#calendar.TextCalendar.formatyear" title="calendar.TextCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a> of the <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> class.</p> | |
| </dd></dl> | |
| <dl class="py function"> | |
| <dt class="sig sig-object py" id="calendar.timegm"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">timegm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tuple</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.timegm" title="Link to this definition">¶</a></dt> | |
| <dd><p>An unrelated but handy function that takes a time tuple such as returned by | |
| the <a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> function in the <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module, and returns the | |
| corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX | |
| encoding. In fact, <code class="xref py py-func docutils literal notranslate"><span class="pre">time.gmtime()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">timegm()</span></code> are each others’ | |
| inverse.</p> | |
| </dd></dl> | |
| <p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module exports the following data attributes:</p> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.day_name"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">day_name</span></span><a class="headerlink" href="#calendar.day_name" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the days of the week in the current locale, | |
| where Monday is day number 0.</p> | |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span> | |
| <span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">day_name</span><span class="p">)</span> | |
| <span class="go">['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']</span> | |
| </pre></div> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.day_abbr"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">day_abbr</span></span><a class="headerlink" href="#calendar.day_abbr" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the abbreviated days of the week in the current locale, | |
| where Mon is day number 0.</p> | |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span> | |
| <span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">day_abbr</span><span class="p">)</span> | |
| <span class="go">['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']</span> | |
| </pre></div> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.MONDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MONDAY</span></span><a class="headerlink" href="#calendar.MONDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.TUESDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">TUESDAY</span></span><a class="headerlink" href="#calendar.TUESDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.WEDNESDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">WEDNESDAY</span></span><a class="headerlink" href="#calendar.WEDNESDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.THURSDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">THURSDAY</span></span><a class="headerlink" href="#calendar.THURSDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.FRIDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">FRIDAY</span></span><a class="headerlink" href="#calendar.FRIDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.SATURDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SATURDAY</span></span><a class="headerlink" href="#calendar.SATURDAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.SUNDAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SUNDAY</span></span><a class="headerlink" href="#calendar.SUNDAY" title="Link to this definition">¶</a></dt> | |
| <dd><p>Aliases for the days of the week, | |
| where <code class="docutils literal notranslate"><span class="pre">MONDAY</span></code> is <code class="docutils literal notranslate"><span class="pre">0</span></code> and <code class="docutils literal notranslate"><span class="pre">SUNDAY</span></code> is <code class="docutils literal notranslate"><span class="pre">6</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.12.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.Day"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Day</span></span><a class="headerlink" href="#calendar.Day" title="Link to this definition">¶</a></dt> | |
| <dd><p>Enumeration defining days of the week as integer constants. | |
| The members of this enumeration are exported to the module scope as | |
| <a class="reference internal" href="#calendar.MONDAY" title="calendar.MONDAY"><code class="xref py py-data docutils literal notranslate"><span class="pre">MONDAY</span></code></a> through <a class="reference internal" href="#calendar.SUNDAY" title="calendar.SUNDAY"><code class="xref py py-data docutils literal notranslate"><span class="pre">SUNDAY</span></code></a>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.12.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.month_name"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month_name</span></span><a class="headerlink" href="#calendar.month_name" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the months of the year in the current locale. This | |
| follows normal convention of January being month number 1, so it has a length of | |
| 13 and <code class="docutils literal notranslate"><span class="pre">month_name[0]</span></code> is the empty string.</p> | |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span> | |
| <span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">month_name</span><span class="p">)</span> | |
| <span class="go">['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']</span> | |
| </pre></div> | |
| </div> | |
| <div class="admonition caution"> | |
| <p class="admonition-title">Caution</p> | |
| <p>In locales with alternative month names forms, the <code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code> sequence | |
| may not be suitable when a month name stands by itself and not as part of a date. | |
| For instance, in Greek and in many Slavic and Baltic languages, <code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code> | |
| will produce the month in genitive case. Use <a class="reference internal" href="#calendar.standalone_month_name" title="calendar.standalone_month_name"><code class="xref py py-data docutils literal notranslate"><span class="pre">standalone_month_name</span></code></a> for a form | |
| suitable for standalone use.</p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.month_abbr"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">month_abbr</span></span><a class="headerlink" href="#calendar.month_abbr" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the abbreviated months of the year in the current | |
| locale. This follows normal convention of January being month number 1, so it | |
| has a length of 13 and <code class="docutils literal notranslate"><span class="pre">month_abbr[0]</span></code> is the empty string.</p> | |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">calendar</span> | |
| <span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">month_abbr</span><span class="p">)</span> | |
| <span class="go">['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']</span> | |
| </pre></div> | |
| </div> | |
| <div class="admonition caution"> | |
| <p class="admonition-title">Caution</p> | |
| <p>In locales with alternative month names forms, the <code class="xref py py-data docutils literal notranslate"><span class="pre">month_abbr</span></code> sequence | |
| may not be suitable when a month name stands by itself and not as part of a date. | |
| Use <a class="reference internal" href="#calendar.standalone_month_abbr" title="calendar.standalone_month_abbr"><code class="xref py py-data docutils literal notranslate"><span class="pre">standalone_month_abbr</span></code></a> for a form suitable for standalone use.</p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.standalone_month_name"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">standalone_month_name</span></span><a class="headerlink" href="#calendar.standalone_month_name" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the months of the year in the current locale | |
| in the standalone form if the locale provides one. Else it is equivalent | |
| to <a class="reference internal" href="#calendar.month_name" title="calendar.month_name"><code class="xref py py-data docutils literal notranslate"><span class="pre">month_name</span></code></a>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.15.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.standalone_month_abbr"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">standalone_month_abbr</span></span><a class="headerlink" href="#calendar.standalone_month_abbr" title="Link to this definition">¶</a></dt> | |
| <dd><p>A sequence that represents the abbreviated months of the year in the current | |
| locale in the standalone form if the locale provides one. Else it is | |
| equivalent to <a class="reference internal" href="#calendar.month_abbr" title="calendar.month_abbr"><code class="xref py py-data docutils literal notranslate"><span class="pre">month_abbr</span></code></a>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.15.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py data"> | |
| <dt class="sig sig-object py" id="calendar.JANUARY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JANUARY</span></span><a class="headerlink" href="#calendar.JANUARY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.FEBRUARY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">FEBRUARY</span></span><a class="headerlink" href="#calendar.FEBRUARY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.MARCH"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MARCH</span></span><a class="headerlink" href="#calendar.MARCH" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.APRIL"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">APRIL</span></span><a class="headerlink" href="#calendar.APRIL" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.MAY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">MAY</span></span><a class="headerlink" href="#calendar.MAY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.JUNE"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JUNE</span></span><a class="headerlink" href="#calendar.JUNE" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.JULY"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">JULY</span></span><a class="headerlink" href="#calendar.JULY" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.AUGUST"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">AUGUST</span></span><a class="headerlink" href="#calendar.AUGUST" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.SEPTEMBER"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">SEPTEMBER</span></span><a class="headerlink" href="#calendar.SEPTEMBER" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.OCTOBER"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">OCTOBER</span></span><a class="headerlink" href="#calendar.OCTOBER" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.NOVEMBER"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">NOVEMBER</span></span><a class="headerlink" href="#calendar.NOVEMBER" title="Link to this definition">¶</a></dt> | |
| <dt class="sig sig-object py" id="calendar.DECEMBER"> | |
| <span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">DECEMBER</span></span><a class="headerlink" href="#calendar.DECEMBER" title="Link to this definition">¶</a></dt> | |
| <dd><p>Aliases for the months of the year, | |
| where <code class="docutils literal notranslate"><span class="pre">JANUARY</span></code> is <code class="docutils literal notranslate"><span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">DECEMBER</span></code> is <code class="docutils literal notranslate"><span class="pre">12</span></code>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.12.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="py class"> | |
| <dt class="sig sig-object py" id="calendar.Month"> | |
| <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">Month</span></span><a class="headerlink" href="#calendar.Month" title="Link to this definition">¶</a></dt> | |
| <dd><p>Enumeration defining months of the year as integer constants. | |
| The members of this enumeration are exported to the module scope as | |
| <a class="reference internal" href="#calendar.JANUARY" title="calendar.JANUARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">JANUARY</span></code></a> through <a class="reference internal" href="#calendar.DECEMBER" title="calendar.DECEMBER"><code class="xref py py-data docutils literal notranslate"><span class="pre">DECEMBER</span></code></a>.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.12.</span></p> | |
| </div> | |
| </dd></dl> | |
| <p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module defines the following exceptions:</p> | |
| <dl class="py exception"> | |
| <dt class="sig sig-object py" id="calendar.IllegalMonthError"> | |
| <em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">IllegalMonthError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">month</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.IllegalMonthError" title="Link to this definition">¶</a></dt> | |
| <dd><p>A subclass of <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>, | |
| raised when the given month number is outside of the range 1-12 (inclusive).</p> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.IllegalMonthError.month"> | |
| <span class="sig-name descname"><span class="pre">month</span></span><a class="headerlink" href="#calendar.IllegalMonthError.month" title="Link to this definition">¶</a></dt> | |
| <dd><p>The invalid month number.</p> | |
| </dd></dl> | |
| </dd></dl> | |
| <dl class="py exception"> | |
| <dt class="sig sig-object py" id="calendar.IllegalWeekdayError"> | |
| <em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">calendar.</span></span><span class="sig-name descname"><span class="pre">IllegalWeekdayError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">weekday</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.IllegalWeekdayError" title="Link to this definition">¶</a></dt> | |
| <dd><p>A subclass of <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>, | |
| raised when the given weekday number is outside of the range 0-6 (inclusive).</p> | |
| <dl class="py attribute"> | |
| <dt class="sig sig-object py" id="calendar.IllegalWeekdayError.weekday"> | |
| <span class="sig-name descname"><span class="pre">weekday</span></span><a class="headerlink" href="#calendar.IllegalWeekdayError.weekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>The invalid weekday number.</p> | |
| </dd></dl> | |
| </dd></dl> | |
| <div class="admonition seealso"> | |
| <p class="admonition-title">See also</p> | |
| <dl class="simple"> | |
| <dt>Module <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a></dt><dd><p>Object-oriented interface to dates and times with similar functionality to the | |
| <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> module.</p> | |
| </dd> | |
| <dt>Module <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a></dt><dd><p>Low-level time related functions.</p> | |
| </dd> | |
| </dl> | |
| </div> | |
| <section id="command-line-usage"> | |
| <span id="calendar-cli"></span><h2>Command-line usage<a class="headerlink" href="#command-line-usage" title="Link to this heading">¶</a></h2> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 2.5.</span></p> | |
| </div> | |
| <p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> module can be executed as a script from the command line | |
| to interactively print a calendar.</p> | |
| <div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>calendar<span class="w"> </span><span class="o">[</span>-h<span class="o">]</span><span class="w"> </span><span class="o">[</span>-L<span class="w"> </span>LOCALE<span class="o">]</span><span class="w"> </span><span class="o">[</span>-e<span class="w"> </span>ENCODING<span class="o">]</span><span class="w"> </span><span class="o">[</span>-t<span class="w"> </span><span class="o">{</span>text,html<span class="o">}]</span> | |
| <span class="w"> </span><span class="o">[</span>-w<span class="w"> </span>WIDTH<span class="o">]</span><span class="w"> </span><span class="o">[</span>-l<span class="w"> </span>LINES<span class="o">]</span><span class="w"> </span><span class="o">[</span>-s<span class="w"> </span>SPACING<span class="o">]</span><span class="w"> </span><span class="o">[</span>-m<span class="w"> </span>MONTHS<span class="o">]</span><span class="w"> </span><span class="o">[</span>-c<span class="w"> </span>CSS<span class="o">]</span> | |
| <span class="w"> </span><span class="o">[</span>-f<span class="w"> </span>FIRST_WEEKDAY<span class="o">]</span><span class="w"> </span><span class="o">[</span>year<span class="o">]</span><span class="w"> </span><span class="o">[</span>month<span class="o">]</span> | |
| </pre></div> | |
| </div> | |
| <p>For example, to print a calendar for the year 2000:</p> | |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>calendar<span class="w"> </span><span class="m">2000</span> | |
| <span class="go"> 2000</span> | |
| <span class="go"> January February March</span> | |
| <span class="go">Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su</span> | |
| <span class="go"> 1 2 1 2 3 4 5 6 1 2 3 4 5</span> | |
| <span class="go"> 3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12</span> | |
| <span class="go">10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19</span> | |
| <span class="go">17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26</span> | |
| <span class="go">24 25 26 27 28 29 30 28 29 27 28 29 30 31</span> | |
| <span class="go">31</span> | |
| <span class="go"> April May June</span> | |
| <span class="go">Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su</span> | |
| <span class="go"> 1 2 1 2 3 4 5 6 7 1 2 3 4</span> | |
| <span class="go"> 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11</span> | |
| <span class="go">10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18</span> | |
| <span class="go">17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25</span> | |
| <span class="go">24 25 26 27 28 29 30 29 30 31 26 27 28 29 30</span> | |
| <span class="go"> July August September</span> | |
| <span class="go">Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su</span> | |
| <span class="go"> 1 2 1 2 3 4 5 6 1 2 3</span> | |
| <span class="go"> 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10</span> | |
| <span class="go">10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17</span> | |
| <span class="go">17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24</span> | |
| <span class="go">24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30</span> | |
| <span class="go">31</span> | |
| <span class="go"> October November December</span> | |
| <span class="go">Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su</span> | |
| <span class="go"> 1 1 2 3 4 5 1 2 3</span> | |
| <span class="go"> 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10</span> | |
| <span class="go"> 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17</span> | |
| <span class="go">16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24</span> | |
| <span class="go">23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31</span> | |
| <span class="go">30 31</span> | |
| </pre></div> | |
| </div> | |
| <p>The following options are accepted:</p> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-help"> | |
| <span id="cmdoption-calendar-h"></span><span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-help" title="Link to this definition">¶</a></dt> | |
| <dd><p>Show the help message and exit.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-locale"> | |
| <span id="cmdoption-calendar-L"></span><span class="sig-name descname"><span class="pre">--locale</span></span><span class="sig-prename descclassname"> <span class="pre">LOCALE</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-L</span></span><span class="sig-prename descclassname"> <span class="pre">LOCALE</span></span><a class="headerlink" href="#cmdoption-calendar-locale" title="Link to this definition">¶</a></dt> | |
| <dd><p>The locale to use for month and weekday names. | |
| Defaults to English.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-encoding"> | |
| <span id="cmdoption-calendar-e"></span><span class="sig-name descname"><span class="pre">--encoding</span></span><span class="sig-prename descclassname"> <span class="pre">ENCODING</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-e</span></span><span class="sig-prename descclassname"> <span class="pre">ENCODING</span></span><a class="headerlink" href="#cmdoption-calendar-encoding" title="Link to this definition">¶</a></dt> | |
| <dd><p>The encoding to use for output. | |
| <a class="reference internal" href="#cmdoption-calendar-encoding"><code class="xref std std-option docutils literal notranslate"><span class="pre">--encoding</span></code></a> is required if <a class="reference internal" href="#cmdoption-calendar-locale"><code class="xref std std-option docutils literal notranslate"><span class="pre">--locale</span></code></a> is set.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-type"> | |
| <span id="cmdoption-calendar-t"></span><span class="sig-name descname"><span class="pre">--type</span></span><span class="sig-prename descclassname"> <span class="pre">{text,html}</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-t</span></span><span class="sig-prename descclassname"> <span class="pre">{text,html}</span></span><a class="headerlink" href="#cmdoption-calendar-type" title="Link to this definition">¶</a></dt> | |
| <dd><p>Print the calendar to the terminal as text, | |
| or as an HTML document.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-first-weekday"> | |
| <span id="cmdoption-calendar-f"></span><span class="sig-name descname"><span class="pre">--first-weekday</span></span><span class="sig-prename descclassname"> <span class="pre">FIRST_WEEKDAY</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-f</span></span><span class="sig-prename descclassname"> <span class="pre">FIRST_WEEKDAY</span></span><a class="headerlink" href="#cmdoption-calendar-first-weekday" title="Link to this definition">¶</a></dt> | |
| <dd><p>The weekday to start each week. | |
| Must be a number between 0 (Monday) and 6 (Sunday). | |
| Defaults to 0.</p> | |
| <div class="versionadded"> | |
| <p><span class="versionmodified added">Added in version 3.13.</span></p> | |
| </div> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-arg-year"> | |
| <span class="sig-name descname"><span class="pre">year</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-arg-year" title="Link to this definition">¶</a></dt> | |
| <dd><p>The year to print the calendar for. | |
| Defaults to the current year.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-arg-month"> | |
| <span class="sig-name descname"><span class="pre">month</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-calendar-arg-month" title="Link to this definition">¶</a></dt> | |
| <dd><p>The month of the specified <a class="reference internal" href="#cmdoption-calendar-arg-year"><code class="xref std std-option docutils literal notranslate"><span class="pre">year</span></code></a> to print the calendar for. | |
| Must be a number between 1 and 12. | |
| Defaults to printing a calendar for the full year.</p> | |
| </dd></dl> | |
| <p><em>Text-mode options:</em></p> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-width"> | |
| <span id="cmdoption-calendar-w"></span><span class="sig-name descname"><span class="pre">--width</span></span><span class="sig-prename descclassname"> <span class="pre">WIDTH</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-w</span></span><span class="sig-prename descclassname"> <span class="pre">WIDTH</span></span><a class="headerlink" href="#cmdoption-calendar-width" title="Link to this definition">¶</a></dt> | |
| <dd><p>The width of the date column in terminal columns. | |
| The date is printed centred in the column. | |
| Any value lower than 2 is ignored. | |
| Defaults to 2.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-lines"> | |
| <span id="cmdoption-calendar-l"></span><span class="sig-name descname"><span class="pre">--lines</span></span><span class="sig-prename descclassname"> <span class="pre">LINES</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-l</span></span><span class="sig-prename descclassname"> <span class="pre">LINES</span></span><a class="headerlink" href="#cmdoption-calendar-lines" title="Link to this definition">¶</a></dt> | |
| <dd><p>The number of lines for each week in terminal rows. | |
| The date is printed top-aligned. | |
| Any value lower than 1 is ignored. | |
| Defaults to 1.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-spacing"> | |
| <span id="cmdoption-calendar-s"></span><span class="sig-name descname"><span class="pre">--spacing</span></span><span class="sig-prename descclassname"> <span class="pre">SPACING</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-s</span></span><span class="sig-prename descclassname"> <span class="pre">SPACING</span></span><a class="headerlink" href="#cmdoption-calendar-spacing" title="Link to this definition">¶</a></dt> | |
| <dd><p>The space between months in columns. | |
| Any value lower than 2 is ignored. | |
| Defaults to 6.</p> | |
| </dd></dl> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-months"> | |
| <span id="cmdoption-calendar-m"></span><span class="sig-name descname"><span class="pre">--months</span></span><span class="sig-prename descclassname"> <span class="pre">MONTHS</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-m</span></span><span class="sig-prename descclassname"> <span class="pre">MONTHS</span></span><a class="headerlink" href="#cmdoption-calendar-months" title="Link to this definition">¶</a></dt> | |
| <dd><p>The number of months printed per row. | |
| Defaults to 3.</p> | |
| </dd></dl> | |
| <div class="versionchanged"> | |
| <p><span class="versionmodified changed">Changed in version 3.14: </span>By default, today’s date is highlighted in color and can be | |
| <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">controlled using environment variables</span></a>.</p> | |
| </div> | |
| <p><em>HTML-mode options:</em></p> | |
| <dl class="std option"> | |
| <dt class="sig sig-object std" id="cmdoption-calendar-css"> | |
| <span id="cmdoption-calendar-c"></span><span class="sig-name descname"><span class="pre">--css</span></span><span class="sig-prename descclassname"> <span class="pre">CSS</span></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">-c</span></span><span class="sig-prename descclassname"> <span class="pre">CSS</span></span><a class="headerlink" href="#cmdoption-calendar-css" title="Link to this definition">¶</a></dt> | |
| <dd><p>The path of a CSS stylesheet to use for the calendar. | |
| This must either be relative to the generated HTML, | |
| or an absolute HTTP or <code class="docutils literal notranslate"><span class="pre">file:///</span></code> URL.</p> | |
| </dd></dl> | |
| </section> | |
| </section> | |
| <div class="clearer"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="sphinxsidebar" role="navigation" aria-label="Main"> | |
| <div class="sphinxsidebarwrapper"> | |
| <div> | |
| <h3><a href="../contents.html">Table of Contents</a></h3> | |
| <ul> | |
| <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a><ul> | |
| <li><a class="reference internal" href="#command-line-usage">Command-line usage</a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4>Previous topic</h4> | |
| <p class="topless"><a href="zoneinfo.html" | |
| title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zoneinfo</span></code> — IANA time zone support</a></p> | |
| </div> | |
| <div> | |
| <h4>Next topic</h4> | |
| <p class="topless"><a href="collections.html" | |
| title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> — Container datatypes</a></p> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const title = document.querySelector('meta[property="og:title"]').content; | |
| const elements = document.querySelectorAll('.improvepage'); | |
| const pageurl = window.location.href.split('?')[0]; | |
| elements.forEach(element => { | |
| const url = new URL(element.href.split('?')[0].replace("-nojs", "")); | |
| url.searchParams.set('pagetitle', title); | |
| url.searchParams.set('pageurl', pageurl); | |
| url.searchParams.set('pagesource', "library/calendar.rst"); | |
| element.href = url.toString(); | |
| }); | |
| }); | |
| </script> | |
| <div role="note" aria-label="source link"> | |
| <h3>This page</h3> | |
| <ul class="this-page-menu"> | |
| <li><a href="../bugs.html">Report a bug</a></li> | |
| <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li> | |
| <li> | |
| <a href="https://github.com/python/cpython/blob/main/Doc/library/calendar.rst?plain=1" | |
| rel="nofollow">Show source | |
| </a> | |
| </li> | |
| </ul> | |
| </div> | |
| </div> | |
| <div id="sidebarbutton" title="Collapse sidebar"> | |
| <span>«</span> | |
| </div> | |
| </div> | |
| <div class="clearer"></div> | |
| </div> | |
| <div class="related" role="navigation" aria-label="Related"> | |
| <h3>Navigation</h3> | |
| <ul> | |
| <li class="right" style="margin-right: 10px"> | |
| <a href="../genindex.html" title="General Index" | |
| >index</a></li> | |
| <li class="right" > | |
| <a href="../py-modindex.html" title="Python Module Index" | |
| >modules</a> |</li> | |
| <li class="right" > | |
| <a href="collections.html" title="collections — Container datatypes" | |
| >next</a> |</li> | |
| <li class="right" > | |
| <a href="zoneinfo.html" title="zoneinfo — IANA time zone support" | |
| >previous</a> |</li> | |
| <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li> | |
| <li><a href="https://www.python.org/">Python</a> »</li> | |
| <li class="switchers"> | |
| <div class="language_switcher_placeholder"></div> | |
| <div class="version_switcher_placeholder"></div> | |
| </li> | |
| <li> | |
| </li> | |
| <li id="cpython-language-and-version"> | |
| <a href="../index.html">3.15.0a6 Documentation</a> » | |
| </li> | |
| <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> | |
| <li class="nav-item nav-item-2"><a href="datatypes.html" >Data Types</a> »</li> | |
| <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code> — General calendar-related functions</a></li> | |
| <li class="right"> | |
| <div class="inline-search" role="search"> | |
| <form class="inline-search" action="../search.html" method="get"> | |
| <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box"> | |
| <input type="submit" value="Go"> | |
| </form> | |
| </div> | |
| | | |
| </li> | |
| <li class="right"> | |
| <label class="theme-selector-label"> | |
| Theme | |
| <select class="theme-selector" oninput="activateTheme(this.value)"> | |
| <option value="auto" selected>Auto</option> | |
| <option value="light">Light</option> | |
| <option value="dark">Dark</option> | |
| </select> | |
| </label> |</li> | |
| </ul> | |
| </div> | |
| <div class="footer"> | |
| © <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation. | |
| <br> | |
| This page is licensed under the Python Software Foundation License Version 2. | |
| <br> | |
| Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. | |
| <br> | |
| See <a href="/license.html">History and License</a> for more information.<br> | |
| <br> | |
| The Python Software Foundation is a non-profit corporation. | |
| <a href="https://www.python.org/psf/donations/">Please donate.</a> | |
| <br> | |
| <br> | |
| Last updated on Mar 10, 2026 (08:58 UTC). | |
| <a href="/bugs.html">Found a bug</a>? | |
| <br> | |
| Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3. | |
| </div> | |
| </body> | |
| </html> |