예제 #1
0
 /**
  * Recalculates the event's status.
  * Call this if you reassign the dates.
  */
 public function refresh()
 {
     $this->scheduled = $this->time_scheduled->is_valid();
     $this->occurred = $this->time_occurred->is_valid();
     $this->overdue = false;
     $this->icon_url = '';
     $this->text = '';
     $this->diff_label = '';
     $this->_html_text = null;
     $this->_plain_text = null;
     if ($this->occurred) {
         $this->date = $this->time_occurred;
         $this->icon_url = '{icons}indicators/released';
         if ($this->time_scheduled->is_valid()) {
             if ($this->time_occurred->less_than_equal($this->time_scheduled)) {
                 $this->difference = $this->time_scheduled->diff($this->time_occurred);
                 $this->diff_label = 'early';
             } else {
                 $this->difference = $this->time_occurred->diff($this->time_scheduled);
                 $this->diff_label = 'late';
             }
         }
     } else {
         if ($this->scheduled) {
             $this->date = $this->time_scheduled;
             if ($this->_skip_condition) {
                 $this->icon_url = '{icons}indicators/warning';
                 $this->text = 'Skipped';
             } else {
                 $this->icon_url = '{icons}buttons/calendar';
                 $now = new DATE_TIME();
                 if ($now->less_than_equal($this->time_scheduled)) {
                     $this->difference = $this->time_scheduled->diff($now);
                     $this->diff_label = 'left';
                     /* Determine whether there should be a warning for the approaching deadline. */
                     $warn_time = $this->_release->warning_time($this->time_scheduled);
                     if ($warn_time->less_than($now)) {
                         $this->icon_url = '{icons}indicators/warning';
                         $this->text = 'Due soon';
                     }
                 } else {
                     $this->overdue = true;
                     $this->icon_url = '{icons}indicators/error';
                     $this->text = 'Overdue';
                     $this->difference = $now->diff($this->time_scheduled);
                     $this->diff_label = 'late';
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * How long has this job been in this status?
  * @return TIME_INTERVAL
  */
 public function status_age()
 {
     $now = new DATE_TIME();
     if ($this->time_status_changed->is_valid()) {
         return $now->diff($this->time_status_changed);
     }
     return $now->diff($this->_entry->time_created);
 }