output timetable according to the time BUT

need to do it for users
need to check endtime
and need to improve code