Message160314
The datetime module says:
An object d of type time or datetime may be naive or aware. d is aware if d.tzinfo is not None and d.tzinfo.utcoffset(d) does not return None. If d.tzinfo is None, or if d.tzinfo is not None but d.tzinfo.utcoffset(d) returns None, d is naive.
However, I can create two non-naive timezones (under this definition) which throw an exception when they're compared, because one is being considered offset-naive:
>>> import pytz, datetime
>>> UTC_TZ = pytz.utc
>>> EASTERN_TZ = pytz.timezone('America/New_York')
>>> d1 = datetime.time(10, tzinfo = UTC_TZ)
>>> d1
datetime.time(10, 0, tzinfo=<UTC>)
>>> d1.tzinfo
<UTC>
>>> d1.utcoffset(d1)
datetime.timedelta(0)
>>> d2 = datetime.time(10, tzinfo = EASTERN_TZ)
>>> d2
datetime.time(10, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> d2.tzinfo
<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>
>>> d2.tzinfo.utcoffset(d2)
datetime.timedelta(-1, 68400)
>>> d1 < d2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't compare offset-naive and offset-aware times |
|
Date |
User |
Action |
Args |
2012-05-09 22:11:10 | Chris.Bergstresser | set | recipients:
+ Chris.Bergstresser |
2012-05-09 22:11:10 | Chris.Bergstresser | set | messageid: <1336601470.15.0.633873123281.issue14766@psf.upfronthosting.co.za> |
2012-05-09 22:11:09 | Chris.Bergstresser | link | issue14766 messages |
2012-05-09 22:11:09 | Chris.Bergstresser | create | |
|