modules/query/CalendarTable.js
function(db, date, callback) {

  // Check cache for services
  let cacheKey = db.id + "-" + date;
  let cache = cache_servicesDefaultByDate.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Array of default services to return
  let rtn = [];

  // Get day of week
  let dt = DateTime.createFromDate(date);
  let dow = dt.getDateDOW();

  // Get default services
  let select = "SELECT service_id, monday, tuesday, wednesday, thursday, friday, " +
    "saturday, sunday, start_date, end_date FROM gtfs_calendar WHERE " + dow +
    "=" + Service.SERVICE_AVAILABLE + " AND start_date<=" + date + " AND " +
    "end_date>=" + date + ";";

  // Query the database
  db.select(select, function(err, results) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }


    // Parse each row in the results...
    for ( let i = 0; i < results.length; i++ ) {
      let row = results[i];

      let service = new Service(
        row.service_id,
        row.monday,
        row.tuesday,
        row.wednesday,
        row.thursday,
        row.friday,
        row.saturday,
        row.sunday,
        row.start_date,
        row.end_date
      );

      rtn.push(service);
    }

    // Add Services to Cache
    cache_servicesDefaultByDate.put(cacheKey, rtn);

    // Return the default services with provided callback
    return callback(null, rtn);

  });

}
function(db, date, callback) {

  // Check cache for services
  let cacheKey = db.id + "-" + date;
  let cache = cache_servicesDefaultByDate.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Array of default services to return
  let rtn = [];

  // Get day of week
  let dt = DateTime.createFromDate(date);
  let dow = dt.getDateDOW();

  // Get default services
  let select = "SELECT service_id, monday, tuesday, wednesday, thursday, friday, " +
    "saturday, sunday, start_date, end_date FROM gtfs_calendar WHERE " + dow +
    "=" + Service.SERVICE_AVAILABLE + " AND start_date<=" + date + " AND " +
    "end_date>=" + date + ";";

  // Query the database
  db.select(select, function(err, results) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }


    // Parse each row in the results...
    for ( let i = 0; i < results.length; i++ ) {
      let row = results[i];

      let service = new Service(
        row.service_id,
        row.monday,
        row.tuesday,
        row.wednesday,
        row.thursday,
        row.friday,
        row.saturday,
        row.sunday,
        row.start_date,
        row.end_date
      );

      rtn.push(service);
    }

    // Add Services to Cache
    cache_servicesDefaultByDate.put(cacheKey, rtn);

    // Return the default services with provided callback
    return callback(null, rtn);

  });

}
function ( db , date , callback ) { // Check cache for services let cacheKey = db . id + "-" + date ; let cache = cache_servicesDefaultByDate . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Array of default services to return let rtn = [ ] ; // Get day of week let dt = DateTime . createFromDate ( date ) ; let dow = dt . getDateDOW ( ) ; // Get default services let select = "SELECT service_id, monday, tuesday, wednesday, thursday, friday, " + "saturday, sunday, start_date, end_date FROM gtfs_calendar WHERE " + dow + "=" + Service . SERVICE_AVAILABLE + " AND start_date<=" + date + " AND " + "end_date>=" + date + ";" ; // Query the database db . select ( select , function ( err , results ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Parse each row in the results... for ( let i = 0 ; i < results . length ; i ++ ) { let row = results [ i ] ; let service = new Service ( row . service_id , row . monday , row . tuesday , row . wednesday , row . thursday , row . friday , row . saturday , row . sunday , row . start_date , row . end_date ) ; rtn . push ( service ) ; } // Add Services to Cache cache_servicesDefaultByDate . put ( cacheKey , rtn ) ; // Return the default services with provided callback return callback ( null , rtn ) ; } ) ; }
Get the default Services in effect on the specified date.  These
services don't include any changes due to service exceptions.

@param {RightTrackDB} db The Right Track Database to query
@param {int} date The date to query (yyyymmdd)
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {Service[]} callback.services The selected Services
Get the default Services in effect on the specified date . These services don t include any changes due to service exceptions .