diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 3200d3b98..3a914adc5 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -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;