dlareau / puzzlehunt_server

Server for Puzzle hunts run by Puzzlehunt CMU, but can be repurposed for other hunts.
MIT License
19 stars 16 forks source link

Fix DST issues surrounding calls to datetime.now() #149

Open dlareau opened 4 years ago

dlareau commented 4 years ago

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.

timparenti commented 4 years ago

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)?

dlareau commented 4 years ago

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".