summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-09-30 14:04:06 -0700
committerCharles Harris <charlesr.harris@gmail.com>2011-10-01 09:43:10 -0600
commit6a3ca96df7179e745c76dc09a67bf37af3d818ce (patch)
tree6e969af8fc647a6783f55a4662973b6f1ee5af6d
parent90a54f4683926ffbe158f0d0ace76cf6a6a3bee3 (diff)
downloadnumpy-6a3ca96df7179e745c76dc09a67bf37af3d818ce.tar.gz
TST: Add tests for the Y2038 problem
This only seems to be cropping up on 32-bit Linux, where time_t is 32 bits, and there appears to be no 64-bit time_t extension like on Windows.
-rw-r--r--numpy/core/tests/test_datetime.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index 4dab25300..07dc86203 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -1688,6 +1688,24 @@ class TestDateTime(TestCase):
assert_equal(np.is_busday(holidays, busdaycal=bdd),
np.zeros(len(holidays), dtype='?'))
+ def test_datetime_y2038(self):
+ # Test parsing on either side of the Y2038 boundary
+ a = np.datetime64('2038-01-19T03:14:07Z')
+ assert_equal(a.view(np.int64), 2**31 - 1)
+ a = np.datetime64('2038-01-19T03:14:08Z')
+ assert_equal(a.view(np.int64), 2**31)
+
+ # Test parsing on either side of the Y2038 boundary with
+ # a manually specified timezone offset
+ a = np.datetime64('2038-01-19T04:14:07+0100')
+ assert_equal(a.view(np.int64), 2**31 - 1)
+ a = np.datetime64('2038-01-19T04:14:08+0100')
+ assert_equal(a.view(np.int64), 2**31)
+
+ # Test parsing a date after Y2038 in the local timezone
+ a = np.datetime64('2038-01-20T13:21:14')
+ assert_equal(str(a)[:-5], '2038-01-20T13:21:14')
+
class TestDateTimeData(TestCase):
def test_basic(self):