From eafaeb4e529dfa40b604547fa8011659de8a5bf8 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 25 Aug 2023 19:03:36 +0100 Subject: [PATCH 1/4] Merge documentation of month and day constants --- Doc/library/calendar.rst | 77 +++++++++++++--------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 3c097f4cf7abd9..8b50ce17560f3a 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -28,58 +28,6 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is 2 BC, and so on. -.. class:: Day - - Enumeration defining the days of the week as integer constants, from 0 to 6. - - .. attribute:: MONDAY - - .. attribute:: TUESDAY - - .. attribute:: WEDNESDAY - - .. attribute:: THURSDAY - - .. attribute:: FRIDAY - - .. attribute:: SATURDAY - - .. attribute:: SUNDAY - - .. versionadded:: 3.12 - - -.. class:: Month - - Enumeration defining months of the year as integer constants, from 1 to 12. - - .. attribute:: JANUARY - - .. attribute:: FEBRUARY - - .. attribute:: MARCH - - .. attribute:: APRIL - - .. attribute:: MAY - - .. attribute:: JUNE - - .. attribute:: JULY - - .. attribute:: AUGUST - - .. attribute:: SEPTEMBER - - .. attribute:: OCTOBER - - .. attribute:: NOVEMBER - - .. attribute:: DECEMBER - - .. versionadded:: 3.12 - - .. class:: Calendar(firstweekday=0) Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the @@ -459,6 +407,7 @@ 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 @@ -467,7 +416,29 @@ The :mod:`calendar` module exports the following data attributes: SATURDAY SUNDAY - Aliases for day numbers, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``. + Enumeration defining the days of the week as integer constants, + where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``. + + .. versionadded:: 3.12 + + +.. data:: JANUARY + FEBRUARY + MARCH + APRIL + MAY + JUNE + JULY + AUGUST + SEPTEMBER + OCTOBER + NOVEMBER + DECEMBER + + Enumeration defining months of the year as integer constants, + where ``JANUARY`` is ``1`` and ``DECEMBER`` is ``12``. + + .. versionadded:: 3.12 The :mod:`calendar` module defines the following exceptions: From ce92dc662e2a65941a1477dc0ab9c78161d43edd Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 25 Aug 2023 19:19:04 +0100 Subject: [PATCH 2/4] Use preferred short forms --- Doc/whatsnew/3.12.rst | 2 +- Doc/whatsnew/3.13.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index b557e6cde6a209..c5a5f7e6bd0235 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -1013,7 +1013,7 @@ Deprecated (Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.) * :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are deprecated and - replaced by :data:`calendar.Month.JANUARY` and :data:`calendar.Month.FEBRUARY`. + replaced by :data:`calendar.JANUARY` and :data:`calendar.FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.) * :mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime.utcnow` and diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 4ff12b16d00266..d31d458b2fb9c9 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -435,8 +435,8 @@ although there is currently no date scheduled for their removal. * Delegation of ``int()`` to ``__trunc__()`` method. * :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are - deprecated and replaced by :data:`calendar.Month.JANUARY` and - :data:`calendar.Month.FEBRUARY`. + deprecated and replaced by :data:`calendar.JANUARY` and + :data:`calendar.FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.) * :mod:`datetime`: From 05b59add9c7fa6cf0ff6fc9dbee5e23d8936fffd Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 25 Aug 2023 19:22:27 +0100 Subject: [PATCH 3/4] Define the enum classes --- Doc/library/calendar.rst | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 8b50ce17560f3a..28b5f03d5b20a0 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -416,12 +416,21 @@ The :mod:`calendar` module exports the following data attributes: SATURDAY SUNDAY - Enumeration defining the days of the week as integer constants, + Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` is ``6``. .. versionadded:: 3.12 +.. class:: Day + + Enumeration defining days of the week as integer constants. + The members of this enumeration are exported to the module scope as + :data:`MONDAY` through :data:`SUNDAY`. + + .. versionadded:: 3.12 + + .. data:: JANUARY FEBRUARY MARCH @@ -435,12 +444,21 @@ The :mod:`calendar` module exports the following data attributes: NOVEMBER DECEMBER - Enumeration defining months of the year as integer constants, + Aliases for the months of the year, where ``JANUARY`` is ``1`` and ``DECEMBER`` is ``12``. .. versionadded:: 3.12 +.. class:: Month + + Enumeration defining months of the year as integer constants. + The members of this enumeration are exported to the module scope as + :data:`JANUARY` through :data:`DECEMBER`. + + .. versionadded:: 3.12 + + The :mod:`calendar` module defines the following exceptions: .. exception:: IllegalMonthError(month) From d249b85fd2bc0e096bed465c9f2479ed1d58a5f6 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:56:41 +0100 Subject: [PATCH 4/4] Group day and month data together --- Doc/library/calendar.rst | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 28b5f03d5b20a0..1868eb1cd359c4 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -394,20 +394,6 @@ The :mod:`calendar` module exports the following data attributes: An array that represents the abbreviated days of the week in the current locale. -.. data:: month_name - - An array 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 ``month_name[0]`` is the empty string. - - -.. data:: month_abbr - - An array 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 ``month_abbr[0]`` is the empty string. - - .. data:: MONDAY TUESDAY WEDNESDAY @@ -431,6 +417,20 @@ The :mod:`calendar` module exports the following data attributes: .. versionadded:: 3.12 +.. data:: month_name + + An array 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 ``month_name[0]`` is the empty string. + + +.. data:: month_abbr + + An array 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 ``month_abbr[0]`` is the empty string. + + .. data:: JANUARY FEBRUARY MARCH