def test_onOffset_deprecated(self, offset_types): # GH#30340 use idiomatic naming off = self._get_offset(offset_types) ts = Timestamp.now() with tm.assert_produces_warning(FutureWarning): result = off.onOffset(ts) expected = off.is_on_offset(ts) assert result == expected
def test_rsub_dtscalars(self, tz_naive_fixture): # In particular, check that datetime64 - Timestamp works GH#28286 td = Timedelta(1235345642000) ts = Timestamp.now(tz_naive_fixture) other = ts + td assert other - ts == td assert other.to_pydatetime() - ts == td if tz_naive_fixture is None: assert other.to_datetime64() - ts == td else: msg = "subtraction must have" with pytest.raises(TypeError, match=msg): other.to_datetime64() - ts
def test_timestamp(self): # GH#17329 # tz-naive --> treat it as if it were UTC for purposes of timestamp() ts = Timestamp.now() uts = ts.replace(tzinfo=utc) assert ts.timestamp() == uts.timestamp() tsc = Timestamp("2014-10-11 11:00:01.12345678", tz="US/Central") utsc = tsc.tz_convert("UTC") # utsc is a different representation of the same time assert tsc.timestamp() == utsc.timestamp() # datetime.timestamp() converts in the local timezone with tm.set_timezone("UTC"): # should agree with datetime.timestamp method dt = ts.to_pydatetime() assert dt.timestamp() == ts.timestamp()
def test_radd_tdscalar(self, td): # GH#24775 timedelta64+Timestamp should not raise ts = Timestamp.now() assert td + ts == ts + td