Skip to content

Commit

Permalink
Hide strftime deprecation warning
Browse files Browse the repository at this point in the history
Since CakePHP 2 doesn't require the installation of `intl` PHP extension in it's documentation, I can't use the alternative `IntlDateFormatter::format` because it relies such extension.

ref: ARCH-13
  • Loading branch information
diegosurita committed Jan 19, 2024
1 parent 4b62d7f commit ddecd9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/dist
/tags
*.mo
.phpunit.result.cache

# IDE and editor specific files #
#################################
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function testTimeAgoInWordsWithFormat() {
$this->assertEquals('on 2007-09-25', $result);

$result = $this->Time->timeAgoInWords('2007-9-25', '%x');
$this->assertEquals('on ' . strftime('%x', strtotime('2007-9-25')), $result);
$this->assertEquals('on ' . @strftime('%x', strtotime('2007-9-25')), $result);

$result = $this->Time->timeAgoInWords(
strtotime('+2 weeks +2 days'),
Expand All @@ -303,7 +303,7 @@ public function testTimeAgoInWordsWithFormat() {
strtotime('+2 months +2 days'),
array('end' => '1 month', 'format' => '%x')
);
$this->assertEquals('on ' . strftime('%x', strtotime('+2 months +2 days')), $result);
$this->assertEquals('on ' . @strftime('%x', strtotime('+2 months +2 days')), $result);
}

/**
Expand Down Expand Up @@ -1174,7 +1174,7 @@ public function testI18nFormat() {
$this->assertEquals($expected, $result);

$result = $this->Time->i18nFormat($time, '%c');
$expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
$expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
$this->assertEquals($expected, $result);

$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
Expand All @@ -1188,7 +1188,7 @@ public function testI18nFormat() {
$this->assertEquals($expected, $result);

$result = $this->Time->i18nFormat($time, '%c');
$expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
$expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
$this->assertEquals($expected, $result);

$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/CakeTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ public static function listTimezones($filter = null, $country = null, $options =
* @return string formatted string with correct encoding.
*/
protected static function _strftime($format, $timestamp) {
$format = strftime($format, $timestamp);
$format = @strftime($format, $timestamp);
$encoding = Configure::read('App.encoding');
if (!empty($encoding) && $encoding === 'UTF-8') {
if (function_exists('mb_check_encoding')) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2767,7 +2767,7 @@ protected function _getDateTimeValue($value, $timeFormat) {
}

if (is_numeric($value)) {
$value = strftime('%Y-%m-%d %H:%M:%S', $value);
$value = @strftime('%Y-%m-%d %H:%M:%S', $value);
}
$meridian = 'am';
$pos = strpos($value, '-');
Expand Down Expand Up @@ -3021,7 +3021,7 @@ protected function _generateOptions($name, $options = array()) {
$data = $options['monthNames'];
} else {
for ($m = 1; $m <= 12; $m++) {
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
$data[sprintf("%02s", $m)] = @strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
}
}
break;
Expand Down

0 comments on commit ddecd9a

Please sign in to comment.