Skip to content

Commit

Permalink
Moving Utility\Time to I18n\Time
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 31, 2014
1 parent 05a0292 commit caac0c6
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Component/CookieComponent.php
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Type/DateTimeType.php
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/Utility/Time.php → src/I18n/Time.php
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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];

Expand All @@ -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];

Expand All @@ -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",
Expand All @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/Model/Behavior/TimestampBehavior.php
Expand Up @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 12 additions & 12 deletions src/View/Helper/TimeHelper.php
Expand Up @@ -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;

Expand All @@ -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 {

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/BasicAuthenticateTest.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/DigestAuthenticateTest.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/FormAuthenticateTest.php
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Database/Type/DateTimeTypeTest.php
Expand Up @@ -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.
Expand All @@ -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'));
Expand All @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Type/DateTypeTest.php
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Type/TimeTypeTest.php
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Model/Behavior/TimestampBehaviorTest.php
Expand Up @@ -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
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -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
Expand Down

0 comments on commit caac0c6

Please sign in to comment.