mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
CakeTime functions can now use timezone string or DateTimeZone object for user offsets. (Passing numeric offsets has been kept for BC)
This commit is contained in:
parent
287c657977
commit
d34f0c2bd8
3 changed files with 156 additions and 123 deletions
|
@ -418,6 +418,7 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$yourTime = new DateTime('now', $yourTimezone);
|
$yourTime = new DateTime('now', $yourTimezone);
|
||||||
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
|
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
|
||||||
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
|
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
|
||||||
|
$this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $timezone));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,6 +624,12 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$expected = time();
|
$expected = time();
|
||||||
$result = $this->Time->fromString(time(), $yourTimezone);
|
$result = $this->Time->fromString(time(), $yourTimezone);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $this->Time->fromString(time(), $timezoneServer->getName());
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $this->Time->fromString(time(), $timezoneServer);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -645,6 +652,11 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$result = $this->Time->fromString('+1 hour', $timezone);
|
$result = $this->Time->fromString('+1 hour', $timezone);
|
||||||
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
|
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$timezone = date_default_timezone_get();
|
||||||
|
$result = $this->Time->fromString('+1 hour', $timezone);
|
||||||
|
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CakeTime {
|
||||||
* `strftime` (http://php.net/manual/en/function.strftime.php)
|
* `strftime` (http://php.net/manual/en/function.strftime.php)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @see TimeHelper::format()
|
* @see CakeTime::format()
|
||||||
*/
|
*/
|
||||||
public static $niceFormat = '%a, %b %eS %Y, %H:%M';
|
public static $niceFormat = '%a, %b %eS %Y, %H:%M';
|
||||||
|
|
||||||
|
@ -195,15 +195,23 @@ class CakeTime {
|
||||||
* Converts given time (in server's time zone) to user's local time, given his/her offset from GMT.
|
* Converts given time (in server's time zone) to user's local time, given his/her offset from GMT.
|
||||||
*
|
*
|
||||||
* @param string $serverTime UNIX timestamp
|
* @param string $serverTime UNIX timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return integer UNIX timestamp
|
* @return integer UNIX timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function convert($serverTime, $userOffset) {
|
public static function convert($serverTime, $timezone) {
|
||||||
$serverOffset = self::serverOffset();
|
$serverOffset = self::serverOffset();
|
||||||
$gmtTime = $serverTime - $serverOffset;
|
$gmtTime = $serverTime - $serverOffset;
|
||||||
$userTime = $gmtTime + $userOffset * (60 * 60);
|
if (is_numeric($timezone)) {
|
||||||
return $userTime;
|
$userOffset = $timezone * (60 * 60);
|
||||||
|
} else {
|
||||||
|
if (!is_object($timezone)) {
|
||||||
|
$timezone = new DateTimeZone($timezone);
|
||||||
|
}
|
||||||
|
$userOffset = $timezone->getOffset(new DateTime('@' . $gmtTime));
|
||||||
|
}
|
||||||
|
$userTime = $gmtTime + $userOffset;
|
||||||
|
return (int)$userTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,21 +228,23 @@ class CakeTime {
|
||||||
* Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string.
|
* Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string
|
* @param string $dateString Datetime string
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Parsed timestamp
|
* @return string Parsed timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function fromString($dateString, $userOffset = null) {
|
public static function fromString($dateString, $timezone = null) {
|
||||||
if (empty($dateString)) {
|
if (empty($dateString)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_integer($dateString) || is_numeric($dateString)) {
|
if (is_integer($dateString) || is_numeric($dateString)) {
|
||||||
$date = intval($dateString);
|
$date = intval($dateString);
|
||||||
} else {
|
} else {
|
||||||
$date = strtotime($dateString);
|
$date = strtotime($dateString);
|
||||||
}
|
}
|
||||||
if ($userOffset !== null) {
|
|
||||||
return self::convert($date, $userOffset);
|
if ($timezone !== null) {
|
||||||
|
return self::convert($date, $timezone);
|
||||||
}
|
}
|
||||||
if ($date === -1) {
|
if ($date === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -249,14 +259,14 @@ class CakeTime {
|
||||||
* using locale strings.
|
* using locale strings.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @param string $format The format to use. If null, `TimeHelper::$niceFormat` is used
|
* @param string $format The format to use. If null, `TimeHelper::$niceFormat` is used
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function nice($dateString = null, $userOffset = null, $format = null) {
|
public static function nice($dateString = null, $timezone = null, $format = null) {
|
||||||
if ($dateString != null) {
|
if ($dateString != null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
} else {
|
} else {
|
||||||
$date = time();
|
$date = time();
|
||||||
}
|
}
|
||||||
|
@ -276,18 +286,18 @@ class CakeTime {
|
||||||
* include mention of the year.
|
* include mention of the year.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Described, relative date string
|
* @return string Described, relative date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function niceShort($dateString = null, $userOffset = null) {
|
public static function niceShort($dateString = null, $timezone = null) {
|
||||||
$date = $dateString ? self::fromString($dateString, $userOffset) : time();
|
$date = $dateString ? self::fromString($dateString, $timezone) : time();
|
||||||
|
|
||||||
$y = self::isThisYear($date) ? '' : ' %Y';
|
$y = self::isThisYear($date) ? '' : ' %Y';
|
||||||
|
|
||||||
if (self::isToday($dateString, $userOffset)) {
|
if (self::isToday($dateString, $timezone)) {
|
||||||
$ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date));
|
$ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date));
|
||||||
} elseif (self::wasYesterday($dateString, $userOffset)) {
|
} elseif (self::wasYesterday($dateString, $timezone)) {
|
||||||
$ret = __d('cake', 'Yesterday, %s', self::_strftime("%H:%M", $date));
|
$ret = __d('cake', 'Yesterday, %s', self::_strftime("%H:%M", $date));
|
||||||
} else {
|
} else {
|
||||||
$format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date);
|
$format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date);
|
||||||
|
@ -303,13 +313,13 @@ class CakeTime {
|
||||||
* @param string $begin Datetime string or Unix timestamp
|
* @param string $begin Datetime string or Unix timestamp
|
||||||
* @param string $end Datetime string or Unix timestamp
|
* @param string $end Datetime string or Unix timestamp
|
||||||
* @param string $fieldName Name of database field to compare with
|
* @param string $fieldName Name of database field to compare with
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Partial SQL string.
|
* @return string Partial SQL string.
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
|
public static function daysAsSql($begin, $end, $fieldName, $timezone = null) {
|
||||||
$begin = self::fromString($begin, $userOffset);
|
$begin = self::fromString($begin, $timezone);
|
||||||
$end = self::fromString($end, $userOffset);
|
$end = self::fromString($end, $timezone);
|
||||||
$begin = date('Y-m-d', $begin) . ' 00:00:00';
|
$begin = date('Y-m-d', $begin) . ' 00:00:00';
|
||||||
$end = date('Y-m-d', $end) . ' 23:59:59';
|
$end = date('Y-m-d', $end) . ' 23:59:59';
|
||||||
|
|
||||||
|
@ -322,11 +332,11 @@ class CakeTime {
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param string $fieldName Name of database field to compare with
|
* @param string $fieldName Name of database field to compare with
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Partial SQL string.
|
* @return string Partial SQL string.
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
public static function dayAsSql($dateString, $fieldName, $timezone = null) {
|
||||||
return self::daysAsSql($dateString, $dateString, $fieldName);
|
return self::daysAsSql($dateString, $dateString, $fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,12 +344,12 @@ class CakeTime {
|
||||||
* Returns true if given datetime string is today.
|
* Returns true if given datetime string is today.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string is today
|
* @return boolean True if datetime string is today
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function isToday($dateString, $userOffset = null) {
|
public static function isToday($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('Y-m-d', $date) == date('Y-m-d', time());
|
return date('Y-m-d', $date) == date('Y-m-d', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,23 +357,23 @@ class CakeTime {
|
||||||
* Returns true if given datetime string is within this week.
|
* Returns true if given datetime string is within this week.
|
||||||
*
|
*
|
||||||
* @param string $dateString
|
* @param string $dateString
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string is within current week
|
* @return boolean True if datetime string is within current week
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function isThisWeek($dateString, $userOffset = null) {
|
public static function isThisWeek($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('W o', $date) == date('W o', time());
|
return date('W o', $date) == date('W o', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if given datetime string is within this month
|
* Returns true if given datetime string is within this month
|
||||||
* @param string $dateString
|
* @param string $dateString
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string is within current month
|
* @return boolean True if datetime string is within current month
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function isThisMonth($dateString, $userOffset = null) {
|
public static function isThisMonth($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString);
|
$date = self::fromString($dateString);
|
||||||
return date('m Y', $date) == date('m Y', time());
|
return date('m Y', $date) == date('m Y', time());
|
||||||
}
|
}
|
||||||
|
@ -372,12 +382,12 @@ class CakeTime {
|
||||||
* Returns true if given datetime string is within current year.
|
* Returns true if given datetime string is within current year.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string is within current year
|
* @return boolean True if datetime string is within current year
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function isThisYear($dateString, $userOffset = null) {
|
public static function isThisYear($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('Y', $date) == date('Y', time());
|
return date('Y', $date) == date('Y', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,13 +395,13 @@ class CakeTime {
|
||||||
* Returns true if given datetime string was yesterday.
|
* Returns true if given datetime string was yesterday.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string was yesterday
|
* @return boolean True if datetime string was yesterday
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function wasYesterday($dateString, $userOffset = null) {
|
public static function wasYesterday($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday'));
|
return date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,12 +409,12 @@ class CakeTime {
|
||||||
* Returns true if given datetime string is tomorrow.
|
* Returns true if given datetime string is tomorrow.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean True if datetime string was yesterday
|
* @return boolean True if datetime string was yesterday
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function isTomorrow($dateString, $userOffset = null) {
|
public static function isTomorrow($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow'));
|
return date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,24 +459,24 @@ class CakeTime {
|
||||||
* Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime().
|
* Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime().
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string to be represented as a Unix timestamp
|
* @param string $dateString Datetime string to be represented as a Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return integer Unix timestamp
|
* @return integer Unix timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function toUnix($dateString, $userOffset = null) {
|
public static function toUnix($dateString, $timezone = null) {
|
||||||
return self::fromString($dateString, $userOffset);
|
return self::fromString($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a date formatted for Atom RSS feeds.
|
* Returns a date formatted for Atom RSS feeds.
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function toAtom($dateString, $userOffset = null) {
|
public static function toAtom($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
return date('Y-m-d\TH:i:s\Z', $date);
|
return date('Y-m-d\TH:i:s\Z', $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,14 +484,24 @@ class CakeTime {
|
||||||
* Formats date for RSS feeds
|
* Formats date for RSS feeds
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function toRSS($dateString, $userOffset = null) {
|
public static function toRSS($dateString, $timezone = null) {
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
|
|
||||||
if (!is_null($userOffset)) {
|
if (!is_null($timezone)) {
|
||||||
|
if (is_numeric($timezone)) {
|
||||||
|
$userOffset = $timezone;
|
||||||
|
} else {
|
||||||
|
if (!is_object($timezone)) {
|
||||||
|
$timezone = new DateTimeZone($timezone);
|
||||||
|
}
|
||||||
|
$currentDate = new DateTime('@' . $date);
|
||||||
|
$currentDate->setTimezone($timezone);
|
||||||
|
$userOffset = $timezone->getOffset($currentDate) / 60 / 60;
|
||||||
|
}
|
||||||
if ($userOffset == 0) {
|
if ($userOffset == 0) {
|
||||||
$timezone = '+0000';
|
$timezone = '+0000';
|
||||||
} else {
|
} else {
|
||||||
|
@ -520,15 +540,16 @@ class CakeTime {
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function timeAgoInWords($dateTime, $options = array()) {
|
public static function timeAgoInWords($dateTime, $options = array()) {
|
||||||
$userOffset = null;
|
$timezone = null;
|
||||||
if (is_array($options) && isset($options['userOffset'])) {
|
if (is_array($options)) {
|
||||||
$userOffset = $options['userOffset'];
|
if (isset($options['userOffset'])) {
|
||||||
|
$timezone = $options['userOffset'];
|
||||||
|
} elseif (isset($options['timezone'])) {
|
||||||
|
$timezone = $options['timezone'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$now = time();
|
$now = self::fromString(time(), $timezone);
|
||||||
if (!is_null($userOffset)) {
|
$inSeconds = self::fromString($dateTime, $timezone);
|
||||||
$now = self::convert(time(), $userOffset);
|
|
||||||
}
|
|
||||||
$inSeconds = self::fromString($dateTime, $userOffset);
|
|
||||||
$backwards = ($inSeconds > $now);
|
$backwards = ($inSeconds > $now);
|
||||||
|
|
||||||
$format = 'j/n/y';
|
$format = 'j/n/y';
|
||||||
|
@ -678,17 +699,17 @@ class CakeTime {
|
||||||
* @param mixed $timeInterval the numeric value with space then time type.
|
* @param mixed $timeInterval the numeric value with space then time type.
|
||||||
* Example of valid types: 6 hours, 2 days, 1 minute.
|
* Example of valid types: 6 hours, 2 days, 1 minute.
|
||||||
* @param mixed $dateString the datestring or unix timestamp to compare
|
* @param mixed $dateString the datestring or unix timestamp to compare
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public static function wasWithinLast($timeInterval, $dateString, $userOffset = null) {
|
public static function wasWithinLast($timeInterval, $dateString, $timezone = null) {
|
||||||
$tmp = str_replace(' ', '', $timeInterval);
|
$tmp = str_replace(' ', '', $timeInterval);
|
||||||
if (is_numeric($tmp)) {
|
if (is_numeric($tmp)) {
|
||||||
$timeInterval = $tmp . ' ' . __d('cake', 'days');
|
$timeInterval = $tmp . ' ' . __d('cake', 'days');
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = self::fromString($dateString, $userOffset);
|
$date = self::fromString($dateString, $timezone);
|
||||||
$interval = self::fromString('-' . $timeInterval);
|
$interval = self::fromString('-' . $timeInterval);
|
||||||
|
|
||||||
if ($date >= $interval && $date <= time()) {
|
if ($date >= $interval && $date <= time()) {
|
||||||
|
@ -729,17 +750,17 @@ class CakeTime {
|
||||||
* @param string $format date format string (or a DateTime string)
|
* @param string $format date format string (or a DateTime string)
|
||||||
* @param string $date Datetime string (or a date format string)
|
* @param string $date Datetime string (or a date format string)
|
||||||
* @param boolean $invalid flag to ignore results of fromString == false
|
* @param boolean $invalid flag to ignore results of fromString == false
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function format($format, $date = null, $invalid = false, $userOffset = null) {
|
public static function format($format, $date = null, $invalid = false, $timezone = null) {
|
||||||
$time = self::fromString($date, $userOffset);
|
$time = self::fromString($date, $timezone);
|
||||||
$_time = self::fromString($format, $userOffset);
|
$_time = self::fromString($format, $timezone);
|
||||||
|
|
||||||
if (is_numeric($_time) && $time === false) {
|
if (is_numeric($_time) && $time === false) {
|
||||||
$format = $date;
|
$format = $date;
|
||||||
return self::i18nFormat($_time, $format, $invalid, $userOffset);
|
return self::i18nFormat($_time, $format, $invalid, $timezone);
|
||||||
}
|
}
|
||||||
if ($time === false && $invalid !== false) {
|
if ($time === false && $invalid !== false) {
|
||||||
return $invalid;
|
return $invalid;
|
||||||
|
@ -754,12 +775,12 @@ class CakeTime {
|
||||||
* @param string $date Datetime string
|
* @param string $date Datetime string
|
||||||
* @param string $format strftime format string.
|
* @param string $format strftime format string.
|
||||||
* @param boolean $invalid flag to ignore results of fromString == false
|
* @param boolean $invalid flag to ignore results of fromString == false
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone Timezone string or DateTimezone object
|
||||||
* @return string Formatted and translated date string
|
* @return string Formatted and translated date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public static function i18nFormat($date, $format = null, $invalid = false, $userOffset = null) {
|
public static function i18nFormat($date, $format = null, $invalid = false, $timezone = null) {
|
||||||
$date = self::fromString($date, $userOffset);
|
$date = self::fromString($date, $timezone);
|
||||||
if ($date === false && $invalid !== false) {
|
if ($date === false && $invalid !== false) {
|
||||||
return $invalid;
|
return $invalid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,12 +137,12 @@ class TimeHelper extends AppHelper {
|
||||||
* @see CakeTime::convert()
|
* @see CakeTime::convert()
|
||||||
*
|
*
|
||||||
* @param string $serverTime UNIX timestamp
|
* @param string $serverTime UNIX timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return integer UNIX timestamp
|
* @return integer UNIX timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function convert($serverTime, $userOffset) {
|
public function convert($serverTime, $timezone) {
|
||||||
return $this->_engine->convert($serverTime, $userOffset);
|
return $this->_engine->convert($serverTime, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,37 +159,37 @@ class TimeHelper extends AppHelper {
|
||||||
* @see CakeTime::fromString()
|
* @see CakeTime::fromString()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string
|
* @param string $dateString Datetime string
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Parsed timestamp
|
* @return string Parsed timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function fromString($dateString, $userOffset = null) {
|
public function fromString($dateString, $timezone = null) {
|
||||||
return $this->_engine->fromString($dateString, $userOffset);
|
return $this->_engine->fromString($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::nice()
|
* @see CakeTime::nice()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @param string $format The format to use. If null, `TimeHelper::$niceFormat` is used
|
* @param string $format The format to use. If null, `TimeHelper::$niceFormat` is used
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function nice($dateString = null, $userOffset = null, $format = null) {
|
public function nice($dateString = null, $timezone = null, $format = null) {
|
||||||
return $this->_engine->nice($dateString, $userOffset, $format);
|
return $this->_engine->nice($dateString, $timezone, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::niceShort()
|
* @see CakeTime::niceShort()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Described, relative date string
|
* @return string Described, relative date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function niceShort($dateString = null, $userOffset = null) {
|
public function niceShort($dateString = null, $timezone = null) {
|
||||||
return $this->_engine->niceShort($dateString, $userOffset);
|
return $this->_engine->niceShort($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,12 +198,12 @@ class TimeHelper extends AppHelper {
|
||||||
* @param string $begin Datetime string or Unix timestamp
|
* @param string $begin Datetime string or Unix timestamp
|
||||||
* @param string $end Datetime string or Unix timestamp
|
* @param string $end Datetime string or Unix timestamp
|
||||||
* @param string $fieldName Name of database field to compare with
|
* @param string $fieldName Name of database field to compare with
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Partial SQL string.
|
* @return string Partial SQL string.
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
|
public function daysAsSql($begin, $end, $fieldName, $timezone = null) {
|
||||||
return $this->_engine->daysAsSql($begin, $end, $fieldName, $userOffset);
|
return $this->_engine->daysAsSql($begin, $end, $fieldName, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,85 +211,85 @@ class TimeHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param string $fieldName Name of database field to compare with
|
* @param string $fieldName Name of database field to compare with
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Partial SQL string.
|
* @return string Partial SQL string.
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
public function dayAsSql($dateString, $fieldName, $timezone = null) {
|
||||||
return $this->_engine->dayAsSql($dateString, $fieldName, $userOffset);
|
return $this->_engine->dayAsSql($dateString, $fieldName, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::isToday()
|
* @see CakeTime::isToday()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string is today
|
* @return boolean True if datetime string is today
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function isToday($dateString, $userOffset = null) {
|
public function isToday($dateString, $timezone = null) {
|
||||||
return $this->_engine->isToday($dateString, $userOffset);
|
return $this->_engine->isToday($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::isThisWeek()
|
* @see CakeTime::isThisWeek()
|
||||||
*
|
*
|
||||||
* @param string $dateString
|
* @param string $dateString
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string is within current week
|
* @return boolean True if datetime string is within current week
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function isThisWeek($dateString, $userOffset = null) {
|
public function isThisWeek($dateString, $timezone = null) {
|
||||||
return $this->_engine->isThisWeek($dateString, $userOffset);
|
return $this->_engine->isThisWeek($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::isThisMonth()
|
* @see CakeTime::isThisMonth()
|
||||||
*
|
*
|
||||||
* @param string $dateString
|
* @param string $dateString
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string is within current month
|
* @return boolean True if datetime string is within current month
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function isThisMonth($dateString, $userOffset = null) {
|
public function isThisMonth($dateString, $timezone = null) {
|
||||||
return $this->_engine->isThisMonth($dateString, $userOffset);
|
return $this->_engine->isThisMonth($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::isThisYear()
|
* @see CakeTime::isThisYear()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string is within current year
|
* @return boolean True if datetime string is within current year
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function isThisYear($dateString, $userOffset = null) {
|
public function isThisYear($dateString, $timezone = null) {
|
||||||
return $this->_engine->isThisYear($dateString, $userOffset);
|
return $this->_engine->isThisYear($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::wasYesterday()
|
* @see CakeTime::wasYesterday()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string was yesterday
|
* @return boolean True if datetime string was yesterday
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function wasYesterday($dateString, $userOffset = null) {
|
public function wasYesterday($dateString, $timezone = null) {
|
||||||
return $this->_engine->wasYesterday($dateString, $userOffset);
|
return $this->_engine->wasYesterday($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::isTomorrow()
|
* @see CakeTime::isTomorrow()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean True if datetime string was yesterday
|
* @return boolean True if datetime string was yesterday
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function isTomorrow($dateString, $userOffset = null) {
|
public function isTomorrow($dateString, $timezone = null) {
|
||||||
return $this->_engine->isTomorrow($dateString, $userOffset);
|
return $this->_engine->isTomorrow($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,36 +308,36 @@ class TimeHelper extends AppHelper {
|
||||||
* @see CakeTime::toUnix()
|
* @see CakeTime::toUnix()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string to be represented as a Unix timestamp
|
* @param string $dateString Datetime string to be represented as a Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return integer Unix timestamp
|
* @return integer Unix timestamp
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function toUnix($dateString, $userOffset = null) {
|
public function toUnix($dateString, $timezone = null) {
|
||||||
return $this->_engine->toUnix($dateString, $userOffset);
|
return $this->_engine->toUnix($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::toAtom()
|
* @see CakeTime::toAtom()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function toAtom($dateString, $userOffset = null) {
|
public function toAtom($dateString, $timezone = null) {
|
||||||
return $this->_engine->toAtom($dateString, $userOffset);
|
return $this->_engine->toAtom($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CakeTime::toRSS()
|
* @see CakeTime::toRSS()
|
||||||
*
|
*
|
||||||
* @param string $dateString Datetime string or Unix timestamp
|
* @param string $dateString Datetime string or Unix timestamp
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function toRSS($dateString, $userOffset = null) {
|
public function toRSS($dateString, $timezone = null) {
|
||||||
return $this->_engine->toRSS($dateString, $userOffset);
|
return $this->_engine->toRSS($dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -358,12 +358,12 @@ class TimeHelper extends AppHelper {
|
||||||
* @param mixed $timeInterval the numeric value with space then time type.
|
* @param mixed $timeInterval the numeric value with space then time type.
|
||||||
* Example of valid types: 6 hours, 2 days, 1 minute.
|
* Example of valid types: 6 hours, 2 days, 1 minute.
|
||||||
* @param mixed $dateString the datestring or unix timestamp to compare
|
* @param mixed $dateString the datestring or unix timestamp to compare
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
||||||
*/
|
*/
|
||||||
public function wasWithinLast($timeInterval, $dateString, $userOffset = null) {
|
public function wasWithinLast($timeInterval, $dateString, $timezone = null) {
|
||||||
return $this->_engine->wasWithinLast($timeInterval, $dateString, $userOffset);
|
return $this->_engine->wasWithinLast($timeInterval, $dateString, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -383,12 +383,12 @@ class TimeHelper extends AppHelper {
|
||||||
* @param string $format date format string (or a DateTime string)
|
* @param string $format date format string (or a DateTime string)
|
||||||
* @param string $date Datetime string (or a date format string)
|
* @param string $date Datetime string (or a date format string)
|
||||||
* @param boolean $invalid flag to ignore results of fromString == false
|
* @param boolean $invalid flag to ignore results of fromString == false
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Formatted date string
|
* @return string Formatted date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function format($format, $date = null, $invalid = false, $userOffset = null) {
|
public function format($format, $date = null, $invalid = false, $timezone = null) {
|
||||||
return $this->_engine->format($format, $date, $invalid, $userOffset);
|
return $this->_engine->format($format, $date, $invalid, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,12 +397,12 @@ class TimeHelper extends AppHelper {
|
||||||
* @param string $date Datetime string
|
* @param string $date Datetime string
|
||||||
* @param string $format strftime format string.
|
* @param string $format strftime format string.
|
||||||
* @param boolean $invalid flag to ignore results of fromString == false
|
* @param boolean $invalid flag to ignore results of fromString == false
|
||||||
* @param integer $userOffset User's offset from GMT (in hours)
|
* @param mixed $timezone User's timezone string or DateTimeZone object
|
||||||
* @return string Formatted and translated date string
|
* @return string Formatted and translated date string
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
|
||||||
*/
|
*/
|
||||||
public function i18nFormat($date, $format = null, $invalid = false, $userOffset = null) {
|
public function i18nFormat($date, $format = null, $invalid = false, $timezone = null) {
|
||||||
return $this->_engine->i18nFormat($date, $format, $invalid, $userOffset);
|
return $this->_engine->i18nFormat($date, $format, $invalid, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue