|
19 | 19 | from pandas._libs import tslib, period
|
20 | 20 | from pandas._libs.tslibs.timezones import get_timezone
|
21 | 21 |
|
22 |
| -from pandas.compat import lrange, long |
| 22 | +from pandas.compat import lrange, long, PY3 |
23 | 23 | from pandas.util.testing import assert_series_equal
|
24 | 24 | from pandas.compat.numpy import np_datetime64_compat
|
25 | 25 | from pandas import (Timestamp, date_range, Period, Timedelta, compat,
|
@@ -1079,6 +1079,23 @@ def test_is_leap_year(self):
|
1079 | 1079 | dt = Timestamp('2100-01-01 00:00:00', tz=tz)
|
1080 | 1080 | assert not dt.is_leap_year
|
1081 | 1081 |
|
| 1082 | + def test_timestamp(self): |
| 1083 | + # GH#17329 |
| 1084 | + # tz-naive --> treat it as if it were UTC for purposes of timestamp() |
| 1085 | + ts = Timestamp.now() |
| 1086 | + uts = ts.replace(tzinfo=utc) |
| 1087 | + assert ts.timestamp() == uts.timestamp() |
| 1088 | + |
| 1089 | + tsc = Timestamp('2014-10-11 11:00:01.12345678', tz='US/Central') |
| 1090 | + utsc = tsc.tz_convert('UTC') |
| 1091 | + # utsc is a different representation of the same time |
| 1092 | + assert tsc.timestamp() == utsc.timestamp() |
| 1093 | + |
| 1094 | + if PY3: |
| 1095 | + # should agree with datetime.timestamp method |
| 1096 | + dt = ts.to_pydatetime() |
| 1097 | + assert dt.timestamp() == ts.timestamp() |
| 1098 | + |
1082 | 1099 |
|
1083 | 1100 | class TestTimestampNsOperations(object):
|
1084 | 1101 |
|
|
0 commit comments