Skip to content

Instantly share code, notes, and snippets.

@jwhitlock
Created December 11, 2020 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwhitlock/08ca74b037c2196f946262ef1a4b775d to your computer and use it in GitHub Desktop.
Save jwhitlock/08ca74b037c2196f946262ef1a4b775d to your computer and use it in GitHub Desktop.
Compare pytz's UTC to Python 3.9's UTC
from datetime import datetime
from zoneinfo import ZoneInfo
from pytz import UTC
ziUTC = ZoneInfo("UTC")
assert UTC != ziUTC
now = datetime.utcnow()
pytz_now = now.replace(tzinfo=UTC)
zoneinfo_now = now.replace(tzinfo=ziUTC)
assert pytz_now == zoneinfo_now
assert now != pytz_now
assert now != zoneinfo_now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment