예제 #1
0
 public function testTimestamp()
 {
     $time = time();
     $this->localeDate->expects($this->at(0))->method('date')->with(1404377188)->will($this->returnValue($this->date));
     $this->localeDate->expects($this->at(1))->method('date')->with($time)->will($this->returnValue($this->date));
     $this->localeDate->expects($this->at(2))->method('date')->with(strtotime("10 September 2000"))->will($this->returnValue($this->date));
     $this->assertSame(1403806949, $this->dateTime->timestamp());
     $this->assertSame(1403806949, $this->dateTime->timestamp($time));
     $this->assertSame(1403806949, $this->dateTime->timestamp("10 September 2000"));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function validateConsumer($consumer)
 {
     // Must use consumer within expiration period.
     $consumerTS = strtotime($consumer->getCreatedAt());
     $expiry = $this->_dataHelper->getConsumerExpirationPeriod();
     if ($this->_date->timestamp() - $consumerTS > $expiry) {
         throw new \Magento\Framework\Oauth\Exception('Consumer key has expired');
     }
     return true;
 }
예제 #3
0
 /**
  * @param int $timeStamp
  * @return int
  */
 private function roundTime($timeStamp)
 {
     if (is_numeric($timeStamp) && $timeStamp != 0) {
         $timeStamp = $this->dateTime->timestamp($this->dateTime->date('Y-m-d 00:00:00', $timeStamp));
     }
     return $timeStamp;
 }
예제 #4
0
 /**
  * @return $this
  */
 protected function _afterLoadData()
 {
     parent::_afterLoadData();
     if ($this->_addDaysInWishlist) {
         $gmtOffset = (int) $this->_date->getGmtOffset();
         $nowTimestamp = $this->_date->timestamp();
         foreach ($this as $wishlistItem) {
             $wishlistItemTimestamp = $this->_date->timestamp($wishlistItem->getAddedAt());
             $wishlistItem->setDaysInWishlist((int) (($nowTimestamp - $gmtOffset - $wishlistItemTimestamp) / 24 / 60 / 60));
         }
     }
     return $this;
 }
예제 #5
0
파일: Schedule.php 프로젝트: aiesh/magento2
 /**
  * Checks the observer's cron expression against time
  *
  * Supports $this->setCronExpr('* 0-5,10-59/5 2-10,15-25 january-june/2 mon-fri')
  *
  * @return bool
  */
 public function trySchedule()
 {
     $time = $this->getScheduledAt();
     $e = $this->getCronExprArr();
     if (!$e || !$time) {
         return false;
     }
     if (!is_numeric($time)) {
         $time = strtotime($time);
     }
     $d = getdate($this->_date->timestamp($time));
     $match = $this->matchCronExpression($e[0], $d['minutes']) && $this->matchCronExpression($e[1], $d['hours']) && $this->matchCronExpression($e[2], $d['mday']) && $this->matchCronExpression($e[3], $d['mon']) && $this->matchCronExpression($e[4], $d['wday']);
     return $match;
 }
예제 #6
0
 /**
  * @return int
  */
 public function getTs()
 {
     return $this->dateTime->timestamp();
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function generateTimestamp()
 {
     return $this->_date->timestamp();
 }
예제 #8
0
 /**
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 public function generate(\Magento\Sales\Model\Order $order)
 {
     $try = $this->transactionResource->getLastTryByOrderId($order->getId()) + 1;
     return $order->getIncrementId() . ':' . $this->dateTime->timestamp() . ':' . $try;
 }