     train.terminated = terminated == 'true'
   train
 
-@getArrivalAndDepartureTimes = (currentTiploc, scheduleCursor) ->
+@getArrivalAndDepartureTimes = (currentTiploc, scheduleCursor, date) ->
+  date or= new Date()
+  date = moment(date)
   schedules = []
   scheduleCursor.forEach (rawSchedule) ->
     jsonScheduleV1 = rawSchedule.JsonScheduleV1

  timeOffset or= 60
  getDateScheduleForTiploc(now, tiploc, timeOffset)

@getDateScheduleForTiploc = (date, tiploc, timeOffset) ->
  # Days runs starts with monday at index 0, javascript starts with sunday at
  # index 0. We need to shift it along
  m = moment(date)
  startTime = parseInt(m.format('HHmm'))
  endTime = parseInt(m.add('minutes', timeOffset).format('HHmm'))
  # Special after midnight case
  if endTime < startTime
    timeQuery =

        time:
          $lte: endTime
      ]
    startDayQuery = {}
    startDayQuery["JsonScheduleV1.schedule_days_runs.#{startDayOfWeek}"] = true
    endDayQuery = {}
    endDayQuery["JsonScheduleV1.schedule_days_runs.#{endDayOfWeek}"] = true
    dayQuery =
      $or: [
        startDayQuery
      ,
        endDayQuery
      ]
  else
    timeQuery =
      tiploc_code: tiploc
      time:
        $gte: startTime
        $lte: endTime
    dayQuery["JsonScheduleV1.schedule_days_runs.#{startDayOfWeek}"] = true
  Schedules.find
    $and: [
      'JsonScheduleV1.schedule_segment.schedule_location':
