diff options
author | Simon Blyth <simon.c.blyth@gmail.com> | 2010-12-10 20:20:38 +0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-01-08 20:57:05 -0700 |
commit | d43668c6284bc5cef4da155dcca6800b003294b7 (patch) | |
tree | e20aaddfbd6d0cc8fcbe1aad5806bdcf8157b3b1 | |
parent | 945126079dd1e48c96629799108a3dec91809085 (diff) | |
download | numpy-d43668c6284bc5cef4da155dcca6800b003294b7.tar.gz |
fix for datetime64[s] hours exceeding 24 and test to demonstrate
-rw-r--r-- | numpy/core/src/multiarray/datetime.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_datetime.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/datetime.c b/numpy/core/src/multiarray/datetime.c index 83c95bef3..9de35de88 100644 --- a/numpy/core/src/multiarray/datetime.c +++ b/numpy/core/src/multiarray/datetime.c @@ -596,7 +596,7 @@ PyArray_DatetimeToDatetimeStruct(npy_datetime val, NPY_DATETIMEUNIT fr, ymd = days_to_ymdstruct((val - 86399) / 86400); sec = 86399 + (val + 1) % 86400; } - hms = seconds_to_hmsstruct(val); + hms = seconds_to_hmsstruct(sec); year = ymd.year; month = ymd.month; day = ymd.day; diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 02131fa3d..9cbfde134 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -12,6 +12,12 @@ class TestDateTime(TestCase): dt2 = np.dtype('m8[%s]' % unit) assert dt2 == np.dtype('timedelta64[%s]' % unit) + + def test_hours(self): + t = np.ones(3, dtype='M8[s]') + t[0] = 60*60*24 + 60*60*10 + assert t[0].item().hour == 10 + def test_divisor_conversion_year(self): assert np.dtype('M8[Y/4]') == np.dtype('M8[3M]') assert np.dtype('M8[Y/13]') == np.dtype('M8[4W]') |