def map_from_json(json_slots):
slots = []
for json_slot in json_slots:
from_long = json_slot['start'] / 1e3
if from_long < TimeSlot.time_to_long(datetime.min):
from_long = TimeSlot.time_to_long(datetime.min)
duration_long = json_slot['duration'] / 1e3
to_long = from_long + duration_long
if to_long > TimeSlot.time_to_long(datetime.max):
to_long = TimeSlot.time_to_long(datetime.max)
fr = datetime.fromtimestamp(from_long)
to = datetime.fromtimestamp(to_long)
slots.append(TimeSlot(fr, to))
return slots
评论列表
文章目录