Skip to content

Commit e5894ca

Browse files
authored
bpo-46266: Add calendar day of week constants to __all__ (GH-30412)
1 parent 817a6bc commit e5894ca

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Doc/library/calendar.rst

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
3131
.. class:: Calendar(firstweekday=0)
3232

3333
Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the
34-
first day of the week. ``0`` is Monday (the default), ``6`` is Sunday.
34+
first day of the week. :const:`MONDAY` is ``0`` (the default), :const:`SUNDAY` is ``6``.
3535

3636
A :class:`Calendar` object provides several methods that can be used for
3737
preparing the calendar data for formatting. This class doesn't do any formatting
@@ -406,6 +406,15 @@ The :mod:`calendar` module exports the following data attributes:
406406
locale. This follows normal convention of January being month number 1, so it
407407
has a length of 13 and ``month_abbr[0]`` is the empty string.
408408

409+
.. data:: MONDAY
410+
TUESDAY
411+
WEDNESDAY
412+
THURSDAY
413+
FRIDAY
414+
SATURDAY
415+
SUNDAY
416+
417+
Aliases for day numbers, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``.
409418

410419
.. seealso::
411420

Lib/calendar.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"monthcalendar", "prmonth", "month", "prcal", "calendar",
1616
"timegm", "month_name", "month_abbr", "day_name", "day_abbr",
1717
"Calendar", "TextCalendar", "HTMLCalendar", "LocaleTextCalendar",
18-
"LocaleHTMLCalendar", "weekheader"]
18+
"LocaleHTMLCalendar", "weekheader",
19+
"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY",
20+
"SATURDAY", "SUNDAY"]
1921

2022
# Exception raised for bad input (with string parameter for details)
2123
error = ValueError

Lib/test/test_calendar.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,7 @@ def test_html_output_year_css(self):
935935
class MiscTestCase(unittest.TestCase):
936936
def test__all__(self):
937937
not_exported = {
938-
'mdays', 'January', 'February', 'EPOCH', 'MONDAY', 'TUESDAY',
939-
'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY',
938+
'mdays', 'January', 'February', 'EPOCH',
940939
'different_locale', 'c', 'prweek', 'week', 'format',
941940
'formatstring', 'main', 'monthlen', 'prevmonth', 'nextmonth'}
942941
support.check__all__(self, calendar, not_exported=not_exported)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Improve day constants in :mod:`calendar`.
2+
3+
Now all constants (`MONDAY` ... `SUNDAY`) are documented, tested, and added
4+
to ``__all__``.

0 commit comments

Comments
 (0)