def test_pickle(self, ts, tz_aware_fixture): tz = tz_aware_fixture tz = maybe_get_tz(tz) ts = Timestamp._from_value_and_reso(ts.value, ts._reso, tz) rt = tm.round_trip_pickle(ts) assert rt._reso == ts._reso assert rt == ts
def test_tz_convert(self, ts): ts = Timestamp._from_value_and_reso(ts.value, ts._reso, utc) tz = pytz.timezone("US/Pacific") result = ts.tz_convert(tz) assert isinstance(result, Timestamp) assert result._reso == ts._reso assert tz_compare(result.tz, tz)
def test_as_unit_overflows(self): # microsecond that would be just out of bounds for nano us = 9223372800000000 ts = Timestamp._from_value_and_reso(us, NpyDatetimeUnit.NPY_FR_us.value, None) msg = "Cannot cast 2262-04-12 00:00:00 to unit='ns' without overflow" with pytest.raises(OutOfBoundsDatetime, match=msg): ts._as_unit("ns") res = ts._as_unit("ms") assert res.value == us // 1000 assert res._reso == NpyDatetimeUnit.NPY_FR_ms.value
def ts_tz(self, ts, tz_aware_fixture): tz = maybe_get_tz(tz_aware_fixture) return Timestamp._from_value_and_reso(ts.value, ts._reso, tz)