本文整理汇总了PHP中Zend_Date::equals方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::equals方法的具体用法?PHP Zend_Date::equals怎么用?PHP Zend_Date::equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetWhenUsesZendDateObject
public function testSetWhenUsesZendDateObject()
{
$entry = new Zend_Feed_Writer_Deleted();
$entry->setWhen(new Zend_Date('1234567890', Zend_Date::TIMESTAMP));
$myDate = new Zend_Date('1234567890', Zend_Date::TIMESTAMP);
$this->assertTrue($myDate->equals($entry->getWhen()));
}
示例2: isValid
public function isValid($value)
{
$front = Zend_Controller_Front::getInstance()->getRequest();
$action = $front->action;
if ($action == "edit-evento") {
return true;
}
if (!isset($value) or empty($value)) {
return false;
}
//date_default_timezone_set( 'America/Sao_Paulo' );
// Zend_Registry::get('logger')->log("valor=", Zend_Log::INFO);
// Zend_Registry::get('logger')->log($value, Zend_Log::INFO);
$date = new Zend_Date();
$data = new Zend_Date($date->toString('dd/MM/YYYY'));
$data2 = new Zend_Date($value);
$comparacao = $data->isLater($data2);
$comparacao2 = $data->isEarlier($data2);
$comparacao3 = $data->equals($data2);
// Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
// Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
// Zend_Registry::get('logger')->log($comparacao3, Zend_Log::INFO);
if ($comparacao3 || $comparacao2) {
Zend_Registry::get('logger')->log("data igual ou maior", Zend_Log::INFO);
} else {
$this->_setValue($value);
// Zend_Registry::get('logger')->log("data menor", Zend_Log::INFO);
$this->_error(self::INVALID);
return false;
}
// $comparacao= $data->compare($date2);
// Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
// Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
return true;
}
示例3: isOpen
/**
* Determine whether the entry is open
*
* @return bool
*/
public function isOpen()
{
$opened = new Zend_Date($this->opened);
$closed = new Zend_Date($this->closed);
if ($closed->equals($opened)) {
return true;
}
return false;
}
示例4: _afterUpdate
protected function _afterUpdate($oldRecord, $newRecord)
{
if ($oldRecord->__get('booking_date') !== $newRecord->__get('booking_date')) {
$booking = $newRecord->getForeignRecord('booking_id', Billing_Controller_Booking::getInstance());
$bookingDate = new Zend_Date($booking->__get('booking_date'));
$abookingDate = new Zend_Date($newRecord->__get('booking_date'));
if (!$bookingDate->equals($abookingDate)) {
$booking->__set('booking_date', $newRecord->__get('booking_date'));
Billing_Controller_Booking::getInstance()->update($booking);
}
}
}
示例5: cmp
function cmp($a, $b)
{
$date = $dateA = $dateB = null;
preg_match('#([0-9]{1,2})_([0-9]{1,2})_([0-9]{4}).*#i', $a, $date);
$date_str = '';
if (count($date)) {
$date_part = @array_slice($date, 1, 3);
if (count($date_part)) {
$date_str = implode('.', $date_part);
$dateA = new Zend_Date($date_str);
}
}
$date = null;
preg_match('#([0-9]{1,2})_([0-9]{1,2})_([0-9]{4}).*#i', $b, $date);
$date_str = '';
if (count($date)) {
$date_part = @array_slice($date, 1, 3);
if (count($date_part)) {
$date_str = implode('.', $date_part);
$dateB = new Zend_Date($date_str);
}
}
if ($dateA && $dateB) {
if ($dateA->equals($dateB, Zend_Date::DATES)) {
return 0;
}
if ($dateA->isEarlier($dateB, Zend_Date::DATES)) {
return -1;
}
if ($dateA->isLater($dateB, Zend_Date::DATES)) {
return 1;
}
} else {
if ($a == $b) {
return 0;
}
return $a < $b ? -1 : 1;
}
}
示例6: testComparingDatesWithoutOption
/**
* @ZF-9891
*/
public function testComparingDatesWithoutOption()
{
$date = new Zend_Date(strtotime('Sat, 07 Mar 2009 08:03:50 +0000'));
$date2 = new Zend_Date();
$date2->set('Sat, 07 Mar 2009 08:03:50 +0000', Zend_Date::RFC_2822);
$this->assertTrue($date2->equals($date));
}
示例7: testSetLastBuildDateUsesZendDateObject
public function testSetLastBuildDateUsesZendDateObject()
{
$writer = new Zend_Feed_Writer_Feed();
$writer->setLastBuildDate(new Zend_Date('1234567890', Zend_Date::TIMESTAMP));
$myDate = new Zend_Date('1234567890', Zend_Date::TIMESTAMP);
$this->assertTrue($myDate->equals($writer->getLastBuildDate()));
}
示例8: testGetsDateModifiedFromRss20_UnrecognisedGmtFormat
/**
* @group ZF-7908
*/
public function testGetsDateModifiedFromRss20_UnrecognisedGmtFormat()
{
$feed = Zend_Feed_Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/plain/rss20-zf-7908.xml'));
$entry = $feed->current();
//$this->assertEquals('Sunday 11 January 2009 09 55 59 +0000', $entry->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
$edate = new Zend_Date();
$edate->set('Sun, 11 Jan 2009 09:55:59 GMT', Zend_Date::RSS);
$this->assertTrue($edate->equals($entry->getDateModified()));
}
示例9: testLoose
/**
* test looseBehaviour
*/
public function testLoose()
{
$date = new Zend_Date(0, 'de');
try {
$date->set(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->set(10, 'de');
$this->assertEquals($date->getTimestamp(), 10);
try {
$date->add(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->add(10, 'de');
$this->assertEquals($date->getTimestamp(), 20);
try {
$date->sub(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
$date->sub(10, 'de');
$this->assertEquals($date->getTimestamp(), 10);
try {
$date->compare(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->equals(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->isEarlier(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->isLater(null, Zend_Date::YEAR);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareTime(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDate(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
//.........这里部分代码省略.........
示例10: _validateFromUntilRange
/**
* Checks if from date is before until date.
*
* @param mixed $from
* @param mixed $until
* @return boolean
*/
private function _validateFromUntilRange($from, $until)
{
$result = $this->_validateFrom($from);
if (false === $result) {
return false;
}
$result = $this->_validateUntil($until);
if (false === $result) {
return $result;
}
$result = true;
$untilDate = new Zend_Date($until, $this->_dateFormat);
$isEqual = $untilDate->equals($from, $this->_dateFormat);
$isLater = $untilDate->isLater($from, $this->_dateFormat);
if (false === $isEqual and false === $isLater) {
$this->setErrorCode(Oai_Model_Error::BADARGUMENT);
$this->setErrorMessage('Date "' . $from . '" is later than date "' . $until . '".');
$result = false;
}
return $result;
}
示例11: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if a token has been set and the provided value
* matches that token.
*
* @param mixed $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$this->_setValue((string) $value);
$token = $this->getToken();
if ($token === null) {
$this->_error(self::MISSING_TOKEN);
return false;
}
if (isset($context[$token]) && !empty($context[$token])) {
//we verify the token as validator order execution means that we could get here before the
//date validation call for the corresponding field is made
$token = $context[$token];
$validator = new Zend_Validate_Date(OpenSKOS_Solr_Queryparser_Editor::OPTIONS_DATE_FORMAT);
if (!$validator->isValid($token)) {
$this->_error(self::INVALID_TOKEN_FIELD);
return false;
}
} else {
return true;
}
$date1 = new Zend_Date($value);
$date2 = new Zend_Date($token);
if ($this->getCompare() === true) {
if ($date1->compare($date2) < 0 || $date1->equals($date2)) {
$this->_error(self::NOT_LATER);
return false;
}
} else {
if ($this->getCompare() === false) {
if ($date1->compare($date2) > 0 || $date1->equals($date2)) {
$this->_error(self::NOT_EARLIER);
return false;
}
} else {
if ($this->getCompare() === null) {
if (!$date1->equals($date2)) {
$this->_error(self::NOT_SAME);
return false;
}
} else {
$date3 = new Zend_Date($this->getCompare());
if ($date1->compare($date2) < 0 || $date1->compare($date3) > 0) {
$this->_error(self::NOT_BETWEEN);
return false;
}
}
}
}
return true;
}
示例12: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if a token has been set and the provided value
* matches that token.
*
* @param mixed $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$logger = new Zend_Log();
$writer = new Zend_Log_Writer_Stream('sample.log');
$logger->addWriter($writer);
$logger->log('Check date start!', Zend_Log::INFO);
$this->_setValue((string) $value);
// $token = $this->getToken();
if ($context !== null && isset($context) && array_key_exists($this->getToken(), $context)) {
$token = $context[$this->getToken()];
} else {
$token = $this->getToken();
}
if ($token === null) {
$this->_error(self::MISSING_TOKEN);
return false;
}
$date1 = new Zend_Date($value, 'YYYY-MM-dd');
$date2 = new Zend_Date($token, 'YYYY-MM-dd');
$logger->log('Check date! date1=' . $date1 . ", date2=" . $date2 . ", token=" . $token, Zend_Log::INFO);
// Not Later
if ($this->getCompare() === true) {
if ($date1->compare($date2) < 0 || $date1->equals($date2)) {
$this->_error(self::NOT_LATER);
return false;
}
// Not Earlier
} elseif ($this->getCompare() === false) {
if ($date1->compare($date2) > 0 || $date1->equals($date2)) {
$this->_error(self::NOT_EARLIER);
return false;
}
// Exact Match
} elseif ($this->getCompare() === null) {
if (!$date1->equals($date2)) {
$this->_error(self::NOT_SAME);
return false;
}
// In Range
} else {
$date3 = new Zend_Date($this->getCompare());
if ($date1->compare($date2) < 0 || $date1->compare($date3) > 0) {
$this->_error(self::NOT_BETWEEN);
return false;
}
}
// Date is valid
return true;
}
示例13: isOnDate
/**
* Check if the event is on the given date
*
* @param Zend_Date $date
* @return Zym_Calendar_Event
*/
public function isOnDate(Zend_Date $date)
{
$startDate = $this->getStartDate();
$endDate = $this->getEndDate();
return ($date->equals($startDate) || $date->isLater($startDate)) && ($date->equals($endDate) || $date->isEarlier($endDate));
}
示例14: addEventAction
/**
* Allows a user to create an event.
*
*/
public function addEventAction()
{
$messages = array();
$get = Zend_Registry::get('getFilter');
$event = new Event();
$values = array();
if (isset($get->date)) {
$values['date'] = $get->date;
}
$form = $event->form($values);
if ($this->_request->isPost()) {
if ($form->isValid($_POST)) {
$workshopId = $form->getValue('workshop');
$locationId = $form->getValue('location');
$startTime = $form->getValue('startTime');
$endTime = $form->getValue('endTime');
$date = $form->getValue('date');
$minSize = $form->getValue('minSize');
$maxSize = $form->getValue('maxSize');
$waitlistSize = $form->getValue('waitlistSize');
$instructors = $form->getValue('instructors');
$password = $form->getValue('password');
$evaluationType = $form->getValue('evaluationType');
$formKey = $form->getValue('formKey');
$answerKey = $form->getValue('answerKey');
if (isset($formKey) && $formKey != '') {
$regex = '(?<=key\\=)\\w*';
$matches = array();
preg_match_all("/" . $regex . "/is", $form->getValue('formKey'), $matches);
$formKey = $matches[0][0];
}
if (isset($answerKey) && $answerKey != '') {
$regex = '(?<=key\\=)\\w*';
$matches = array();
preg_match_all("/" . $regex . "/is", $form->getValue('answerKey'), $matches);
$answerKey = $matches[0][0];
}
$date = strtotime($date);
$date = strftime('%Y', $date) . "-" . strftime('%m', $date) . "-" . strftime('%d', $date);
if (strtolower($startTime['meridian']) == "pm" && $startTime['hour'] < 12) {
$startTime['hour'] += 12;
}
if (strtolower($startTime['meridian']) == "am" && $startTime['hour'] == 12) {
$startTime['hour'] = 0;
}
if (strtolower($endTime['meridian']) == "pm" && $endTime['hour'] < 12) {
$endTime['hour'] += 12;
}
if (strtolower($endTime['meridian']) == "am" && $endTime['hour'] == 12) {
$endTime['hour'] = 0;
}
$timesOk = true;
$st = new Zend_Date($date);
$st->setHour($startTime['hour'])->setMinute($startTime['minute']);
$et = new Zend_Date($date);
$et->setHour($endTime['hour'])->setMinute($endTime['minute']);
if ($st->isLater($et)) {
$timesOk = false;
$messages[] = "msg-error-eventStartsAfter";
} else {
if ($st->equals($et)) {
$timesOk = false;
$messages[] = "msg-error-eventTimesEqual";
}
}
$startTime = $startTime['hour'] . ":" . $startTime['minute'] . ":00";
$endTime = $endTime['hour'] . ":" . $endTime['minute'] . ":00";
$where = $event->getAdapter()->quoteInto('date = ?', $date) . " AND " . $event->getAdapter()->quoteInto('locationId = ?', $locationId) . " AND " . $event->getAdapter()->quoteInto('status = ?', 'open');
$possibleConflicts = $event->fetchAll($where);
$conflictFound = false;
if ($possibleConflicts->count() > 0) {
$startTs = strtotime($startTime);
$endTs = strtoTime($endTime);
foreach ($possibleConflicts as $pc) {
$pcStart = strtotime($pc->startTime);
$pcEnd = strtotime($pc->endTime);
if ($startTs == $pcStart) {
$conflictFound = true;
} else {
if ($startTs < $pcStart && $endTs > $pcStart) {
$conflictFound = true;
} else {
if ($startTs >= $pcStart && $endTs <= $pcEnd) {
$conflictFound = true;
} else {
if ($startTs < $pcEnd && $endTs >= $pcEnd) {
$conflictFound = true;
} else {
if ($startTs < $pcStart && $endTime > $pcEnd) {
$conflictFound = true;
}
}
}
}
}
if ($conflictFound) {
//.........这里部分代码省略.........
示例15: getIdsForDateRange
/**
* Returns an array of ids for all documents published between two dates.
*
* @param string $from (Optional) The earliest publication date to include.
* @param string $until (Optional) The latest publication date to include.
* @return array Array of document ids.
*
* @deprecated
*/
public static function getIdsForDateRange($from = null, $until = null)
{
try {
if (true === is_null($from)) {
$from = new Zend_Date(self::getEarliestPublicationDate());
} else {
$from = new Zend_Date($from);
}
} catch (Exception $e) {
throw new Exception('Invalid date string supplied: ' . $from);
}
try {
if (true === is_null($until)) {
$until = new Zend_Date();
} else {
$until = new Zend_Date($until);
}
} catch (Exception $e) {
throw new Exception('Invalid date string supplied: ' . $until);
}
$searchRange = null;
if (true === $from->equals($until)) {
$searchRange = 'LIKE "' . $from->toString('yyyy-MM-dd') . '%"';
} else {
// TODO FIXME
//
// For some strange reason a between does not include the
// latest day. E.g. if until date is 2009-05-10 then the
// result does not include data sets with 2009-05-10 only newer dates.
//
// If we add one day then is result as expected but maybe wrong?
//
// Between range looks like $from < $until and not $from <= $until
$until->addDay(1);
$searchRange = 'BETWEEN "' . $from->toString('yyyy-MM-dd') . '%" AND "' . $until->toString('yyyy-MM-dd') . '%"';
}
$table = Opus_Db_TableGateway::getInstance('Opus_Db_Documents');
// TODO server date publish really needed ?
// because server date modified is in any case setted to latest change date
$select = $table->select()->from($table, array('id'))->where('server_date_published ' . $searchRange)->orWhere('server_date_modified ' . $searchRange);
$rows = $table->fetchAll($select)->toArray();
$ids = array();
foreach ($rows as $row) {
$ids[] = $row['id'];
}
return $ids;
}