|
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,
|
@@ -1097,6 +1097,23 @@ def test_is_leap_year(self):
|
1097 | 1097 | dt = Timestamp('2100-01-01 00:00:00', tz=tz)
|
1098 | 1098 | assert not dt.is_leap_year
|
1099 | 1099 |
|
| 1100 | + def test_timestamp(self): |
| 1101 | + # GH#17329 |
| 1102 | + # tz-naive --> treat it as if it were UTC for purposes of timestamp() |
| 1103 | + ts = Timestamp.now() |
| 1104 | + uts = ts.replace(tzinfo=utc) |
| 1105 | + assert ts.timestamp() == uts.timestamp() |
| 1106 | + |
| 1107 | + tsc = Timestamp('2014-10-11 11:00:01.12345678', tz='US/Central') |
| 1108 | + utsc = tsc.tz_convert('UTC') |
| 1109 | + # utsc is a different representation of the same time |
| 1110 | + assert tsc.timestamp() == utsc.timestamp() |
| 1111 | + |
| 1112 | + if PY3: |
| 1113 | + # should agree with datetime.timestamp method |
| 1114 | + dt = ts.to_pydatetime() |
| 1115 | + assert dt.timestamp() == ts.timestamp() |
| 1116 | + |
1100 | 1117 |
|
1101 | 1118 | class TestTimestampNsOperations(object):
|
1102 | 1119 |
|
|
0 commit comments