public boolean activeOn ( LocalDate date ) { // first check for exceptions CalendarDate exception = calendar_dates . get ( date ) ; if ( exception != null ) return exception . exception_type == 1 ; else if ( calendar == null ) return false ; else { int gtfsDate = date . getYear ( ) * 10000 + date . getMonthValue ( ) * 100 + date . getDayOfMonth ( ) ; boolean withinValidityRange = calendar . end_date >= gtfsDate && calendar . start_date <= gtfsDate ; if ( ! withinValidityRange ) return false ; switch ( date . getDayOfWeek ( ) ) { case MONDAY : return calendar . monday == 1 ; case TUESDAY : return calendar . tuesday == 1 ; case WEDNESDAY : return calendar . wednesday == 1 ; case THURSDAY : return calendar . thursday == 1 ; case FRIDAY : return calendar . friday == 1 ; case SATURDAY : return calendar . saturday == 1 ; case SUNDAY : return calendar . sunday == 1 ; default : throw new IllegalArgumentException ( "unknown day of week constant!" ) ; } } }
Is this service active on the specified date?