public function isSent() { $sent = false; if ($this->send_date instanceof SwatDate) { $send_date = clone $this->send_date; $send_date->toUTC(); $now = new SwatDate(); $now->toUTC(); $sent = $now->after($this->send_date); } return $sent; }
protected function selectSwatDateEntry($id, SwatDate $date) { static $month_map = array('January' => '01', 'February' => '02', 'March' => '03', 'April' => '04', 'May' => '05', 'June' => '06', 'July' => '07', 'August' => '08', 'September' => '09', 'October' => '10', 'November' => '11', 'December' => '12'); $year = $date->getYear(); $month = $date->getMonth(); $day = $date->getDay(); $year_select = 'xpath=//select[@id=\'' . $id . '_year\']'; $month_select = 'xpath=//select[@id=\'' . $id . '_month\']'; $day_select = 'xpath=//select[@id=\'' . $id . '_day\']'; // get year info $year_options = $this->getSelectOptions($year_select); $start_year = $year_options[1]; $end_year = end($year_options); // get month info if ($this->isElementPresent($month_select)) { $month_options = $this->getSelectOptions($month_select); $start_month = preg_replace('/[^A-Za-z]/', '', $month_options[1]); $start_month = $month_map[$start_month]; $end_month = preg_replace('/[^A-Za-z]/', '', end($month_options)); $end_month = $month_map[$end_month]; } else { $start_month = '01'; $end_month = '01'; } // get day info if ($this->isElementPresent($day_select)) { $day_options = $this->getSelectOptions($day_select); $start_day = sprintf('%02d', $day_options[1]); $end_day = sprintf('%02d', end($day_options)); } else { $start_day = '01'; $end_day = '01'; } // validate ranges $start_date = new SwatDate($start_year . $start_month . $start_day); $end_date = new SwatDate($end_year . $end_month . $end_day); $this->assertFalse($date->before($start_date), 'Date specified in test (' . $date . ') is before the minimum ' . 'selectable date (' . $start_date . ').'); $this->assertFalse($date->after($end_date), 'Date specified in test (' . $date . ') is after the maximum ' . 'selectable date (' . $end_date . ').'); // select year $year_index = $year - intval($start_year) + 1; $this->select($year_select, 'index=' . $year_index); // select month if ($this->isElementPresent($month_select)) { $month_index = $month - intval($start_month) + 1; $this->select($month_select, 'index=' . $month_index); } // select day if ($this->isElementPresent($day_select)) { $day_index = $day - intval($start_day) + 1; $this->select($day_select, 'index=' . $day_index); } }