public function updateDateRange($date, $use_year = true) { $date = new LsDate($date); if ($use_year) { $date->setDay('00'); $date->setMonth('00'); } if ($date->getYear() == '0000') { return false; } //start date and end date both null, make start date the date if (!$this->end_date && !$this->start_date) { $this->start_date = (string) $date; $this->end_date = (string) $date; return true; } $end_date = new LsDate($this->end_date); $start_date = new LsDate($this->start_date); $start_date_comp = LsDate::compare($date, $start_date); $end_date_comp = LsDate::compare($date, $end_date); //if date is the same as either start date or end date, make no changes if ($start_date_comp == LsDate::COMPARE_SAME || $end_date_comp === LsDate::COMPARE_SAME) { return false; } else { if ($start_date_comp == LsDate::COMPARE_BEFORE) { $this->start_date = (string) $date; return true; } else { if ($end_date_comp == LsDate::COMPARE_AFTER) { $this->end_date = (string) $date; return true; } } } //no changes have been made return false; }