From fb2fee62980e469c8c34fabbdf0a5df785f93fa6 Mon Sep 17 00:00:00 2001 From: "Stan U." <89152624+StanFromIreland@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:41:23 +0000 Subject: [PATCH 1/9] Document formatday and prepare --- Doc/library/calendar.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index eafc038d6cb722..a8985e053e6d74 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -138,6 +138,19 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is :class:`TextCalendar` instances have the following methods: + .. method:: formatday(theday, weekday, width=2) + + Return a string representing a single day formatted with the given width + which defaults to 2. If *theday* is ``0``, return a string of spaces of + the specified width, representing an empty day. The *weekday* parameter + represents the day of the week, where ``0`` is Monday and ``6`` is Sunday. + + .. method:: formatweek() + + .. method:: formatweekday() + + .. method:: formatweekheader() + .. method:: formatmonth(theyear, themonth, w=0, l=0) Return a month's calendar in a multi-line string. If *w* is provided, it @@ -146,6 +159,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is on the first weekday as specified in the constructor or set by the :meth:`setfirstweekday` method. + .. method:: formatmonthname() .. method:: prmonth(theyear, themonth, w=0, l=0) From 8c17c78ac1f8f97cd672c24986fdecbf44559b85 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:23:08 +0000 Subject: [PATCH 2/9] Update calendar.rst --- Doc/library/calendar.rst | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index a8985e053e6d74..1919f5e8543b48 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -145,11 +145,24 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is the specified width, representing an empty day. The *weekday* parameter represents the day of the week, where ``0`` is Monday and ``6`` is Sunday. - .. method:: formatweek() + .. method:: formatweek(theweek, width=2) - .. method:: formatweekday() + Return a string representing an entire week formatted with the given width for each day. + The *theweek* parameter is a list of tuples, where each tuple contains a day of + the month or ``0`` for padding, and the corresponding weekday where 0 is + Monday and 6 is Sunday. Each day is padded to the specified width. - .. method:: formatweekheader() + .. method:: formatweekday(weekday, width=2) + + Return a string representing the name of a single weekday formatted to + the specified width. The *weekday* parameter is an integer representing + the day of the week, where 0 is Monday and 6 is Sunday. + + .. method:: formatweekheader(width=2) + + Return a string containing the header row of weekday names, formatted + with the given width for each column. The names depend on the locale + settings and are padded to the specified width. .. method:: formatmonth(theyear, themonth, w=0, l=0) @@ -159,13 +172,17 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is on the first weekday as specified in the constructor or set by the :meth:`setfirstweekday` method. - .. method:: formatmonthname() + .. method:: formatmonthname(theyear, themonth, width=0, withyear=True) + + Return a string representing the month's name centered within the + specified width. If *withyear* is True, include the year in the + output. The *theyear* and *themonth* parameters specify the year + and month for the name to be formatted. .. method:: prmonth(theyear, themonth, w=0, l=0) Print a month's calendar as returned by :meth:`formatmonth`. - .. method:: formatyear(theyear, w=2, l=1, c=6, m=3) Return a *m*-column calendar for an entire year as a multi-line string. From e3a14b06c7ed682f34d76e01d9eb8945c2e1a398 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:04:36 +0000 Subject: [PATCH 3/9] Update Doc/library/calendar.rst Co-authored-by: Peter Bierma --- Doc/library/calendar.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 1919f5e8543b48..f490b77c931e3b 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -149,8 +149,8 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is Return a string representing an entire week formatted with the given width for each day. The *theweek* parameter is a list of tuples, where each tuple contains a day of - the month or ``0`` for padding, and the corresponding weekday where 0 is - Monday and 6 is Sunday. Each day is padded to the specified width. + the month or ``0`` for padding, and the corresponding weekday where ``0`` is + Monday and ``6`` is Sunday. Each day is padded to the specified width. .. method:: formatweekday(weekday, width=2) From a41d652fde10c17b890b08b6cdfc196ebd697a72 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:04:42 +0000 Subject: [PATCH 4/9] Update Doc/library/calendar.rst Co-authored-by: Peter Bierma --- Doc/library/calendar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index f490b77c931e3b..a4c1adcdb9dd43 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -141,7 +141,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. method:: formatday(theday, weekday, width=2) Return a string representing a single day formatted with the given width - which defaults to 2. If *theday* is ``0``, return a string of spaces of + which defaults to ``2``. If *theday* is ``0``, return a string of spaces of the specified width, representing an empty day. The *weekday* parameter represents the day of the week, where ``0`` is Monday and ``6`` is Sunday. From 238befb8b90c3088adf5f7e069bc5ff428710259 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:04:51 +0000 Subject: [PATCH 5/9] Update Doc/library/calendar.rst Co-authored-by: Peter Bierma --- Doc/library/calendar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index a4c1adcdb9dd43..04dda616440714 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -156,7 +156,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is Return a string representing the name of a single weekday formatted to the specified width. The *weekday* parameter is an integer representing - the day of the week, where 0 is Monday and 6 is Sunday. + the day of the week, where ``0`` is Monday and ``6`` is Sunday. .. method:: formatweekheader(width=2) From 781876ccf2c340b09edebf65c5560fae4906e93d Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:04:59 +0000 Subject: [PATCH 6/9] Update Doc/library/calendar.rst Co-authored-by: Peter Bierma --- Doc/library/calendar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 04dda616440714..409bfd41ef4eca 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -175,7 +175,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. method:: formatmonthname(theyear, themonth, width=0, withyear=True) Return a string representing the month's name centered within the - specified width. If *withyear* is True, include the year in the + specified width. If *withyear* is ``True``, include the year in the output. The *theyear* and *themonth* parameters specify the year and month for the name to be formatted. From 60b524fa9bedd8a25d3caa998c1f42512153f45c Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:13:36 +0000 Subject: [PATCH 7/9] Change string to :class:`str` As per ZeroIntenisities suggestion --- Doc/library/calendar.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 409bfd41ef4eca..33cff8edee5b8c 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -140,33 +140,33 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. method:: formatday(theday, weekday, width=2) - Return a string representing a single day formatted with the given width - which defaults to ``2``. If *theday* is ``0``, return a string of spaces of + Return a :class:`str` representing a single day formatted with the given width + which defaults to ``2``. If *theday* is ``0``, return a :class:`str` of spaces of the specified width, representing an empty day. The *weekday* parameter represents the day of the week, where ``0`` is Monday and ``6`` is Sunday. .. method:: formatweek(theweek, width=2) - Return a string representing an entire week formatted with the given width for each day. + Return a :class:`str` representing an entire week formatted with the given width for each day. The *theweek* parameter is a list of tuples, where each tuple contains a day of the month or ``0`` for padding, and the corresponding weekday where ``0`` is Monday and ``6`` is Sunday. Each day is padded to the specified width. .. method:: formatweekday(weekday, width=2) - Return a string representing the name of a single weekday formatted to + Return a :class:`str` representing the name of a single weekday formatted to the specified width. The *weekday* parameter is an integer representing the day of the week, where ``0`` is Monday and ``6`` is Sunday. .. method:: formatweekheader(width=2) - Return a string containing the header row of weekday names, formatted + Return a :class:`str` containing the header row of weekday names, formatted with the given width for each column. The names depend on the locale settings and are padded to the specified width. .. method:: formatmonth(theyear, themonth, w=0, l=0) - Return a month's calendar in a multi-line string. If *w* is provided, it + Return a month's calendar in a multi-line :class:`str`. If *w* is provided, it specifies the width of the date columns, which are centered. If *l* 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 @@ -174,7 +174,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. method:: formatmonthname(theyear, themonth, width=0, withyear=True) - Return a string representing the month's name centered within the + Return a :class:`str` representing the month's name centered within the specified width. If *withyear* is ``True``, include the year in the output. The *theyear* and *themonth* parameters specify the year and month for the name to be formatted. @@ -185,7 +185,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is .. method:: formatyear(theyear, w=2, l=1, c=6, m=3) - Return a *m*-column calendar for an entire year as a multi-line string. + Return a *m*-column calendar for an entire year as a multi-line :class:`str`. Optional parameters *w*, *l*, and *c* 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 @@ -396,7 +396,7 @@ For simple text calendars this module provides the following functions. .. function:: month(theyear, themonth, w=0, l=0) - Returns a month's calendar in a multi-line string using the :meth:`~TextCalendar.formatmonth` + Returns a month's calendar in a multi-line :class:`str` using the :meth:`~TextCalendar.formatmonth` of the :class:`TextCalendar` class. @@ -407,7 +407,7 @@ For simple text calendars this module provides the following functions. .. function:: calendar(year, w=2, l=1, c=6, m=3) - Returns a 3-column calendar for an entire year as a multi-line string using + Returns a 3-column calendar for an entire year as a multi-line :class:`str` using the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class. @@ -468,7 +468,7 @@ The :mod:`calendar` module exports the following data attributes: 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 ``month_name[0]`` is the empty string. + 13 and ``month_name[0]`` is the empty :class:`str`. >>> import calendar >>> list(calendar.month_name) @@ -479,7 +479,7 @@ The :mod:`calendar` module exports the following data attributes: 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 ``month_abbr[0]`` is the empty string. + has a length of 13 and ``month_abbr[0]`` is the empty :class:`str`. >>> import calendar >>> list(calendar.month_abbr) From 6ed0c74b21a50ef223eb481008e3d0743978d2e4 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 10 Dec 2024 22:56:46 +0000 Subject: [PATCH 8/9] Update Doc/library/calendar.rst Co-authored-by: Peter Bierma --- Doc/library/calendar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 33cff8edee5b8c..c99d18f6808853 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -468,7 +468,7 @@ The :mod:`calendar` module exports the following data attributes: 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 ``month_name[0]`` is the empty :class:`str`. + 13 and ``month_name[0]`` is the empty :class:`str`. >>> import calendar >>> list(calendar.month_name) From 60c55723057845e1acbaa0e223d0216c2ecab5bd Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:12:33 +0000 Subject: [PATCH 9/9] Update calendar.rst --- Doc/library/calendar.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index c99d18f6808853..bd7cfc23f874bc 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -138,27 +138,27 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is :class:`TextCalendar` instances have the following methods: - .. method:: formatday(theday, weekday, width=2) + .. method:: formatday(theday, weekday, width) - Return a :class:`str` representing a single day formatted with the given width - which defaults to ``2``. If *theday* is ``0``, return a :class:`str` of spaces of + Return a :class:`str` representing a single day formatted with the given width. + If *theday* is ``0``, return a :class:`str` of spaces of the specified width, representing an empty day. The *weekday* parameter represents the day of the week, where ``0`` is Monday and ``6`` is Sunday. - .. method:: formatweek(theweek, width=2) + .. method:: formatweek(theweek, width) Return a :class:`str` representing an entire week formatted with the given width for each day. The *theweek* parameter is a list of tuples, where each tuple contains a day of the month or ``0`` for padding, and the corresponding weekday where ``0`` is Monday and ``6`` is Sunday. Each day is padded to the specified width. - .. method:: formatweekday(weekday, width=2) + .. method:: formatweekday(weekday, width) Return a :class:`str` representing the name of a single weekday formatted to the specified width. The *weekday* parameter is an integer representing the day of the week, where ``0`` is Monday and ``6`` is Sunday. - .. method:: formatweekheader(width=2) + .. method:: formatweekheader(width) Return a :class:`str` containing the header row of weekday names, formatted with the given width for each column. The names depend on the locale