diff options
author | Stephan Hoyer <shoyer@gmail.com> | 2018-03-31 08:09:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-31 08:09:40 -0700 |
commit | 0440fb1a5578643e526d254762eee70e4859fb5d (patch) | |
tree | ed317c8ca40e2e5f1f8a8d1ca7ac259cd6703655 /numpy | |
parent | 256c6fcd5842c3b9aa897f37c868ba8f0c67b26c (diff) | |
parent | 942f986492f2a77bbac8e8ddfbc4fa480cf1809f (diff) | |
download | numpy-0440fb1a5578643e526d254762eee70e4859fb5d.tar.gz |
Merge pull request #10832 from orestisf1993/issue-10810
ENH: datetime64: support AC dates starting with '+'
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/datetime_strings.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_datetime.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c index 96cb66b95..4f9d8fa41 100644 --- a/numpy/core/src/multiarray/datetime_strings.c +++ b/numpy/core/src/multiarray/datetime_strings.c @@ -374,7 +374,7 @@ parse_iso_8601_datetime(char *str, Py_ssize_t len, } /* Leading '-' sign for negative year */ - if (*substr == '-') { + if (*substr == '-' || *substr == '+') { ++substr; --sublen; } diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 638994aee..ba291737a 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -1255,12 +1255,19 @@ class TestDateTime(object): # Allow space instead of 'T' between date and time assert_equal(np.array(['1980-02-29T01:02:03'], np.dtype('M8[s]')), np.array(['1980-02-29 01:02:03'], np.dtype('M8[s]'))) + # Allow positive years + assert_equal(np.array(['+1980-02-29T01:02:03'], np.dtype('M8[s]')), + np.array(['+1980-02-29 01:02:03'], np.dtype('M8[s]'))) # Allow negative years assert_equal(np.array(['-1980-02-29T01:02:03'], np.dtype('M8[s]')), np.array(['-1980-02-29 01:02:03'], np.dtype('M8[s]'))) # UTC specifier with assert_warns(DeprecationWarning): assert_equal( + np.array(['+1980-02-29T01:02:03'], np.dtype('M8[s]')), + np.array(['+1980-02-29 01:02:03Z'], np.dtype('M8[s]'))) + with assert_warns(DeprecationWarning): + assert_equal( np.array(['-1980-02-29T01:02:03'], np.dtype('M8[s]')), np.array(['-1980-02-29 01:02:03Z'], np.dtype('M8[s]'))) # Time zone offset |