示例#1
0
 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
示例#2
0
    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)
示例#3
0
    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
示例#4
0
 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)