summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrince Roshan <princekrroshan01@gmail.com>2023-05-02 20:13:31 (GMT)
committerGitHub <noreply@github.com>2023-05-02 20:13:31 (GMT)
commit1f5384434dce013b5dcf7e7ea3ec5312d13bba72 (patch)
tree49bb2be002fd6b2c06e7777984b94317f9e050c1
parent587f2f018051049cf5d9de3e12ed5aa7644404dc (diff)
downloadcpython-1f5384434dce013b5dcf7e7ea3ec5312d13bba72.zip
cpython-1f5384434dce013b5dcf7e7ea3ec5312d13bba72.tar.gz
cpython-1f5384434dce013b5dcf7e7ea3ec5312d13bba72.tar.bz2
gh-103822: [Calendar] change return value to enum for day and month APIs (GH-103827)
-rw-r--r--Lib/calendar.py3
-rw-r--r--Misc/NEWS.d/next/Library/2023-05-02-04-49-45.gh-issue-103822.m0QdAO.rst1
2 files changed, 2 insertions, 2 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py
index bbd4fea..ea56f12 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -83,7 +83,6 @@ class Day(IntEnum):
SUNDAY = 6
-
# Number of days per month (except for February in leap years)
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@@ -156,7 +155,7 @@ def weekday(year, month, day):
"""Return weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31)."""
if not datetime.MINYEAR <= year <= datetime.MAXYEAR:
year = 2000 + year % 400
- return datetime.date(year, month, day).weekday()
+ return Day(datetime.date(year, month, day).weekday())
def monthrange(year, month):
diff --git a/Misc/NEWS.d/next/Library/2023-05-02-04-49-45.gh-issue-103822.m0QdAO.rst b/Misc/NEWS.d/next/Library/2023-05-02-04-49-45.gh-issue-103822.m0QdAO.rst
new file mode 100644
index 0000000..3daf9cc
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-05-02-04-49-45.gh-issue-103822.m0QdAO.rst
@@ -0,0 +1 @@
+Update the return type of ``weekday`` to the newly added Day attribute