class TimestampOps: params = [None, "US/Eastern", pytz.UTC, dateutil.tz.tzutc()] param_names = ["tz"] def setup(self, tz): self.ts = Timestamp("2017-08-25 08:16:14", tz=tz) def time_replace_tz(self, tz): self.ts.replace(tzinfo=pytz.timezone("US/Eastern")) def time_replace_None(self, tz): self.ts.replace(tzinfo=None) def time_to_pydatetime(self, tz): self.ts.to_pydatetime() def time_normalize(self, tz): self.ts.normalize() def time_tz_convert(self, tz): if self.ts.tz is not None: self.ts.tz_convert(tz) def time_tz_localize(self, tz): if self.ts.tz is None: self.ts.tz_localize(tz) def time_to_julian_date(self, tz): self.ts.to_julian_date() def time_floor(self, tz): self.ts.floor("5T") def time_ceil(self, tz): self.ts.ceil("5T")
class TimestampOps(object): params = [None, 'US/Eastern', pytz.UTC, dateutil.tz.tzutc()] param_names = ['tz'] def setup(self, tz): self.ts = Timestamp('2017-08-25 08:16:14', tz=tz) def time_replace_tz(self, tz): self.ts.replace(tzinfo=pytz.timezone('US/Eastern')) def time_replace_None(self, tz): self.ts.replace(tzinfo=None) def time_to_pydatetime(self, tz): self.ts.to_pydatetime() def time_normalize(self, tz): self.ts.normalize() def time_tz_convert(self, tz): if self.ts.tz is not None: self.ts.tz_convert(tz) def time_tz_localize(self, tz): if self.ts.tz is None: self.ts.tz_localize(tz) def time_to_julian_date(self, tz): self.ts.to_julian_date() def time_floor(self, tz): self.ts.floor('5T') def time_ceil(self, tz): self.ts.ceil('5T')
def test_non_nano_fields(self, dt64, ts): alt = Timestamp(dt64) assert ts.year == alt.year assert ts.month == alt.month assert ts.day == alt.day assert ts.hour == ts.minute == ts.second == ts.microsecond == 0 assert ts.nanosecond == 0 assert ts.to_julian_date() == alt.to_julian_date() assert ts.weekday() == alt.weekday() assert ts.isoweekday() == alt.isoweekday()
class TimestampOps: params = [None, 'US/Eastern', pytz.UTC, dateutil.tz.tzutc()] param_names = ['tz'] def setup(self, tz): self.ts = Timestamp('2017-08-25 08:16:14', tz=tz) def time_replace_tz(self, tz): self.ts.replace(tzinfo=pytz.timezone('US/Eastern')) def time_replace_None(self, tz): self.ts.replace(tzinfo=None) def time_to_pydatetime(self, tz): self.ts.to_pydatetime() def time_normalize(self, tz): self.ts.normalize() def time_tz_convert(self, tz): if self.ts.tz is not None: self.ts.tz_convert(tz) def time_tz_localize(self, tz): if self.ts.tz is None: self.ts.tz_localize(tz) def time_to_julian_date(self, tz): self.ts.to_julian_date() def time_floor(self, tz): self.ts.floor('5T') def time_ceil(self, tz): self.ts.ceil('5T')