Browse Source

Moving Utility\Time to I18n\Time

Jose Lorenzo Rodriguez 11 years ago
parent
commit
caac0c6d0a

+ 1 - 1
src/Controller/Component/CookieComponent.php

@@ -17,11 +17,11 @@ namespace Cake\Controller\Component;
 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.

+ 1 - 1
src/Database/Type/DateTimeType.php

@@ -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

+ 10 - 10
src/Utility/Time.php

@@ -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 @@ use JsonSerializable;
 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';
 

+ 2 - 2
src/Model/Behavior/TimestampBehavior.php

@@ -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 @@ class TimestampBehavior extends Behavior {
  *
  * @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) {

+ 12 - 12
src/View/Helper/TimeHelper.php

@@ -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 @@ use Cake\View\Helper\StringTemplateTrait;
  * 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 @@ class TimeHelper extends Helper {
  * @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 @@ 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 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 @@ 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 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 @@ class TimeHelper extends Helper {
  * @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 @@ 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 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 @@ 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 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 @@ class TimeHelper extends Helper {
  *
  * @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 @@ class TimeHelper extends Helper {
  * @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 @@ class TimeHelper extends Helper {
  * @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) {

+ 1 - 1
tests/TestCase/Auth/BasicAuthenticateTest.php

@@ -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

+ 1 - 1
tests/TestCase/Auth/DigestAuthenticateTest.php

@@ -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

+ 1 - 1
tests/TestCase/Auth/FormAuthenticateTest.php

@@ -19,12 +19,12 @@ use Cake\Cache\Cache;
 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

+ 1 - 1
tests/TestCase/Controller/Component/CookieComponentTest.php

@@ -18,11 +18,11 @@ use Cake\Controller\ComponentRegistry;
 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

+ 3 - 3
tests/TestCase/Database/Type/DateTimeTypeTest.php

@@ -17,7 +17,7 @@ namespace Cake\Test\TestCase\Database\Type;
 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 @@ class DateTimeTypeTest extends TestCase {
 		$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 @@ class DateTimeTypeTest extends TestCase {
 	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);
 	}
 
 /**

+ 1 - 1
tests/TestCase/Database/Type/DateTypeTest.php

@@ -17,7 +17,7 @@ namespace Cake\Test\TestCase\Database\Type;
 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.

+ 1 - 1
tests/TestCase/Database/Type/TimeTypeTest.php

@@ -17,7 +17,7 @@ namespace Cake\Test\TestCase\Database\Type;
 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.

+ 4 - 4
tests/TestCase/Model/Behavior/TimestampBehaviorTest.php

@@ -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 @@ class TimestampBehaviorTest extends TestCase {
 
 		$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 @@ class TimestampBehaviorTest extends TestCase {
 
 		$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 @@ class TimestampBehaviorTest extends TestCase {
 
 		$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');
 	}
 

+ 1 - 1
tests/TestCase/ORM/MarshallerTest.php

@@ -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.

+ 1 - 1
tests/TestCase/ORM/QueryRegressionTest.php

@@ -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

+ 1 - 1
tests/TestCase/ORM/TableTest.php

@@ -19,9 +19,9 @@ use Cake\Database\Expression\OrderByExpression;
 use Cake\Database\Expression\QueryExpression;
 use Cake\Database\TypeMap;
 use Cake\Datasource\ConnectionManager;
+use Cake\I18n\Time;
 use Cake\ORM\Table;
 use Cake\ORM\TableRegistry;
-use Cake\Utility\Time;
 use Cake\Validation\Validator;
 
 /**

+ 1 - 1
tests/TestCase/Utility/TimeTest.php

@@ -16,8 +16,8 @@
  */
 namespace Cake\Test\TestCase\Utility;
 
+use Cake\I18n\Time;
 use Cake\TestSuite\TestCase;
-use Cake\Utility\Time;
 
 /**
  * TimeTest class

+ 1 - 1
tests/TestCase/View/Helper/TimeHelperTest.php

@@ -17,8 +17,8 @@ namespace Cake\Test\TestCase\View\Helper;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
+use Cake\I18n\Time;
 use Cake\TestSuite\TestCase;
-use Cake\Utility\Time;
 use Cake\View\Helper\TimeHelper;
 use Cake\View\View;