]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103822: [Calendar] change return value to enum for day and month APIs (GH-103827)
authorPrince Roshan <princekrroshan01@gmail.com>
Tue, 2 May 2023 20:13:31 +0000 (01:43 +0530)
committerGitHub <noreply@github.com>
Tue, 2 May 2023 20:13:31 +0000 (13:13 -0700)
Lib/calendar.py
Misc/NEWS.d/next/Library/2023-05-02-04-49-45.gh-issue-103822.m0QdAO.rst [new file with mode: 0644]

index bbd4fea3b88ca41889ba84853d1edf065f55c382..ea56f12ccc41d0a7dd574ab1edac962a27e80e68 100644 (file)
@@ -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 (file)
index 0000000..3daf9cc
--- /dev/null
@@ -0,0 +1 @@
+Update the return type of ``weekday`` to the newly added Day attribute