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()));
 }
Example #2
0
 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 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);
         }
     }
 }
Example #5
0
 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;
     }
 }
Example #6
0
 /**
  * @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));
 }
Example #7
0
 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()));
 }
Example #8
0
 /**
  * @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()));
 }
Example #9
0
 /**
  * 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) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
 }
Example #10
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 /**
  * 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));
 }
 /**
  * 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) {
                         $messages[] = "msg-error-eventAlreadyScheduled";
                         break;
                     }
                 }
             }
             $evaluationCheck = true;
             if ($evaluationType == 'google') {
                 $evaluationCheck = isset($formKey) && isset($answerKey);
             } else {
                 $evaluationCheck = $evaluationType == 'default';
             }
             if (!$evaluationCheck) {
                 $messages[] = 'msg-error-eventFormKeyMissing';
             }
             if (!$conflictFound && $timesOk && $evaluationCheck) {
                 $data = array('locationId' => $locationId, 'workshopId' => $workshopId, 'startTime' => $startTime, 'endTime' => $endTime, 'date' => $date, 'minSize' => $minSize, 'maxSize' => $maxSize, 'waitlistSize' => $waitlistSize, 'password' => $password, 'evaluationType' => $evaluationType, 'formKey' => $formKey, 'answerKey' => $answerKey);
                 $eventId = $event->insert($data);
                 $instructor = new Event_Instructor();
                 foreach ($instructors as $i) {
                     $instructor->insert(array('accountId' => $i, 'eventId' => $eventId));
                 }
                 $this->_helper->flashMessenger->addMessage('msg-info-eventAdded');
                 $date = explode('-', $date);
                 $this->_helper->redirector->gotoUrl('/workshop/schedule?startYear=' . $date[0] . '&startMonth=' . (int) $date[1]);
             }
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/workshop/schedule/help.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/workshop/schedule/help.css');
     $this->view->form = $form;
     $this->_helper->pageTitle('workshop-schedule-addEvent:title');
 }
Example #15
0
 /**
  * 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;
 }
 /**
  * Get modification date (Unencoded Text)
  */
 public function testGetsDateModifiedFromAtom10()
 {
     $feed = Zend_Feed_Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml'));
     $source = $feed->current()->getSource();
     $edate = new Zend_Date();
     $edate->set('2009-03-07T08:03:50Z', Zend_Date::ISO_8601);
     $this->assertTrue($edate->equals($source->getDateModified()));
 }
 public function testSetTaskDueDate()
 {
     $this->markTestIncomplete();
     $series = $this->_getTaskSeries();
     $task = reset($series->getTaskList());
     $date = new Zend_Date();
     self::$_rtm->setTaskDueDate($series->getListId(), $series->getId(), $task->getId(), $date->toString());
     $this->assertTrue($date->equals($this->_getTask()->getDueDate()), 'Task due date was not set');
 }
Example #18
0
 /**
  * Test for equals
  */
 public function testEquals()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(0, null, $locale);
     $d2 = new Zend_Date(1010101010, null, $locale);
     $retour = $date->set(1234567890);
     $this->assertSame((string) $retour, '1234567890');
     $this->assertSame($date->equals(1234567890), true);
     $this->assertSame($date->equals(1234567800), false);
     $date->set($d2);
     $this->assertSame($date->equals(3, Zend_Date::DAY), false);
     $this->assertSame($date->equals(4, Zend_Date::DAY), true);
 }