Daniel O'Connor <dar...@dons.net.au> added the comment: On 16/08/2011, at 1:06, R. David Murray wrote: > R. David Murray <rdmur...@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 <rep...@bugs.python.org> > <http://bugs.python.org/issue12750> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12750> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com