Skip to content

Commit 6484b9d

Browse files
changhiskhanwesm
authored andcommitted
BUG: Timestamp.astimezone returns datetime.datetime #2060
1 parent 116e44a commit 6484b9d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pandas/src/datetime.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ class Timestamp(_Timestamp):
238238
# Same UTC timestamp, different time zone
239239
return Timestamp(self.value, tz=tz)
240240

241+
astimezone = tz_convert
242+
241243
def replace(self, **kwds):
242244
return Timestamp(datetime.replace(self, **kwds),
243245
offset=self.offset)

pandas/tseries/tests/test_timezones.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ def test_tz_localize_dti(self):
137137
freq='L')
138138
self.assertRaises(pytz.NonExistentTimeError, dti.tz_localize, 'US/Eastern')
139139

140+
def test_astimezone(self):
141+
utc = Timestamp('3/11/2012 22:00', tz='UTC')
142+
expected = utc.tz_convert('US/Eastern')
143+
result = utc.astimezone('US/Eastern')
144+
self.assertEquals(expected, result)
145+
self.assert_(isinstance(result, Timestamp))
146+
140147
def test_create_with_tz(self):
141148
stamp = Timestamp('3/11/2012 05:00', tz='US/Eastern')
142149
self.assertEquals(stamp.hour, 5)

0 commit comments

Comments
 (0)