diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-06-03 18:15:04 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-06-03 18:15:04 -0500 |
commit | 283b2e712bd52e6661f2dc338eb14caae2f5a8da (patch) | |
tree | 0d8d4b4fd5e6c10c524e9f6f2bf4c4ccee0bd170 /numpy/core/arrayprint.py | |
parent | de719936cf64df1a8f1096fb7f3a2be720906da4 (diff) | |
download | numpy-283b2e712bd52e6661f2dc338eb14caae2f5a8da.tar.gz |
ENH: datetime: Finish fixing up datetime printing, add datetime to string function with several options
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index c02d3e0a1..8595d6f02 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -15,7 +15,7 @@ __docformat__ = 'restructuredtext' import sys import numerictypes as _nt from umath import maximum, minimum, absolute, not_equal, isnan, isinf -from multiarray import format_longfloat +from multiarray import format_longfloat, datetime_as_string from fromnumeric import ravel @@ -245,7 +245,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', 'complexfloat' : ComplexFormat(data, precision, suppress_small), 'longcomplexfloat' : LongComplexFormat(precision), - 'datetime' : DatetimeFormat(True, None), + 'datetime' : DatetimeFormat(True, None, -1), 'timedelta' : TimedeltaFormat(data), 'numpystr' : repr, 'str' : str} @@ -698,12 +698,16 @@ class ComplexFormat(object): return r + i class DatetimeFormat(object): - def __init__(self, uselocaltime=True, overrideunit=None): + def __init__(self, uselocaltime=True, overrideunit=None, tzoffset=-1): self.local = uselocaltime self.unit = overrideunit + self.tzoffset = -1 def __call__(self, x): - return "'%s'" % str(x) + return "'%s'" % datetime_as_string(x, + local=self.local, + unit=self.unit, + tzoffset=self.tzoffset) class TimedeltaFormat(object): def __init__(self, data): |