[egenix-users] Date conversion weirdness

Steve Holden sholden at holdenweb.com
Tue Oct 8 09:14:42 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.
>
> It doesn't happen for most dates, but seems to be a problem for a
> significant portion of 1971!
>

Strange. I wonder if this is dependent on your time zone? Or perhaps your
mxDateTime version? It works for me both under Cygwin (shown below) and
vanillla Windows Python 2.2.

Python 2.2.1 (#1, Jun 25 2002, 10:55:46)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from mx.DateTime import DateTime, gmtime
>>> dt = DateTime(1971, 06, 23)
>>> dt2 = gmtime(dt)
>>> dt2
<DateTime object for '1971-06-23 04:00:00.00' at 10117100>
>>> dt2.strftime('%d-%b-%Y')
'23-Jun-1971'
>>>

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------





More information about the egenix-users mailing list