mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Renaming param in CakeTime::format() to make its purpose more obvious,
added some examples in doc block
This commit is contained in:
parent
0d013f8da5
commit
a2c2902dd6
1 changed files with 12 additions and 4 deletions
|
@ -928,14 +928,22 @@ class CakeTime {
|
|||
* This function also accepts a time string and a format string as first and second parameters.
|
||||
* In that case this function behaves as a wrapper for TimeHelper::i18nFormat()
|
||||
*
|
||||
* ## Examples:
|
||||
* {{{
|
||||
* CakeTime::format('2012-02-15', '%m-%d-%Y'); // returns 02-15-2012
|
||||
* CakeTime::format('2012-02-15 23:01:01', '%c'); // returns preferred date and time based on configured locale
|
||||
* CakeTime::format('0000-00-00', '%d-%m-%Y', 'N/A'); // return N/A becuase an invalid date was passed
|
||||
* CakeTime::format('2012-02-15 23:01:01', '%c', 'N/A', 'America/New_York'); // converts passed date to timezone
|
||||
* }}}
|
||||
*
|
||||
* @param integer|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object (or a date format string)
|
||||
* @param integer|string|DateTime $format date format string (or UNIX timestamp, strtotime() valid string or DateTime object)
|
||||
* @param boolean $invalid flag to ignore results of fromString == false
|
||||
* @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
|
||||
*/
|
||||
public static function format($date, $format = null, $invalid = false, $timezone = null) {
|
||||
public static function format($date, $format = null, $default = false, $timezone = null) {
|
||||
//Backwards compatible params order
|
||||
$time = self::fromString($format, $timezone);
|
||||
$_time = is_numeric($time) ? false : self::fromString($date, $timezone);
|
||||
|
@ -955,12 +963,12 @@ class CakeTime {
|
|||
*
|
||||
* @param integer|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object
|
||||
* @param string $format strftime format string.
|
||||
* @param boolean $invalid flag to ignore results of fromString == false
|
||||
* @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
|
||||
*/
|
||||
public static function i18nFormat($date, $format = null, $invalid = false, $timezone = null) {
|
||||
public static function i18nFormat($date, $format = null, $default = false, $timezone = null) {
|
||||
$date = self::fromString($date, $timezone);
|
||||
if ($date === false && $invalid !== false) {
|
||||
return $invalid;
|
||||
|
|
Loading…
Reference in a new issue