def __new__(cls, hour=None, minute=0, second=0, microsecond=0):
"""
hour may be a datetime.time or a str(Time)
"""
if hour is None or hour is Null:
return cls._null_time
nt = object.__new__(cls)
if isinstance(hour, basestring):
hour = Time.strptime(hour)
if isinstance(hour, (Time)):
nt._time = hour._time
elif isinstance(hour, (datetime.time)):
microsecond = hour.microsecond // 1000 * 1000
hour, minute, second = hour.hour, hour.minute, hour.second
nt._time = datetime.time(hour, minute, second, microsecond)
elif hour is not None:
microsecond = microsecond // 1000 * 1000
nt._time = datetime.time(hour, minute, second, microsecond)
return nt
评论列表
文章目录