function getAverageTime($user_id)
 {
     $udtlf = new UserDateTotalListFactory();
     //Check if Min and Max time is the same, if so we can skip any averaging.
     if ($this->getHolidayPolicyObject()->getMinimumTime() > 0 and $this->getHolidayPolicyObject()->getMaximumTime() > 0 and $this->getHolidayPolicyObject()->getMinimumTime() == $this->getHolidayPolicyObject()->getMaximumTime()) {
         Debug::text('Min and Max times are equal.', __FILE__, __LINE__, __METHOD__, 10);
         return $this->getHolidayPolicyObject()->getMinimumTime();
     }
     if ($this->getHolidayPolicyObject()->getAverageTimeWorkedDays() == TRUE) {
         $last_days_worked_count = $udtlf->getDaysWorkedByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
     } else {
         Debug::text('NOT Using worked days!', __FILE__, __LINE__, __METHOD__, 10);
         $last_days_worked_count = $this->getHolidayPolicyObject()->getAverageTimeDays();
     }
     Debug::text('Last Days Worked:' . $last_days_worked_count, __FILE__, __LINE__, __METHOD__, 10);
     if ($this->getHolidayPolicyObject()->getIncludeOverTime() == TRUE) {
         Debug::text('Including OverTime!', __FILE__, __LINE__, __METHOD__, 10);
         $total_seconds_worked = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
     } else {
         Debug::text('NOT Including OverTime!', __FILE__, __LINE__, __METHOD__, 10);
         $total_seconds_worked = $udtlf->getRegularTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
     }
     if ($this->getHolidayPolicyObject()->getIncludePaidAbsenceTime() == TRUE) {
         Debug::text('Including Paid Absence Time!', __FILE__, __LINE__, __METHOD__, 10);
         $total_seconds_worked += $udtlf->getPaidAbsenceTimeSumByUserIDAndStartDateAndEndDate($user_id, $this->getDateStamp() - $this->getHolidayPolicyObject()->getAverageTimeDays() * 86400, $this->getDateStamp() - 86400);
     } else {
         Debug::text('NOT Including Paid Absence Time!', __FILE__, __LINE__, __METHOD__, 10);
     }
     if ($last_days_worked_count > 0) {
         $avg_seconds_worked_per_day = bcdiv($total_seconds_worked, $last_days_worked_count);
         Debug::text('AVG hours worked per day:' . TTDate::getHours($avg_seconds_worked_per_day), __FILE__, __LINE__, __METHOD__, 10);
     } else {
         $avg_seconds_worked_per_day = 0;
     }
     if ($this->getHolidayPolicyObject()->getMaximumTime() > 0 and $avg_seconds_worked_per_day > $this->getHolidayPolicyObject()->getMaximumTime()) {
         $avg_seconds_worked_per_day = $this->getHolidayPolicyObject()->getMaximumTime();
         Debug::text('AVG hours worked per day exceeds maximum regulars hours per day, setting to:' . $avg_seconds_worked_per_day / 60 / 60, __FILE__, __LINE__, __METHOD__, 10);
     }
     if ($avg_seconds_worked_per_day < $this->getHolidayPolicyObject()->getMinimumTime()) {
         $avg_seconds_worked_per_day = $this->getHolidayPolicyObject()->getMinimumTime();
         Debug::text('AVG hours worked per day is less then minimum regulars hours per day, setting to:' . $avg_seconds_worked_per_day / 60 / 60, __FILE__, __LINE__, __METHOD__, 10);
     }
     //Round to nearest 15mins.
     if ((int) $this->getHolidayPolicyObject()->getRoundIntervalPolicyID() != 0 and is_object($this->getHolidayPolicyObject()->getRoundIntervalPolicyObject())) {
         $avg_seconds_worked_per_day = TTDate::roundTime($avg_seconds_worked_per_day, $this->getHolidayPolicyObject()->getRoundIntervalPolicyObject()->getInterval(), $this->getHolidayPolicyObject()->getRoundIntervalPolicyObject()->getRoundType());
         Debug::text('Rounding Stat Time To: ' . $avg_seconds_worked_per_day, __FILE__, __LINE__, __METHOD__, 10);
     } else {
         Debug::text('NOT Rounding Stat Time!', __FILE__, __LINE__, __METHOD__, 10);
     }
     return $avg_seconds_worked_per_day;
 }