import type { BusSchedule , DayOfWeek } from '../types' ; import type { Moment } from 'moment-timezone' ; const allDaysOfWeek = [ 'Su' , 'Mo' , 'Tu' , 'We' , 'Th' , 'Fr' , 'Sa' ] ; export function getScheduleForNow ( schedules , now ) { let thisWeekday = allDaysOfWeek [ now . day ( ) ] ; let schedule = schedules . find ( ( schedule ) => schedule . days . includes ( thisWeekday ) ) ; if ( ! schedule ) { return { days : [ thisWeekday ] , timetable : [ ] , coordinates : { } , stops : [ ] , times : [ ] , } ; } return schedule ; }