-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-46266: Improve day constants (MONDAY
... SUNDAY
) in calendar
#30412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is | |
2 BC, and so on. | ||
|
||
|
||
.. class:: Calendar(firstweekday=0) | ||
.. class:: Calendar(firstweekday=MONDAY) | ||
|
||
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 | ||
|
@@ -275,13 +275,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is | |
cssclass_year = "text-italic lead" | ||
|
||
|
||
.. class:: LocaleTextCalendar(firstweekday=0, locale=None) | ||
.. class:: LocaleTextCalendar(firstweekday=MONDAY, locale=None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave all the defaults as 0. |
||
|
||
This subclass of :class:`TextCalendar` can be passed a locale name in the | ||
constructor and will return month and weekday names in the specified locale. | ||
|
||
|
||
.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None) | ||
.. class:: LocaleHTMLCalendar(firstweekday=MONDAY, locale=None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this one. |
||
|
||
This subclass of :class:`HTMLCalendar` can be passed a locale name in the | ||
constructor and will return month and weekday names in the specified | ||
|
@@ -406,6 +406,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:: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
"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 | ||
|
@@ -151,7 +153,7 @@ class Calendar(object): | |
provides data to subclasses. | ||
""" | ||
|
||
def __init__(self, firstweekday=0): | ||
def __init__(self, firstweekday=MONDAY): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave all of these as 0 as well. |
||
self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday | ||
|
||
def getfirstweekday(self): | ||
|
@@ -561,7 +563,7 @@ class LocaleTextCalendar(TextCalendar): | |
month and weekday names in the specified locale. | ||
""" | ||
|
||
def __init__(self, firstweekday=0, locale=None): | ||
def __init__(self, firstweekday=MONDAY, locale=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too. |
||
TextCalendar.__init__(self, firstweekday) | ||
if locale is None: | ||
locale = _locale.getdefaultlocale() | ||
|
@@ -581,7 +583,7 @@ class LocaleHTMLCalendar(HTMLCalendar): | |
This class can be passed a locale name in the constructor and will return | ||
month and weekday names in the specified locale. | ||
""" | ||
def __init__(self, firstweekday=0, locale=None): | ||
def __init__(self, firstweekday=MONDAY, locale=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too. |
||
HTMLCalendar.__init__(self, firstweekday) | ||
if locale is None: | ||
locale = _locale.getdefaultlocale() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Improve day constants in :mod:`calendar`. | ||
|
||
Now all constants (`MONDAY` ... `SUNDAY`) are documented, tested, and added | ||
to ``__all__``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave this as 0.