summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-23 01:00:11 (GMT)
committerGitHub <noreply@github.com>2022-01-23 01:00:11 (GMT)
commitf66ef3eab62c6d262ddbc8ab16fb43c8921ad33a (patch)
tree241d32dbf875b98a55549ce5b39d5d418dc656c5
parent486b4d3d8e1a5699a2854e310c58fe12b220b7a9 (diff)
downloadcpython-f66ef3eab62c6d262ddbc8ab16fb43c8921ad33a.zip
cpython-f66ef3eab62c6d262ddbc8ab16fb43c8921ad33a.tar.gz
cpython-f66ef3eab62c6d262ddbc8ab16fb43c8921ad33a.tar.bz2
bpo-46266: Add calendar day of week constants to __all__ (GH-30412) (GH-30424)
(cherry picked from commit e5894ca8fd05e6a6df1033025b9093b68baa718d) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r--Doc/library/calendar.rst11
-rw-r--r--Lib/calendar.py4
-rw-r--r--Lib/test/test_calendar.py3
-rw-r--r--Misc/NEWS.d/next/Library/2022-01-05-12-48-18.bpo-46266.ACQCgX.rst4
4 files changed, 18 insertions, 4 deletions
diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst
index c3c04db..f641760 100644
--- a/Doc/library/calendar.rst
+++ b/Doc/library/calendar.rst
@@ -31,7 +31,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
.. class:: Calendar(firstweekday=0)
Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the
- first day of the week. ``0`` is Monday (the default), ``6`` is Sunday.
+ first day of the week. :const:`MONDAY` is ``0`` (the default), :const:`SUNDAY` is ``6``.
A :class:`Calendar` object provides several methods that can be used for
preparing the calendar data for formatting. This class doesn't do any formatting
@@ -409,6 +409,15 @@ The :mod:`calendar` module exports the following data attributes:
locale. This follows normal convention of January being month number 1, so it
has a length of 13 and ``month_abbr[0]`` is the empty string.
+.. data:: MONDAY
+ TUESDAY
+ WEDNESDAY
+ THURSDAY
+ FRIDAY
+ SATURDAY
+ SUNDAY
+
+ Aliases for day numbers, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``.
.. seealso::
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 7311a01..cbea9ec 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -15,7 +15,9 @@ __all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
"monthcalendar", "prmonth", "month", "prcal", "calendar",
"timegm", "month_name", "month_abbr", "day_name", "day_abbr",
"Calendar", "TextCalendar", "HTMLCalendar", "LocaleTextCalendar",
- "LocaleHTMLCalendar", "weekheader"]
+ "LocaleHTMLCalendar", "weekheader",
+ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY",
+ "SATURDAY", "SUNDAY"]
# Exception raised for bad input (with string parameter for details)
error = ValueError
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index c641e8c..39094ad 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -935,8 +935,7 @@ class CommandLineTestCase(unittest.TestCase):
class MiscTestCase(unittest.TestCase):
def test__all__(self):
not_exported = {
- 'mdays', 'January', 'February', 'EPOCH', 'MONDAY', 'TUESDAY',
- 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY',
+ 'mdays', 'January', 'February', 'EPOCH',
'different_locale', 'c', 'prweek', 'week', 'format',
'formatstring', 'main', 'monthlen', 'prevmonth', 'nextmonth'}
support.check__all__(self, calendar, not_exported=not_exported)
diff --git a/Misc/NEWS.d/next/Library/2022-01-05-12-48-18.bpo-46266.ACQCgX.rst b/Misc/NEWS.d/next/Library/2022-01-05-12-48-18.bpo-46266.ACQCgX.rst
new file mode 100644
index 0000000..354dcb0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-01-05-12-48-18.bpo-46266.ACQCgX.rst
@@ -0,0 +1,4 @@
+Improve day constants in :mod:`calendar`.
+
+Now all constants (`MONDAY` ... `SUNDAY`) are documented, tested, and added
+to ``__all__``.