예제 #1
0
 /**
  * Determines whether a date represents a holiday or not
  *
  * @param mixed                $date   a timestamp, string or PEAR::Date object
  * @param Date_Holidays_Filter $filter filter-object (or an array !DEPRECATED!)
  *
  * @access   public
  * @return   boolean true if date represents a holiday, otherwise false
  * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE_FORMAT
  * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE
  */
 function isHoliday($date, $filter = null)
 {
     if (!is_a($date, 'Date')) {
         $date = $this->_convertDate($date);
         if (Date_Holidays::isError($date)) {
             return $date;
         }
     }
     //rebuild internal array of holidays if required.
     $compare_year = $date->getYear();
     $this_year = $this->getYear();
     if ($this_year !== $compare_year) {
         $this->setYear($compare_year);
     }
     if (is_null($filter)) {
         $filter = new Date_Holidays_Filter_Blacklist(array());
     } elseif (is_array($filter)) {
         $filter = new Date_Holidays_Filter_Whitelist($filter);
     }
     foreach (array_keys($this->_dates) as $internalName) {
         if ($filter->accept($internalName)) {
             if (Date_Holidays_Driver::dateSloppyCompare($date, $this->_dates[$internalName]) != 0) {
                 continue;
             }
             $this->setYear($this_year);
             return true;
         }
     }
     $this->setYear($this_year);
     return false;
 }
예제 #2
0
 /**
  * Determines whether a date represents a holiday or not
  *
  * @access   public
  * @param    mixed   $date       date (can be a timestamp, string or PEAR::Date object)
  * @param    Date_Holidays_Filter $filter    filter-object (or an array !DEPRECATED!)
  * @return   boolean true if date represents a holiday, otherwise false
  * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  */
 function isHoliday($date, $filter = null)
 {
     if (!is_a($date, 'Date')) {
         $date = $this->_convertDate($date);
         if (Date_Holidays::isError($date)) {
             return $date;
         }
     }
     if (is_null($filter)) {
         $filter = new Date_Holidays_Filter_Blacklist(array());
     } elseif (is_array($filter)) {
         $filter = new Date_Holidays_Filter_Whitelist($filter);
     }
     foreach (array_keys($this->_dates) as $internalName) {
         if ($filter->accept($internalName)) {
             if (Date_Holidays_Driver::dateSloppyCompare($date, $this->_dates[$internalName]) != 0) {
                 continue;
             }
             return true;
         }
     }
     return false;
 }