From 426114879da49bf9a586b1991dcaf38ce594c4b6 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Thu, 14 Jan 2016 23:47:37 -0800 Subject: API: Make datetime64 timezone naive Fixes GH3290 With apologies to mwiebe, this rips out most of the time zone parsing from the datetime64 type. I think we mostly sorted out the API design in discussions last year, but I'll be posting this to the mailing list shortly to get feedback. Old behavior: # string parsing and printing defaults to your local timezone :( >>> np.datetime64('2000-01-01T00') numpy.datetime64('2000-01-01T00:00-0800','h') New behavior: # datetime64 is parsed and printed as timezone naive >>> np.datetime64('2000-01-01T00') numpy.datetime64('2000-01-01T00','h') # you can still supply a timezone, but you get a deprecation warning >>> np.datetime64('2000-01-01T00Z') DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future numpy.datetime64('2000-01-01T00','h') --- numpy/core/arrayprint.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'numpy/core/arrayprint.py') diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index c5b5b5a8f..74a9d3da3 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -708,9 +708,9 @@ class ComplexFormat(object): i = i + 'j' return r + i + class DatetimeFormat(object): - def __init__(self, x, unit=None, - timezone=None, casting='same_kind'): + def __init__(self, x, unit=None, timezone=None, casting='same_kind'): # Get the unit from the dtype if unit is None: if x.dtype.kind == 'M': @@ -718,15 +718,9 @@ class DatetimeFormat(object): else: unit = 's' - # If timezone is default, make it 'local' or 'UTC' based on the unit if timezone is None: - # Date units -> UTC, time units -> local - if unit in ('Y', 'M', 'W', 'D'): - self.timezone = 'UTC' - else: - self.timezone = 'local' - else: - self.timezone = timezone + timezone = 'naive' + self.timezone = timezone self.unit = unit self.casting = casting -- cgit v1.2.1