Replying to myself, I've changed to gmtime rather than localtime and
this solves my immediate problem. This is a bit counter-intuitive,
however. I suspect I still have an issue with locale.

Scott Holmes wrote:
I've just run into an issue with the use of localtime and strftime. It
appears that localtime is dropping the value provided by the database
record by eight (8) hours. It is only doing this for the representation
of time (H:M) not the date. I have this bit of code:

print "DB Time: ", app_date, " ", start_time, " Python
Time:",time.strftime('%m/%d/%Y', time.localtime(app_date)), " ",
time.strftime('%H:%M', time.localtime(start_time))

This results in:

DB Time: 2000-12-31 00:00:00.00 06:45:00.00 Python Time: 12/31/2000

Actually, I did this for a number of dates and times. I would expect
the python date to be 12/30/2000

I would like to avoid this conversion of times altogether and just trust
the value contained in the database. I suspect it may have something to
do with locale, but I haven't delved that far into Python yet to know
how to deal with that issue.

Scott Holmes http://sholmes.ws
scottholmes at sbcglobal.net

Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppython-list @
postedAug 14, '03 at 8:14p
activeAug 14, '03 at 9:14p

1 user in discussion

Scott Holmes: 2 posts



site design / logo © 2022 Grokbase