[egenix-users] Date conversion weirdness

M.-A. Lemburg mal at lemburg.com
Tue Oct 8 14:18:24 CEST 2002


Graham Ashton wrote:
> Hi. Can anybody explain what is happening here, and how I should get
> round it?
> 
> % python
> Python 2.2 (#2, Mar 11 2002, 13:24:00) 
> [GCC 2.95.3 20010315 (release)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>>from mx.DateTime import DateTime, gmtime
>>>>dt = DateTime(1971, 06, 23)
>>>>dt2 = gmtime(dt)
>>>>dt2.strftime('%d-%b-%Y')
> 
> '22-Jun-1971'
> 
> I was expecting 23-Jun-1971 to pop out of the end of there.

The outcome depends on your local time zone:

 >>> dt = DateTime(1971, 06, 23)
 >>> dt
<DateTime object for '1971-06-23 00:00:00.00' at 817d998>
 >>> gmtime(dt)
<DateTime object for '1971-06-22 23:00:00.00' at 81b3ae0>

(this is GMT+1)

> It doesn't happen for most dates, but seems to be a problem for a
> significant portion of 1971!

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/




More information about the egenix-users mailing list