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")); }
/** * {@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; }
/** * @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; }
/** * @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; }
/** * 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; }
/** * @return int */ public function getTs() { return $this->dateTime->timestamp(); }
/** * {@inheritdoc} */ public function generateTimestamp() { return $this->_date->timestamp(); }
/** * @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; }