[egenix-users] date display behavior in mxdatetime 3
M.-A. Lemburg
mal at egenix.com
Fri Feb 29 21:15:15 CET 2008
On 2008-02-29 20:58, M.-A. Lemburg wrote:
> On 2008-02-29 20:51, Eugene Chow wrote:
>> I've noticed that date display behavior has changed in version 3 of
>> mxdatetime in an undesirable way:
>>
>> Python 2.4.3 (#1, Apr 7 2006, 10:54:33)
>> [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import mx.DateTime
>>>>> mx.DateTime.__version__
>> '3.0.0'
>>>>> d=mx.DateTime.Date(2008,1,-1)
>>>>> d
>> <mx.DateTime.DateTime object for '2008-01--1 00:00:00.00' at 63e90>
>>>>> d.strftime()
>> 'Thu Jan -1 00:00:00 2008'
>>>>> d==mx.DateTime.Date(2008,1,31)
>> True
>> In version 2, the day is displayed as the actual last day of the month
>> and not "-1".
>>
>> Was this change intentional?
>
> No, that's a bug. Thanks for reporting it. We'll fix it in 3.0.1.
That appears to be a GCC compiler optimizer - the normalization seems
to have been "optimized" away.
By adding this patch (which does really do anything):
Index: mxDateTime.c
===================================================================
--- mxDateTime.c (revision 22888)
+++ mxDateTime.c (working copy)
@@ -1022,6 +1022,9 @@
DPRINTF("mxDateTime_SetFromDateAndTime: "
"yearoffset=%ld absdate=%ld\n",
yearoffset,absdate);
+ DPRINTF("mxDateTime_SetFromDateAndTime: using normalized values:"
+ "year=%i month=%i day=%i\n",
+ year,month,day);
datetime->absdate = absdate;
the correct result gets used:
>>> import mx.DateTime
>>> mx.DateTime.Date(2008,1,-1).day
31
We'll have to see how we can make GCC do the right thing in all
cases and add a test case for this.
Thanks,
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Feb 29 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the egenix-users
mailing list