Skip to content

Commit

Permalink
Added @link CakeTime.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimegede committed Sep 1, 2013
1 parent f32760e commit 539040a
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -131,7 +131,7 @@ public function __get($name) {
* Accepts the special specifier %S which mimics the modifier S for date()
* @param string $time UNIX timestamp
* @return string windows safe and date() function compatible format for strftime
* @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#TimeHelper::convertSpecifiers
*/
public static function convertSpecifiers($format, $time = null) {
if (!$time) {
Expand Down Expand Up @@ -244,7 +244,7 @@ protected static function _translateSpecifier($specifier) {
* @param string $serverTime UNIX timestamp
* @param string|DateTimeZone $timezone User's timezone string or DateTimeZone object
* @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#TimeHelper::convert
*/
public static function convert($serverTime, $timezone) {
static $serverTimezone = null;
Expand All @@ -269,6 +269,7 @@ public static function convert($serverTime, $timezone) {
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* If null it tries to get timezone from 'Config.timezone' config var
* @return DateTimeZone Timezone object
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::timezone
*/
public static function timezone($timezone = null) {
static $tz = null;
Expand Down Expand Up @@ -297,7 +298,7 @@ public static function timezone($timezone = null) {
* Returns server's offset from GMT in seconds.
*
* @return integer Offset
* @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#TimeHelper::serverOffset
*/
public static function serverOffset() {
return date('Z', time());
Expand All @@ -309,7 +310,7 @@ public static function serverOffset() {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::fromString
*/
public static function fromString($dateString, $timezone = null) {
if (empty($dateString)) {
Expand Down Expand Up @@ -360,7 +361,7 @@ public static function fromString($dateString, $timezone = null) {
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @param string $format The format to use. If null, `TimeHelper::$niceFormat` is used
* @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#TimeHelper::nice
*/
public static function nice($dateString = null, $timezone = null, $format = null) {
if (!$dateString) {
Expand All @@ -387,7 +388,7 @@ public static function nice($dateString = null, $timezone = null, $format = null
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::niceShort
*/
public static function niceShort($dateString = null, $timezone = null) {
if (!$dateString) {
Expand Down Expand Up @@ -437,7 +438,7 @@ public static function niceShort($dateString = null, $timezone = null) {
* @param string $fieldName Name of database field to compare with
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::daysAsSql
*/
public static function daysAsSql($begin, $end, $fieldName, $timezone = null) {
$begin = self::fromString($begin, $timezone);
Expand All @@ -456,7 +457,7 @@ public static function daysAsSql($begin, $end, $fieldName, $timezone = null) {
* @param string $fieldName Name of database field to compare with
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::dayAsSql
*/
public static function dayAsSql($dateString, $fieldName, $timezone = null) {
return self::daysAsSql($dateString, $dateString, $fieldName);
Expand All @@ -468,7 +469,7 @@ public static function dayAsSql($dateString, $fieldName, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::isToday
*/
public static function isToday($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -482,7 +483,7 @@ public static function isToday($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @return boolean True if datetime string is in the future
* @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#TimeHelper::isFuture
*/
public static function isFuture($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -495,7 +496,7 @@ public static function isFuture($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @return boolean True if datetime string is in the past
* @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#TimeHelper::isPast
*/
public static function isPast($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -508,7 +509,7 @@ public static function isPast($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::isThisWeek
*/
public static function isThisWeek($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -522,7 +523,7 @@ public static function isThisWeek($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::isThisMonth
*/
public static function isThisMonth($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -536,7 +537,7 @@ public static function isThisMonth($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::isThisYear
*/
public static function isThisYear($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -550,8 +551,7 @@ public static function isThisYear($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::wasYesterday
*/
public static function wasYesterday($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -565,7 +565,7 @@ public static function wasYesterday($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::isTomorrow
*/
public static function isTomorrow($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
Expand All @@ -579,7 +579,7 @@ public static function isTomorrow($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param boolean $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
* @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#TimeHelper::toQuarter
*/
public static function toQuarter($dateString, $range = false) {
$time = self::fromString($dateString);
Expand All @@ -603,10 +603,11 @@ public static function toQuarter($dateString, $range = false) {

/**
* Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime().
*
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::toUnix
*/
public static function toUnix($dateString, $timezone = null) {
return self::fromString($dateString, $timezone);
Expand All @@ -625,6 +626,7 @@ public static function toUnix($dateString, $timezone = null) {
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @param string $format date format string
* @return mixed Formatted date
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toServer
*/
public static function toServer($dateString, $timezone = null, $format = 'Y-m-d H:i:s') {
if ($timezone === null) {
Expand Down Expand Up @@ -656,7 +658,7 @@ public static function toServer($dateString, $timezone = null, $format = 'Y-m-d
* @param string $dateString Datetime string or Unix timestamp
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::toAtom
*/
public static function toAtom($dateString, $timezone = null) {
return date('Y-m-d\TH:i:s\Z', self::fromString($dateString, $timezone));
Expand All @@ -668,7 +670,7 @@ public static function toAtom($dateString, $timezone = null) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::toRSS
*/
public static function toRSS($dateString, $timezone = null) {
$date = self::fromString($dateString, $timezone);
Expand Down Expand Up @@ -733,7 +735,7 @@ public static function toRSS($dateString, $timezone = null) {
* @param integer|string|DateTime $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.
* @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#TimeHelper::timeAgoInWords
*/
public static function timeAgoInWords($dateTime, $options = array()) {
$timezone = null;
Expand Down Expand Up @@ -945,7 +947,7 @@ public static function timeAgoInWords($dateTime, $options = array()) {
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::wasWithinLast
*/
public static function wasWithinLast($timeInterval, $dateString, $timezone = null) {
$tmp = str_replace(' ', '', $timeInterval);
Expand All @@ -968,7 +970,6 @@ public static function wasWithinLast($timeInterval, $dateString, $timezone = nul
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @return boolean
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
*/
public static function isWithinNext($timeInterval, $dateString, $timezone = null) {
$tmp = str_replace(' ', '', $timeInterval);
Expand All @@ -988,7 +989,7 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null
*
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @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#TimeHelper::gmt
*/
public static function gmt($dateString = null) {
$time = time();
Expand Down Expand Up @@ -1026,7 +1027,7 @@ public static function gmt($dateString = null) {
* @param boolean|string $default if an invalid date is passed it will output supplied default value. Pass false if you want raw conversion value
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::format
* @see CakeTime::i18nFormat()
*/
public static function format($date, $format = null, $default = false, $timezone = null) {
Expand All @@ -1048,7 +1049,7 @@ public static function format($date, $format = null, $default = false, $timezone
* @param boolean|string $default if an invalid date is passed it will output supplied default value. Pass false if you want raw conversion value
* @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
* @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#TimeHelper::i18nFormat
*/
public static function i18nFormat($date, $format = null, $default = false, $timezone = null) {
$date = self::fromString($date, $timezone);
Expand All @@ -1071,6 +1072,7 @@ public static function i18nFormat($date, $format = null, $default = false, $time
* @param boolean $group If true (default value) groups the identifiers list by primary region
* @return array List of timezone identifiers
* @since 2.2
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::listTimezones
*/
public static function listTimezones($filter = null, $country = null, $group = true) {
$regex = null;
Expand Down

0 comments on commit 539040a

Please sign in to comment.