Leap seconds and mx.DateTime
Hello,
on another topic - a while ago, we discovered a small inconsistency in the handling of leap seconds in
mx.DateTime; some checks assume that a day is not longer than 86400 seconds, although of course on a day
with a leap second this would be 86401 seconds.
I've attached a patch (against the 3.2.2 dev version from another discussion thread) that has fixed the
issue for us; maybe it or an improved version could make it's way into one of the next releases...
Thanks a lot,
Christian.
diff -r -C3 egenix-mx-base-3.2.2_dev_20120103.orig/mx/DateTime/mxDateTime/mxDateTime.c egenix-mx-base-3.2.2_dev_20120103/mx/DateTime/mxDateTime/mxDateTime.c
*** egenix-mx-base-3.2.2_dev_20120103.orig/mx/DateTime/mxDateTime/mxDateTime.c 2012-01-03
19:57:19.000000000 +0100
--- egenix-mx-base-3.2.2_dev_20120103/mx/DateTime/mxDateTime/mxDateTime.c 2012-01-05
01:05:34.918070159 +0100
***************
*** 1161,1167 ****
/* Special case for leap seconds */
hour = 23;
minute = 59;
! second = 60.0;
}
else {
hour = inttime / 3600;
--- 1161,1167 ----
/* Special case for leap seconds */
hour = 23;
minute = 59;
! second = 60.0 + abstime - (int) abstime;
}
else {
hour = inttime / 3600;
***************
*** 1290,1298 ****
(int)abstime);
/* Bounds check */
! Py_AssertWithArg(abstime >= 0.0 && abstime <= SECONDS_PER_DAY,
mxDateTime_RangeError,
! "abstime out of range (0.0 - 86400.0): %f",
abstime);
datetime->absdate = absdate;
--- 1290,1298 ----
(int)abstime);
/* Bounds check */
! Py_AssertWithArg(abstime >= 0.0 && abstime < SECONDS_PER_DAY + (double) 1.0,
mxDateTime_RangeError,
! "abstime out of range (0.0 - 86401.0): %f",
abstime);
datetime->absdate = absdate;
diff -r -C3
egenix-mx-base-3.2.2_dev_20120103.orig/mx/DateTime/mxDateTime/mxDateTime_Python.py egenix-mx-base-3.2.2_dev_20120103/mx/DateTime/mxDateTime/mxDateTime_Python.py
***
egenix-mx-base-3.2.2_dev_20120103.orig/mx/DateTime/mxDateTime/mxDateTime_Python.py 2001-06-24
15:54:29.000000000 +0200
---
egenix-mx-base-3.2.2_dev_20120103/mx/DateTime/mxDateTime/mxDateTime_Python.py 2012-01-05
01:05:34.919070169 +0100
***************
*** 319,326 ****
if abstime < 0 and abstime > -0.001: abstime = 0.0
if not (absdate > 0):
raise RangeError, "absdate out of range (>0)"
! if not (abstime >= 0.0 and abstime <= 86400.0):
! raise RangeError, "abstime out of range (0.0 - 86400.0) <%s>" % abstime
dt.absdate=absdate
dt.abstime=abstime
--- 319,326 ----
if abstime < 0 and abstime > -0.001: abstime = 0.0
if not (absdate > 0):
raise RangeError, "absdate out of range (>0)"
! if not (abstime >= 0.0 and abstime < 86401.0):
! raise RangeError, "abstime out of range (0.0 - 86401.0) <%s>" % abstime
dt.absdate=absdate
dt.abstime=abstime
_______________________________________________________________________
eGenix.com User Mailing List http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users