Confusing datetime.datetime
Damjan
gdamjan at gmail.com
Thu Jul 5 22:05:38 EDT 2012
> from datetime import datetime, timedelta, tzinfo
> ZERO = timedelta(0)
> HOUR = timedelta(hours=1)
>
> class UTC(tzinfo):
> def utcoffset(self, dt):
> return ZERO
> def tzname(self, dt):
> return "UTC"
> def dst(self, dt):
> return ZERO
>
> utc = UTC()
> t1 = datetime.now(tz=utc)
> t2 = datetime(t1.year, t1.month, t1.day, tzinfo=utc)
> assert t1.tzinfo == t2.tzinfo
>
>
> No assertion error at all.
>
> This makes me think that the "retardation" as you put it is not in
> Python's datetime module at all, but in pytz.
>
> What does TZ == TZ give? If it returns False, I recommend you report it
> as a bug against the pytz module.
It returns True, so it seems to be changed in the datetime object??
I tried both 2.7 and 3.2
--
damjan
More information about the Python-list
mailing list