Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey team,
This fixes an
AmbiguousTimeErrorthat crashes the contest calendar view when viewing months that start during a daylight saving time fall-back transition at midnight (like/contests/2026/11/or/contests/2020/11/for users in theAmerica/Havanatimezone).What was happening
ContestCalendar.get_table()calculates the calendar start and end dates withdatetime.datetime.combine(calendar[0][0], time.min)and passes them tomake_aware(). In timezones where DST ends right at midnight on Sunday (such as Cuba falling back from Daylight Time to Standard Time on the first Sunday of November),00:00:00happens twice. Becausemake_aware()defaults tois_dst=None,pytzcannot tell which side of the transition to pick and raisespytz.exceptions.AmbiguousTimeError.What changed
We added a helper method
_make_aware()onContestCalendarthat resolves ambiguity by settingis_dst=Falsewhen usingpytz. This cleanly picks standard time for the midnight boundary during fall-back transitions without crashing. For normal dates or standard zoneinfo, it behaves exactly as before.Testing
ContestCalendarTestCasewithtest_make_aware_ambiguous_dstandtest_get_table_ambiguous_dstinjudge/models/tests/test_contest.py.manage.py testacross all related test suites with 18/18 passing tests.flake8with 0 warnings or errors.