Re:Whenever – typed and DST-safe datetimes for Python
by raverbashing on Sunday April 13, 2025 @09:17AM
(#43672600)
Honestly yeah who in tarnation created that function and called it utcnow
These things are really frustrating
Re:Whenever – typed and DST-safe datetimes for Python
by mark-r on Sunday April 13, 2025 @10:15AM
(#43672964)
Yeah, utcnow is completely broken. They should have fixed it when they created datetime.timezone.utc, but they didn't. The recommendation is to use datetime.datetime.now(datetime.timezone.utc) instead. utcnow should be deprecated and eventually removed.
That's why I use a Flake8 plugin to prohibit especially egregious footguns.
https://github.com/jkittner/flake8-ban-utcnow