diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2012-02-19 14:49:36 -0800 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2012-02-19 14:49:36 -0800 |
commit | 1ef79b71e18e6ab00002447128f617003b05af29 (patch) | |
tree | 421c933e703283c87a6c7163e632ad4e40c531a6 | |
parent | 16d49fda2516d5a76f973302db96c751bba8a7ca (diff) | |
download | numpy-1ef79b71e18e6ab00002447128f617003b05af29.tar.gz |
BUG: datetime: Restrict 'local' timezone print to >= 1970
On the Windows platform, the library calls fail before 1970.
For NumPy consistency across platforms, we have chosen to
apply this in every case.
-rw-r--r-- | numpy/core/src/multiarray/datetime_strings.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c index 97d170230..00879aede 100644 --- a/numpy/core/src/multiarray/datetime_strings.c +++ b/numpy/core/src/multiarray/datetime_strings.c @@ -1016,8 +1016,18 @@ make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen, return 0; } - /* Only do local time within a reasonable year range */ - if ((dts->year <= 1800 || dts->year >= 10000) && tzoffset == -1) { + /* + * Only do local time within a reasonable year range. The years + * earlier than 1970 are not made local, because the Windows API + * raises an error when they are attempted. For consistency, this + * restriction is applied to all platforms. + * + * Note that this only affects how the datetime becomes a string. + * The result is still completely unambiguous, it only means + * that datetimes outside this range will not include a time zone + * when they are printed. + */ + if ((dts->year < 1970 || dts->year >= 10000) && tzoffset == -1) { local = 0; } |