/**
  * 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';
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Does the given date pass the day and day mode filters?
  * @param DATE_TIME $date
  * @see $ALBUM::$first_day_mode
  * @see $ALBUM::$last_day_mode
  */
 public function is_valid_date($date)
 {
     if ($this->show_times) {
         $parts = Date_time_both_parts;
     } else {
         $parts = Date_time_date_part;
     }
     return ($this->first_day_mode == Day_mode_adjust || $this->first_day->less_than_equal($date, $parts)) && ($this->last_day_mode == Day_mode_fixed && $date->less_than_equal($this->last_day, $parts) || $this->last_day_mode == Day_mode_today && $date->less_than_equal(new DATE_TIME(), $parts) || $this->last_day_mode == Day_mode_adjust);
 }
Esempio n. 3
0
 /**
  * @param DATE_TIME $first
  * @param DATE_TIME $last
  * @param int $parts Can be {@link Date_time_date_part}, {@link Date_time_time_part} or {@link Date_time_both_parts}.
  * @return bool
  */
 public function between($first, $last, $parts = Date_time_both_parts)
 {
     return $first->less_than_equal($this, $parts) && $this->less_than_equal($last);
 }
Esempio n. 4
0
 /**
  * @var FORM $form
  */
 public function validate($form)
 {
     parent::validate($form);
     if ($this->continue_validating($form)) {
         /** @var $value DATE_TIME */
         $value = $this->_value;
         if (!$value->is_valid()) {
             $form->record_error($this->id, "[{$this->_text_value}] is not a valid date/time. Use [d.m.Y] or [m/d/Y] or [Y-m-d]");
         } else {
             $date = $value;
             if (isset($this->max_date)) {
                 if (isset($this->min_date)) {
                     if ($date->less_than_equal($this->min_date) || $this->max_date->less_than_equal($date)) {
                         $form->record_error($this->id, 'Please enter a date between ' . $this->min_date->as_iso() . ' and ' . $this->max_date->as_iso() . " for {$this->caption}");
                     }
                 } else {
                     if ($this->max_date->less_than_equal($date)) {
                         $form->record_error($this->id, 'Please enter a date less than ' . $this->max_date->as_iso() . " for {$this->caption}");
                     }
                 }
             } else {
                 if (isset($this->min_date)) {
                     if ($date->less_than_equal($this->min_date)) {
                         $form->record_error($this->id, 'Please enter a date greater than ' . $this->min_date->as_iso() . " for {$this->caption}");
                     }
                 }
             }
         }
     }
 }