puzzlehunt_server icon indicating copy to clipboard operation
puzzlehunt_server copied to clipboard

Fix DST issues surrounding calls to datetime.now()

Open dlareau opened this issue 4 years ago • 2 comments

Last night between 1am and 1am (I don't know how to properly describe the repeated hour) we encountered 335 instances of AmbiguousTimeError mostly seeming to stem from calls to datetime.now(). Some googling seems to imply we need to also include a call to make_aware. No huge rush on this issue though, presumably only happens once a year.

dlareau avatar Nov 01 '20 13:11 dlareau

Did these arise between 01:00 EDT and 01:59 EDT (0500–0559 UTC), or between 01:00 EST and 01:59 EST (0600–0659 UTC)?

timparenti avatar Nov 01 '20 14:11 timparenti

Heh, I knew I could rely on a response from you :) Digging into the logs further it appears the errors actually occurred in the whole two hour span of 0500-0700 UTC.

The problem simply seems to be that python has two datetime types, "naive" and "timzezone aware", and if you try and do any comparisons to a naive timestamp that falls in the DST fallback period python (probably correctly) errors rather than attempt to make a guess at what you meant. Hence the necessary calls to "make_aware".

dlareau avatar Nov 01 '20 15:11 dlareau