Confusing DateTime().strftime behavior
I'm upgrading our server from a FoxPro backend to PostgreSQL, using the Psycopg connector. My problem is that the old database returned timestamps as a "%m/%d/%Y"-formatted string, while Psycopg returns a DateTime object (I'm using the internal module, not mxDateTime). Whenever I use strftime to format the object for display, I get the previous day's date instead. I've found several references to this problem in Google, but no one seems to have found a good solution. Any thoughts? -- Kirk Strauser The Day Companies
--On 15. Oktober 2005 01:19:56 -0500 Kirk Strauser <kirk@daycos.com> wrote:
I'm upgrading our server from a FoxPro backend to PostgreSQL, using the Psycopg connector. My problem is that the old database returned timestamps as a "%m/%d/%Y"-formatted string, while Psycopg returns a DateTime object (I'm using the internal module, not mxDateTime). Whenever I use strftime to format the object for display, I get the previous day's date instead.
If you speak of DateTime instances then you should be able to write to two-line testcase that shows the issue with a standard Zope installation. If you can provide such a testcase we are able to look at it in detail. -aj
On Saturday 15 October 2005 01:24, Andreas Jung wrote:
If you speak of DateTime instances then you should be able to write to two-line testcase that shows the issue with a standard Zope installation. If you can provide such a testcase we are able to look at it in detail.
######## date = context.testQuery()[0]['date'] print date print date.ISO() print date.strftime('%m/%d/%Y') return ######## gives ######## 2005/10/14 2005-10-14 00:00:00 10/13/2005 ######## By the way, this is with Zope 2.7.7 and Python 2.3.5 on a FreeBSD 5-STABLE server (if that makes any difference). -- Kirk Strauser The Day Companies
--On 16. Oktober 2005 10:41:19 -0500 Kirk Strauser <kirk@daycos.com> wrote:
On Saturday 15 October 2005 01:24, Andreas Jung wrote:
If you speak of DateTime instances then you should be able to write to two-line testcase that shows the issue with a standard Zope installation. If you can provide such a testcase we are able to look at it in detail.
######## date = context.testQuery()[0]['date']
This might work for you on your system but that is unusable to reproduce your error on a bare Zope system. -aj
Are you using Python 2.4? I've seen other people here on the list having problems witht he DateTime module and it being a day off. Search the archive on 'strftime' and hope. 2005/10/15, Kirk Strauser <kirk@daycos.com>:
I'm upgrading our server from a FoxPro backend to PostgreSQL, using the Psycopg connector. My problem is that the old database returned timestamps as a "%m/%d/%Y"-formatted string, while Psycopg returns a DateTime object (I'm using the internal module, not mxDateTime). Whenever I use strftime to format the object for display, I get the previous day's date instead.
I've found several references to this problem in Google, but no one seems to have found a good solution. Any thoughts? -- Kirk Strauser The Day Companies _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (3)
-
Andreas Jung -
Kirk Strauser -
Peter Bengtsson