def _build_stoptimes(new_trip,trip): stoptimes = trip.stoptime_set.all().order_by('stop_sequence') new_stoptimes = [] for stoptime in stoptimes: new_stop = TtStop.objects.get(gtfs_stop_id=stoptime.stop.stop_id) exp_arrival = ot_utils.db_time_to_datetime(stoptime.arrival_time,new_trip.date) exp_departure = ot_utils.db_time_to_datetime(stoptime.departure_time,new_trip.date) new_stoptime = TtStopTime(stop=new_stop, stop_sequence=stoptime.stop_sequence, trip=new_trip, exp_arrival=exp_arrival, exp_departure=exp_departure) new_stoptimes.append(new_stoptime) TtStopTime.objects.bulk_create(new_stoptimes)
def load_from_gtfs(gtfs_stop_time, date): arrival = ot_utils.db_time_to_datetime(gtfs_stop_time.arrival_time, date) arrival = ot_utils.get_localtime(arrival) departure = ot_utils.db_time_to_datetime(gtfs_stop_time.departure_time, date) departure = ot_utils.get_localtime(departure) return DetectedStopTime(gtfs_stop_time.stop.stop_id, arrival, departure)