Skip to content
Permalink
Browse files

Moving Utility\Time to I18n\Time

  • Loading branch information...
lorenzo committed Aug 31, 2014
1 parent 05a0292 commit caac0c6d0a161335a868677a578584c49e0d7b1b
@@ -17,11 +17,11 @@
use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
use Cake\I18n\Time;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Utility\Hash;
use Cake\Utility\Security;
use Cake\Utility\Time;
/**
* Cookie Component.
@@ -28,7 +28,7 @@ class DateTimeType extends \Cake\Database\Type {
*
* @var string
*/
public static $dateTimeClass = 'Cake\Utility\Time';
public static $dateTimeClass = 'Cake\I18n\Time';
/**
* String format to use for DateTime parsing
@@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Utility;
namespace Cake\I18n;
use Carbon\Carbon;
use IntlDateFormatter;
@@ -26,7 +26,7 @@
class Time extends Carbon implements JsonSerializable {
/**
* The format to use when formatting a time using `Cake\Utility\Time::i18nFormat()`
* The format to use when formatting a time using `Cake\I18n\Time::i18nFormat()`
* and `__toString`
*
* The format should be either the formatting constants from IntlDateFormatter as
@@ -38,12 +38,12 @@ class Time extends Carbon implements JsonSerializable {
* will be used to format the time part.
*
* @var mixed
* @see \Cake\Utility\Time::i18nFormat()
* @see \Cake\I18n\Time::i18nFormat()
*/
protected static $_toStringFormat = [IntlDateFormatter::SHORT, IntlDateFormatter::SHORT];
/**
* The format to use when formatting a time using `Cake\Utility\Time::nice()`
* The format to use when formatting a time using `Cake\I18n\Time::nice()`
*
* The format should be eiter the formatting constants from IntlDateFormatter as
* described in (http://www.php.net/manual/en/class.intldateformatter.php) or a pattern
@@ -54,7 +54,7 @@ class Time extends Carbon implements JsonSerializable {
* will be used to format the time part.
*
* @var mixed
* @see \Cake\Utility\Time::nice()
* @see \Cake\I18n\Time::nice()
*/
public static $niceFormat = [IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT];
@@ -66,11 +66,11 @@ class Time extends Carbon implements JsonSerializable {
public static $defaultLocale;
/**
* The format to use when formatting a time using `Cake\Utility\Time::timeAgoInWords()`
* and the difference is more than `Cake\Utility\Time::$wordEnd`
* The format to use when formatting a time using `Cake\I18n\Time::timeAgoInWords()`
* and the difference is more than `Cake\I18n\Time::$wordEnd`
*
* @var string
* @see \Cake\Utility\Time::timeAgoInWords()
* @see \Cake\I18n\Time::timeAgoInWords()
*/
public static $wordFormat = [IntlDateFormatter::SHORT, -1];
@@ -79,7 +79,7 @@ class Time extends Carbon implements JsonSerializable {
* and the difference is less than `Time::$wordEnd`
*
* @var array
* @see \Cake\Utility\Time::timeAgoInWords()
* @see \Cake\I18n\Time::timeAgoInWords()
*/
public static $wordAccuracy = array(
'year' => "day",
@@ -95,7 +95,7 @@ class Time extends Carbon implements JsonSerializable {
* The end of relative time telling
*
* @var string
* @see \Cake\Utility\Time::timeAgoInWords()
* @see \Cake\I18n\Time::timeAgoInWords()
*/
public static $wordEnd = '+1 month';
@@ -15,10 +15,10 @@
namespace Cake\Model\Behavior;
use Cake\Event\Event;
use Cake\I18n\Time;
use Cake\ORM\Behavior;
use Cake\ORM\Entity;
use Cake\ORM\Table;
use Cake\Utility\Time;
class TimestampBehavior extends Behavior {
@@ -130,7 +130,7 @@ public function implementedEvents() {
*
* @param \DateTime $ts Timestamp
* @param bool $refreshTimestamp If true timestamp is refreshed.
* @return \Cake\Utility\Time
* @return \Cake\I18n\Time
*/
public function timestamp(\DateTime $ts = null, $refreshTimestamp = false) {
if ($ts) {
@@ -14,7 +14,7 @@
*/
namespace Cake\View\Helper;
use Cake\Utility\Time;
use Cake\I18n\Time;
use Cake\View\Helper;
use Cake\View\Helper\StringTemplateTrait;
@@ -24,7 +24,7 @@
* Manipulation of time data.
*
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html
* @see \Cake\Utility\Time
* @see \Cake\I18n\Time
*/
class TimeHelper extends Helper {
@@ -35,7 +35,7 @@ class TimeHelper extends Helper {
*
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return \Cake\Utility\Time
* @return \Cake\I18n\Time
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function fromString($dateString, $timezone = null) {
@@ -158,7 +158,7 @@ public function isTomorrow($dateString, $timezone = null) {
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param bool $range if true returns a range in Y-m-d format
* @return mixed 1, 2, 3, or 4 quarter of year or array if $range true
* @see \Cake\Utility\Time::toQuarter()
* @see \Cake\I18n\Time::toQuarter()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function toQuarter($dateString, $range = false) {
@@ -171,7 +171,7 @@ public function toQuarter($dateString, $range = false) {
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return int Unix timestamp
* @see \Cake\Utility\Time::toUnix()
* @see \Cake\I18n\Time::toUnix()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function toUnix($dateString, $timezone = null) {
@@ -184,7 +184,7 @@ public function toUnix($dateString, $timezone = null) {
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return string Formatted date string
* @see \Cake\Utility\Time::toAtom()
* @see \Cake\I18n\Time::toAtom()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function toAtom($dateString, $timezone = null) {
@@ -219,7 +219,7 @@ public function toRSS($dateString, $timezone = null) {
* @param int|string|\DateTime $dateTime UNIX timestamp, strtotime() valid string or DateTime object
* @param array $options Default format if timestamp is used in $dateString
* @return string Relative time string.
* @see \Cake\Utility\Time::timeAgoInWords()
* @see \Cake\I18n\Time::timeAgoInWords()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function timeAgoInWords($dateTime, array $options = array()) {
@@ -261,7 +261,7 @@ public function timeAgoInWords($dateTime, array $options = array()) {
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return bool
* @see \Cake\Utility\Time::wasWithinLast()
* @see \Cake\I18n\Time::wasWithinLast()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
*/
public function wasWithinLast($timeInterval, $dateString, $timezone = null) {
@@ -276,7 +276,7 @@ public function wasWithinLast($timeInterval, $dateString, $timezone = null) {
* @param int|string|\DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return bool
* @see \Cake\Utility\Time::wasWithinLast()
* @see \Cake\I18n\Time::wasWithinLast()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
*/
public function isWithinNext($timeInterval, $dateString, $timezone = null) {
@@ -288,7 +288,7 @@ public function isWithinNext($timeInterval, $dateString, $timezone = null) {
*
* @param int|string|\DateTime $string UNIX timestamp, strtotime() valid string or DateTime object
* @return int UNIX timestamp
* @see \Cake\Utility\Time::gmt()
* @see \Cake\I18n\Time::gmt()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function gmt($string = null) {
@@ -306,7 +306,7 @@ public function gmt($string = null) {
* @param bool|string $invalid Default value to display on invalid dates
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return string Formatted and translated date string
* @see \Cake\Utility\Time::i18nFormat()
* @see \Cake\I18n\Time::i18nFormat()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function format($date, $format = null, $invalid = false, $timezone = null) {
@@ -324,7 +324,7 @@ public function format($date, $format = null, $invalid = false, $timezone = null
* @param string|\DateTimeZone $timezone User's timezone string or DateTimeZone object
* @return string Formatted and translated date string
* @throws \InvalidArgumentException When the date cannot be parsed
* @see \Cake\Utility\Time::i18nFormat()
* @see \Cake\I18n\Time::i18nFormat()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/
public function i18nFormat($date, $format = null, $invalid = false, $timezone = null) {
@@ -15,13 +15,13 @@
namespace Cake\Test\TestCase\Auth;
use Cake\Auth\BasicAuthenticate;
use Cake\I18n\Time;
use Cake\Network\Exception\UnauthorizedException;
use Cake\Network\Request;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use Cake\Utility\Time;
/**
* Test case for BasicAuthentication
@@ -17,12 +17,12 @@
namespace Cake\Test\TestCase\Auth;
use Cake\Auth\DigestAuthenticate;
use Cake\I18n\Time;
use Cake\Network\Exception\UnauthorizedException;
use Cake\Network\Request;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
/**
* Test case for DigestAuthentication
@@ -19,12 +19,12 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\I18n\Time;
use Cake\Network\Request;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use Cake\Utility\Time;
/**
* Test case for FormAuthentication
@@ -18,11 +18,11 @@
use Cake\Controller\Component\CookieComponent;
use Cake\Controller\Controller;
use Cake\Event\Event;
use Cake\I18n\Time;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use Cake\Utility\Time;
/**
* CookieComponentTest class
@@ -17,7 +17,7 @@
use Cake\Database\Type;
use Cake\Database\Type\DateTimeType;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
use Cake\I18n\Time;
/**
* Test for the DateTime type.
@@ -44,7 +44,7 @@ public function testToPHP() {
$this->assertNull($this->type->toPHP(null, $this->driver));
$result = $this->type->toPHP('2001-01-04 12:13:14', $this->driver);
$this->assertInstanceOf('Cake\Utility\Time', $result);
$this->assertInstanceOf('Cake\I18n\Time', $result);
$this->assertEquals('2001', $result->format('Y'));
$this->assertEquals('01', $result->format('m'));
$this->assertEquals('04', $result->format('d'));
@@ -64,7 +64,7 @@ public function testToPHP() {
public function testToPHPIncludingMilliseconds() {
$in = '2014-03-24 20:44:36.315113';
$result = $this->type->toPHP($in, $this->driver);
$this->assertInstanceOf('Cake\Utility\Time', $result);
$this->assertInstanceOf('Cake\I18n\Time', $result);
}
/**
@@ -17,7 +17,7 @@
use Cake\Database\Type;
use Cake\Database\Type\DateType;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
use Cake\I18n\Time;
/**
* Test for the Date type.
@@ -17,7 +17,7 @@
use Cake\Database\Type;
use Cake\Database\Type\TimeType;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
use Cake\I18n\Time;
/**
* Test for the Time type.
@@ -15,11 +15,11 @@
namespace Cake\Test\TestCase\Model\Behavior;
use Cake\Event\Event;
use Cake\I18n\Time;
use Cake\Model\Behavior\TimestampBehavior;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
/**
* Behavior test case
@@ -93,7 +93,7 @@ public function testCreatedAbsent() {
$return = $this->Behavior->handleEvent($event, $entity);
$this->assertTrue($return, 'Handle Event is expected to always return true');
$this->assertInstanceOf('Cake\Utility\Time', $entity->created);
$this->assertInstanceOf('Cake\I18n\Time', $entity->created);
$this->assertSame($ts->format('c'), $entity->created->format('c'), 'Created timestamp is not the same');
}
@@ -154,7 +154,7 @@ public function testModifiedAbsent() {
$return = $this->Behavior->handleEvent($event, $entity);
$this->assertTrue($return, 'Handle Event is expected to always return true');
$this->assertInstanceOf('Cake\Utility\Time', $entity->modified);
$this->assertInstanceOf('Cake\I18n\Time', $entity->modified);
$this->assertSame($ts->format('c'), $entity->modified->format('c'), 'Modified timestamp is not the same');
}
@@ -177,7 +177,7 @@ public function testModifiedPresent() {
$return = $this->Behavior->handleEvent($event, $entity);
$this->assertTrue($return, 'Handle Event is expected to always return true');
$this->assertInstanceOf('Cake\Utility\Time', $entity->modified);
$this->assertInstanceOf('Cake\I18n\Time', $entity->modified);
$this->assertSame($ts->format('c'), $entity->modified->format('c'), 'Modified timestamp is expected to be updated');
}
@@ -14,12 +14,12 @@
*/
namespace Cake\Test\TestCase\ORM;
use Cake\I18n\Time;
use Cake\ORM\Entity;
use Cake\ORM\Marshaller;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
/**
* Test entity for mass assignment.
@@ -15,11 +15,11 @@
namespace Cake\Test\TestCase\ORM;
use Cake\Core\Plugin;
use Cake\I18n\Time;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
use Cake\Utility\Time;
/**
* Contains regression test for the Query builder
Oops, something went wrong.

0 comments on commit caac0c6

Please sign in to comment.
You can’t perform that action at this time.