diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/datetime_strings.c | 9 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/datetime_strings.h | 2 | ||||
| -rw-r--r-- | numpy/core/tests/test_datetime.py | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c index 716453c95..b9aeda508 100644 --- a/numpy/core/src/multiarray/datetime_strings.c +++ b/numpy/core/src/multiarray/datetime_strings.c @@ -885,15 +885,16 @@ lossless_unit_from_datetimestruct(npy_datetimestruct *dts) * string was too short). */ NPY_NO_EXPORT int -make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen, +make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, npy_intp outlen, int local, int utc, NPY_DATETIMEUNIT base, int tzoffset, NPY_CASTING casting) { npy_datetimestruct dts_local; int timezone_offset = 0; - char *substr = outstr, sublen = outlen; - int tmplen; + char *substr = outstr; + npy_intp sublen = outlen; + npy_intp tmplen; /* Handle NaT, and treat a datetime with generic units as NaT */ if (dts->year == NPY_DATETIME_NAT || base == NPY_FR_GENERIC) { @@ -1321,7 +1322,7 @@ add_time_zone: string_too_short: PyErr_Format(PyExc_RuntimeError, "The string provided for NumPy ISO datetime formatting " - "was too short, with length %d", + "was too short, with length %"NPY_INTP_FMT, outlen); return -1; } diff --git a/numpy/core/src/multiarray/datetime_strings.h b/numpy/core/src/multiarray/datetime_strings.h index d7608565c..4e60ce929 100644 --- a/numpy/core/src/multiarray/datetime_strings.h +++ b/numpy/core/src/multiarray/datetime_strings.h @@ -70,7 +70,7 @@ get_datetime_iso_8601_strlen(int local, NPY_DATETIMEUNIT base); * string was too short). */ NPY_NO_EXPORT int -make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen, +make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, npy_intp outlen, int local, int utc, NPY_DATETIMEUNIT base, int tzoffset, NPY_CASTING casting); diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 92a1325bc..6fc198b0d 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -543,6 +543,10 @@ class TestDateTime(object): assert_equal(dt_a, dt_b) # Datetime to unicode assert_equal(str_a, dt_a.astype('U')) + + # Datetime to long string - gh-9712 + assert_equal(str_a, dt_a.astype((np.string_, 128))) + str_b = np.empty(str_a.shape, dtype=(np.string_, 128)) str_b[...] = dt_a assert_equal(str_a, str_b) |
