diff -r 5da3315058a2 -r d0ae1996abdd service.py --- a/service.py Wed Jun 28 16:25:17 2017 +0300 +++ b/service.py Wed Jun 28 17:01:42 2017 +0300 @@ -74,6 +74,9 @@ else: return schedule_entry['trip'].schedule[-1].stop.name +def imminent(schedule_entry): + return (schedule_entry['time'] - now()) <= timedelta(minutes = 3) + @app.route('/pysäkki/') def bus_stop_schedule(reference): from buses import bus_stops @@ -89,6 +92,7 @@ 'sign': sign(schedule_entry), 'trip': schedule_entry['stop'].trip.name, 'night': is_night_time(schedule_entry['time']), + 'imminent': imminent(schedule_entry), }) return render_template( 'stop.html', @@ -134,6 +138,7 @@ 'stop_id': schedule_entry['stop'].stop.reference, 'stop_code': schedule_entry['stop'].stop.code, 'stop_name': tr(schedule_entry['stop'].stop.name, 'pysäkit'), + 'imminent': imminent(schedule_entry), }) stops_in_cluster = sorted( ({