function getTransactionBusinessDay($epoch)
 {
     Debug::Text('Epoch: ' . TTDate::getDate('DATE+TIME', $epoch), __FILE__, __LINE__, __METHOD__, 10);
     $holiday_epochs = array();
     $user_ids = $this->getUser();
     if (count($user_ids) > 0) {
         $hlf = new HolidayListFactory();
         $hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($user_ids, $epoch - 86400 * 14, $epoch + 86400 * 2);
         if ($hlf->getRecordCount() > 0) {
             foreach ($hlf as $h_obj) {
                 Debug::Text('Found Holiday Epoch: ' . TTDate::getDate('DATE+TIME', $h_obj->getDateStamp()) . ' Name: ' . $h_obj->getName(), __FILE__, __LINE__, __METHOD__, 10);
                 $holiday_epochs[] = $h_obj->getDateStamp();
             }
             //Debug::Arr($holiday_epochs, 'Holiday Epochs: ', __FILE__, __LINE__, __METHOD__, 10);
         }
         while (TTDate::isWeekDay($epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($epoch), $holiday_epochs)) {
             Debug::text('<b>FOUND WeekDay/HOLIDAY!</b>', __FILE__, __LINE__, __METHOD__, 10);
             switch ($this->getTransactionDateBusinessDay()) {
                 case 0:
                     //No adjustment
                     break 2;
                 case 1:
                     //Previous day
                     $epoch -= 86400;
                     break;
                 case 2:
                     //Next day
                     $epoch += 86400;
                     break;
                 case 3:
                     //Closest day
                     $forward_epoch = $epoch;
                     $forward_days = 0;
                     while (TTDate::isWeekDay($forward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($forward_epoch), $holiday_epochs)) {
                         $forward_epoch += 86400;
                         $forward_days++;
                     }
                     $backward_epoch = $epoch;
                     $backward_days = 0;
                     while (TTDate::isWeekDay($backward_epoch) == FALSE or in_array(TTDate::getBeginDayEpoch($backward_epoch), $holiday_epochs)) {
                         $backward_epoch -= 86400;
                         $backward_days++;
                     }
                     if ($backward_days <= $forward_days) {
                         $epoch = $backward_epoch;
                     } else {
                         $epoch = $forward_epoch;
                     }
                     break;
             }
         }
     }
     return $epoch;
 }
 function getArrayByPolicyGroupUserId($user_id, $start_date, $end_date)
 {
     $hlf = new HolidayListFactory();
     $hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($user_id, $start_date, $end_date);
     if ($hlf->getRecordCount() > 0) {
         foreach ($hlf as $h_obj) {
             $list[$h_obj->getDateStamp()] = $h_obj->getName();
         }
         return $list;
     }
     return FALSE;
 }
 function getHolidayUserDateIDs()
 {
     Debug::text('reCalculating Holiday...', __FILE__, __LINE__, __METHOD__, 10);
     //Get Holiday policies and determine how many days we need to look ahead/behind in order
     //to recalculate the holiday eligilibility/time.
     $holiday_before_days = 0;
     $holiday_after_days = 0;
     $hplf = new HolidayPolicyListFactory();
     $hplf->getByCompanyId($this->getUserDateObject()->getUserObject()->getCompany());
     if ($hplf->getRecordCount() > 0) {
         foreach ($hplf as $hp_obj) {
             if ($hp_obj->getMinimumWorkedPeriodDays() > $holiday_before_days) {
                 $holiday_before_days = $hp_obj->getMinimumWorkedPeriodDays();
             }
             if ($hp_obj->getAverageTimeDays() > $holiday_before_days) {
                 $holiday_before_days = $hp_obj->getAverageTimeDays();
             }
             if ($hp_obj->getMinimumWorkedAfterPeriodDays() > $holiday_after_days) {
                 $holiday_after_days = $hp_obj->getMinimumWorkedAfterPeriodDays();
             }
         }
     }
     Debug::text('Holiday Before Days: ' . $holiday_before_days . ' Holiday After Days: ' . $holiday_after_days, __FILE__, __LINE__, __METHOD__, 10);
     if ($holiday_before_days > 0 or $holiday_after_days > 0) {
         $retarr = array();
         $search_start_date = TTDate::getBeginWeekEpoch($this->getUserDateObject()->getDateStamp() - $holiday_after_days * 86400);
         $search_end_date = TTDate::getEndWeekEpoch(TTDate::getEndDayEpoch($this->getUserDateObject()->getDateStamp()) + $holiday_before_days * 86400 + 3601);
         Debug::text('Holiday search start date: ' . TTDate::getDate('DATE', $search_start_date) . ' End date: ' . TTDate::getDate('DATE', $search_end_date) . ' Current Date: ' . TTDate::getDate('DATE', $this->getUserDateObject()->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
         $hlf = new HolidayListFactory();
         //$hlf->getByPolicyGroupUserIdAndStartDateAndEndDate( $this->getUserDateObject()->getUser(), TTDate::getEndWeekEpoch( $this->getUserDateObject()->getDateStamp() )+86400, TTDate::getEndDayEpoch()+($max_average_time_days*86400)+3601 );
         $hlf->getByPolicyGroupUserIdAndStartDateAndEndDate($this->getUserDateObject()->getUser(), $search_start_date, $search_end_date);
         if ($hlf->getRecordCount() > 0) {
             Debug::text('Found Holidays within range: ' . $hlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             $udlf = new UserDateListFactory();
             foreach ($hlf as $h_obj) {
                 Debug::text('ReCalculating Day due to Holiday: ' . TTDate::getDate('DATE', $h_obj->getDateStamp()), __FILE__, __LINE__, __METHOD__, 10);
                 $user_date_ids = $udlf->getArrayByListFactory($udlf->getByUserIdAndDate($this->getUserDateObject()->getUser(), $h_obj->getDateStamp()));
                 if (is_array($user_date_ids)) {
                     $retarr = array_merge($retarr, $user_date_ids);
                 }
                 unset($user_date_ids);
             }
         }
     }
     if (isset($retarr) and is_array($retarr) and count($retarr) > 0) {
         //Debug::Arr($retarr, 'Holiday UserDateIDs: ', __FILE__, __LINE__, __METHOD__, 10);
         return $retarr;
     }
     Debug::text('No Holidays within range...', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }