From: Prince Roshan Date: Tue, 2 May 2023 20:13:31 +0000 (+0530) Subject: gh-103822: [Calendar] change return value to enum for day and month APIs (GH-103827) X-Git-Tag: v3.12.0b1~321 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f5384434dce013b5dcf7e7ea3ec5312d13bba72;p=thirdparty%2FPython%2Fcpython.git gh-103822: [Calendar] change return value to enum for day and month APIs (GH-103827) --- diff --git a/Lib/calendar.py b/Lib/calendar.py index bbd4fea3b88c..ea56f12ccc41 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 000000000000..3daf9cc09380 --- /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