/** * Helper method * * @param string input * @param bool lower whether this is the lower boundary * @return util.Date */ protected function parseDate($input, $lower) { switch ($input) { case '__NOW__': if ($lower) { $r = DateUtil::getMidnight(Date::now()); } else { $r = DateUtil::getMidnight(DateUtil::addDays(Date::now(), 1)); } break; case '__FUTURE__': $r = Date::now(); break; case '__UNLIMITED__': $r = NULL; break; default: $r = DateParser::parse($input); } return $r; }
public function testNonLeapYear() { $date = Date::create(1999, 2, 1, 0, 0, 0, new TimeZone('Europe/Berlin')); $this->assertEquals(Date::create(1999, 3, 1, 0, 0, 0, new TimeZone('Europe/Berlin')), DateUtil::addMonths($date, 1)); $this->assertEquals(Date::create(1999, 3, 3, 0, 0, 0, new TimeZone('Europe/Berlin')), DateUtil::addDays($date, 30)); }
/** * Adds a positive or negative amount of weeks * * @param util.Date date * @param int count default 1 * @return util.Date */ public static function addWeeks(Date $date, $count = 1) { return DateUtil::addDays($date, $count * 7); }
public function multipleResultForDoSelect() { $this->setResults(new MockResultSet(array(0 => array('job_id' => 1, 'title' => 'Unit tester', 'valid_from' => Date::now(), 'expire_at' => NULL), 1 => array('job_id' => 9, 'title' => 'PHP programmer', 'valid_from' => Date::now(), 'expire_at' => DateUtil::addDays(Date::now(), 7))))); $peer = Job::getPeer(); $jobs = $peer->doSelect(new Criteria(array('job_id', 10, LESS_THAN))); $this->assertArray($jobs); $this->assertEquals(2, sizeof($jobs)); $this->assertClass($jobs[0], 'net.xp_framework.unittest.rdbms.dataset.Job'); $this->assertEquals(1, $jobs[0]->getJob_id()); $this->assertClass($jobs[1], 'net.xp_framework.unittest.rdbms.dataset.Job'); $this->assertEquals(9, $jobs[1]->getJob_id()); }