lib/gtfs/realtime/stop_time.rb in gtfs-realtime-0.3.0 vs lib/gtfs/realtime/stop_time.rb in gtfs-realtime-0.4.0

- old
+ new

@@ -1,10 +1,11 @@ module GTFS class Realtime class StopTime < GTFS::Realtime::Model - many_to_one :trip - many_to_one :stop + belongs_to :trip + belongs_to :trip_update, primary_key: :trip_id, foreign_key: :trip_id + belongs_to :stop attr_accessor :actual_arrival_time, :actual_arrival_delay, :actual_departure_time, :actual_departure_delay def live? actual_arrival_time || actual_arrival_delay || actual_departure_time || actual_departure_delay @@ -36,20 +37,19 @@ end private def self.parse_time(time, date = Date.today) - # TODO: handle case where date != Date.today day_adjustment = 0 hour = time[0...2].to_i # handle timestamps like "24:30" if hour >= 24 days = hour / 24 time[0...2] = (hour % 24).to_s.rjust(2, '0') end - Time.parse(time) + day_adjustment * 60 * 60 * 24 + Time.parse("#{date} #{time}").in_time_zone(Time.zone) + day_adjustment * 60 * 60 * 24 end end end end