Created
December 11, 2020 16:24
-
-
Save jwhitlock/08ca74b037c2196f946262ef1a4b775d to your computer and use it in GitHub Desktop.
Compare pytz's UTC to Python 3.9's UTC
This file contains 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
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