mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Fixed TimestampFromTicks for second values > 59.5.
Bug reported and fixed by Jozsef Szalay on 2010-05-06 at 14:11:59.999920.
This commit is contained in:
parent
b04bf41f99
commit
afea19651c
|
@ -1,3 +1,10 @@
|
|||
2010-05-07 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* psycopg/adapter_datetime.c: Fixed TimestampFromTicks for second
|
||||
values > 59.5.
|
||||
|
||||
Bug reported and fixed by Jozsef Szalay on 2010-05-06 at 14:11:59.999920.
|
||||
|
||||
2010-05-04 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* Added typecasters for arrays of specific MX/Py time-related types.
|
||||
|
|
|
@ -435,7 +435,7 @@ psyco_TimestampFromTicks(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "d", &ticks))
|
||||
return NULL;
|
||||
|
||||
t = (time_t)round(ticks);
|
||||
t = (time_t)floor(ticks);
|
||||
ticks -= (double)t;
|
||||
if (localtime_r(&t, &tm)) {
|
||||
PyObject *value = Py_BuildValue("iiiiidO",
|
||||
|
|
|
@ -478,6 +478,17 @@ if not hasattr(psycopg2._psycopg, 'MXDATETIME'):
|
|||
del mxDateTimeTests
|
||||
|
||||
|
||||
class TimestampFromTicksTestCase(unittest.TestCase):
|
||||
# bug "TimestampFromTicks() throws ValueError (2-2.0.14)"
|
||||
# reported by Jozsef Szalay on 2010-05-06
|
||||
def test_value_error_sec_59_99(self):
|
||||
from datetime import datetime
|
||||
s = psycopg2.TimestampFromTicks(1273173119.99992)
|
||||
self.assertEqual(s.adapted,
|
||||
datetime(2010, 5, 6, 14, 11, 59, 999920,
|
||||
tzinfo=FixedOffsetTimezone(-5 * 60)))
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user