Skip to content

Commit

Permalink
ENH/CLN: make Timestamp repr executable, like datetime
Browse files Browse the repository at this point in the history
PTF
  • Loading branch information
y-p committed Apr 23, 2013
1 parent 334b4db commit b7b36b1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,25 @@ class Timestamp(_Timestamp):

def __repr__(self):
result = self._repr_base
zone = None

try:
result += self.strftime('%z')
if self.tzinfo:
zone = _get_zone(self.tzinfo)
result += _tz_format(self, zone)
except ValueError:
year2000 = self.replace(year=2000)
result += year2000.strftime('%z')
if self.tzinfo:
zone = _get_zone(self.tzinfo)
result += _tz_format(year2000, zone)

return '<Timestamp: %s>' % result
try:
result += zone.strftime(' %%Z')
except:
pass
zone = "'%s'" % zone if zone else 'None'

return "Timestamp('%s', tz=%s)" % (result,zone)

@property
def _repr_base(self):
Expand Down

0 comments on commit b7b36b1

Please sign in to comment.