Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57373 > unrolled thread
| Started by | Skip Montanaro <skip@pobox.com> |
|---|---|
| First post | 2013-10-23 11:17 -0500 |
| Last post | 2013-10-23 11:17 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Confused about timezones Skip Montanaro <skip@pobox.com> - 2013-10-23 11:17 -0500
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Date | 2013-10-23 11:17 -0500 |
| Subject | Confused about timezones |
| Message-ID | <mailman.1416.1382545517.18130.python-list@python.org> |
This isn't really a Python issue, though my problem solution will be
implemented in Python. If I have a naive datetime object for some time
in the past, it's not clear to me how the offset gets set correctly.
Consider this sequence:
>>> import datetime, pytz
>>> LOCAL_TZ = pytz.timezone(os.environ.get('TZ', "America/Chicago"))
>>> dt1 = datetime.datetime(2013, 5, 30, 0, 0) # DST in effect
>>> dt2 = datetime.datetime(2013, 1, 30, 0, 0) # no DST
>>> LOCAL_TZ.localize(dt1).utcoffset()
datetime.timedelta(-1, 68400)
>>> LOCAL_TZ.localize(dt2).utcoffset()
datetime.timedelta(-1, 64800)
Why is the UTC offset the same for both datetime objects despite the
presence/absence of Daylight Savings?
Thx,
Skip
Back to top | Article view | comp.lang.python
csiph-web