Changeset View
Changeset View
Standalone View
Standalone View
swh/model/model.py
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | def check_offset(self, attribute, value): | ||||
if not (-2**15 <= value < 2**15): | if not (-2**15 <= value < 2**15): | ||||
# max 14 hours offset in theory, but you never know what | # max 14 hours offset in theory, but you never know what | ||||
# you'll find in the wild... | # you'll find in the wild... | ||||
raise ValueError('offset too large: %d minutes' % value) | raise ValueError('offset too large: %d minutes' % value) | ||||
@classmethod | @classmethod | ||||
def from_dict(cls, d): | def from_dict(cls, d): | ||||
"""Builds a TimestampWithTimezone from any of the formats | """Builds a TimestampWithTimezone from any of the formats | ||||
accepted by :py:`swh.model.normalize_timestamp`.""" | accepted by :func:`swh.model.normalize_timestamp`.""" | ||||
d = normalize_timestamp(d) | d = normalize_timestamp(d) | ||||
return cls( | return cls( | ||||
timestamp=Timestamp.from_dict(d['timestamp']), | timestamp=Timestamp.from_dict(d['timestamp']), | ||||
offset=d['offset'], | offset=d['offset'], | ||||
negative_utc=d['negative_utc']) | negative_utc=d['negative_utc']) | ||||
@attr.s(frozen=True) | @attr.s(frozen=True) | ||||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |