Message142150
On 16/08/2011, at 1:06, R. David Murray wrote:
> R. David Murray <rdmurray@bitdance.com> added the comment:
>
> Ah. Well, pre-3.2 datetime itself did not generate *any* non-naive datetimes.
>
> Nor do you need to specify everything for replace. dt.replace(tzinfo=tz) should work just fine.
OK.
I did try this and it seems broken though..
In [19]: now = datetime.datetime.utcnow()
In [21]: now.replace(tzinfo = pytz.utc)
Out[21]: datetime.datetime(2011, 8, 15, 22, 54, 13, 173110, tzinfo=<UTC>)
In [22]: datetime.datetime.strftime(now, "%s")
Out[22]: '1313414653'
In [23]: now
Out[23]: datetime.datetime(2011, 8, 15, 22, 54, 13, 173110)
[ur 8:22] ~ >date -ujr 1313414653
Mon 15 Aug 2011 13:24:13 UTC
i.e. it appears that replace() applies the TZ offset to a naive datetime object effectively assuming it is local time rather than un-timezoned (which is what the docs imply to me)
> ----------
> resolution: -> invalid
> stage: -> committed/rejected
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue12750>
> _______________________________________
> |
|
Date |
User |
Action |
Args |
2011-08-15 22:57:04 | Daniel.O'Connor | set | recipients:
+ Daniel.O'Connor, r.david.murray |
2011-08-15 22:57:03 | Daniel.O'Connor | link | issue12750 messages |
2011-08-15 22:57:03 | Daniel.O'Connor | create | |
|