FAQ
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
22:45

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
http://pages.sbcglobal.net/scottholmes
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

Follow ups

Related Discussions

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

1 user in discussion

Scott Holmes: 2 posts

People

Translate

site design / logo © 2022 Grokbase