def translate(self, value, topython=True): if topython: if isinstance(value, six.string_types) and len(value): return Time(value).time else: return None else: if isinstance(value, dt.date): return str(Time(value)) else: return value
def testConvertToString(self, input, output): assert str(Time(input)) == output
def testConstructFromString_timezone(self, string, h, m, s, micros, tz_h, tz_m): tzdelta = datetime.timedelta(hours=tz_h, minutes=tz_m) tzinfo = FixedOffsetTimezone(tzdelta) ref = datetime.time(h, m, s, micros, tzinfo=tzinfo) assert Time(string).value == ref
def testConstructFromString_subsecondRounding(self, string, h, m, s, micros): assert Time(string).value == datetime.time(h, m, s, micros)
def testConstructFromTime(self): time = datetime.time(1, 1) assert Time(time).value is time time.replace(tzinfo=UtcTimezone()) assert Time(time).value is time