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

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

  // Get matching holiday
  let select = "SELECT date, holiday_name, peak, service_info " +
    "FROM rt_holidays WHERE date=" + date;

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

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

    // Add result to cache
    cache_isHolidayByDate.put(cacheKey, result !== undefined);

    // Return if holiday is found with callback
    return callback(null, result !== undefined);

  });

}
function isHoliday(db, date, callback) {

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

  // Get matching holiday
  let select = "SELECT date, holiday_name, peak, service_info " +
    "FROM rt_holidays WHERE date=" + date;

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

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

    // Add result to cache
    cache_isHolidayByDate.put(cacheKey, result !== undefined);

    // Return if holiday is found with callback
    return callback(null, result !== undefined);

  });

}
function isHoliday ( db , date , callback ) { // Check cache for is holiday let cacheKey = db . id + "-" + date ; let cache = cache_isHolidayByDate . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Get matching holiday let select = "SELECT date, holiday_name, peak, service_info " + "FROM rt_holidays WHERE date=" + date ; // Query the database db . get ( select , function ( err , result ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Add result to cache cache_isHolidayByDate . put ( cacheKey , result !== undefined ) ; // Return if holiday is found with callback return callback ( null , result !== undefined ) ; } ) ; }
Check if the specified date is a Holiday

@param {RightTrackDB} db The Right Track DB to query
@param {int} date The date to check (yyyymmdd)
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {boolean} [callback.isHoliday] True if the specified date is a Holiday
Check if the specified date is a Holiday