pytz and timezone specialists
Ned Deily
nad at acm.org
Fri Dec 5 14:46:47 EST 2008
In article
<1f6172c1-4f70-42ea-8010-b72beb0af487 at w24g2000prd.googlegroups.com>,
manatlan <manatlan at gmail.com> wrote:
> Here is a really simple code :
> -------------------------------------------------------
> from datetime import datetime
> from pytz import timezone
>
> tz=timezone("Europe/Paris")
>
> d=datetime(2008,12,12,19,00,00,tzinfo=tz)
> print d.isoformat()
>
> d=datetime.now(tz)
> print d.isoformat()
> -------------------------------------------------------
> when I run it, it displays (according current time ;-):
>
> 2008-12-12T19:00:00+00:09
> 2008-12-05T19:15:38.135467+01:00
>
> The Europe/Paris timezone is GMT+1 ... the second date seems to be
> right (+01:00 at the end)
>
> But why the first date ends with "+00:09" ?!? it should be +01:00 ...
> no ?!
> Where's the bug ?!? (sure : it's me ;-) ... but i don't understand
> this simple thing)
>>> tz = timezone("Europe/Paris")
>>> d = tz.localize(datetime(2008,12,12,19,00,00))
>>> print d.isoformat()
2008-12-12T19:00:00+01:00
<http://pytz.sourceforge.net/>
"This library only supports two ways of building a localized time. The
first is to use the .localize() method provided by the pytz library.
This is used to localize a naive datetime (datetime with no timezone
information). ... Unfortunately using the tzinfo argument of the
standard datetime constructors ''does not work'' with pytz for many
timezones."
--
Ned Deily,
nad at acm.org
More information about the Python-list
mailing list