fromutc: dt.tzinfo is not self: pytz.timezone('UTC').fromutc(datetime.utcnow())

A

aspineux

hi
datetime.datetime(2011, 10, 19, 7, 54, 45, 579125,
Traceback (most recent call last):
datetime.datetime(2011, 10, 19, 9, 55, 47, 787937, tzinfo=<DstTzInfo
'Europe/Brussels' CEST+2:00:00 DST>)

Why does UTC fail ?
Bug or feature ?
 
C

Chris Rebert

hi

datetime.datetime(2011, 10, 19, 7, 54, 45, 579125,

Traceback (most recent call last):

datetime.datetime(2011, 10, 19, 9, 55, 47, 787937, tzinfo=<DstTzInfo
'Europe/Brussels' CEST+2:00:00 DST>)

Why does UTC fail ?
Bug or feature ?

Dunno, but it might be worth noting that the examples in the pytz docs
don't use .fromutc(). Have you tried using .localize() instead? Or
specifically in the case of UTC,
datetime.utcnow().replace(tzinfo=pytz.utc) ?

Cheers,
Chris
 
S

Steven D'Aprano

hi

datetime.datetime(2011, 10, 19, 7, 54, 45, 579125, tzinfo=<StaticTzInfo
'GMT0'>)
Traceback (most recent call last):

datetime.datetime(2011, 10, 19, 9, 55, 47, 787937, tzinfo=<DstTzInfo
'Europe/Brussels' CEST+2:00:00 DST>)

Why does UTC fail ?
Bug or feature ?


Looks like a bug to me. But I'm not an expert on pytz. Perhaps you should
report it back to the package author.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top