Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 533767f

Browse files
minh-swinburnetianyizheng02
andauthored
Doomsday Algorithm: Fix leap year check (#12396)
* Fix leap year check Replace `!=` in `(year % 400) != 0` (line 49) with `==` Justification: Years that are divisible by 100 (centurian == 100) but not by 400 (year % 400 != 0) are skipped and NOT leap year. * Update parentheses Correct the parentheses to make clear the precedence of the conditional check * Update other/doomsday.py Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com> --------- Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
1 parent 0040ad4 commit 533767f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎other/doomsday.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_week_day(year: int, month: int, day: int) -> str:
4646
) % 7
4747
day_anchor = (
4848
DOOMSDAY_NOT_LEAP[month - 1]
49-
if (year % 4 != 0) or (centurian == 0 and (year % 400) == 0)
49+
if year % 4 != 0 or (centurian == 0 and year % 400!= 0)
5050
else DOOMSDAY_LEAP[month - 1]
5151
)
5252
week_day = (dooms_day + day - day_anchor) % 7

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /