Skip to content

Commit

Permalink
OXDEV-7753 Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
kenariosz committed Jul 4, 2024
1 parent 4b27fdc commit 2838672
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## v3.0.0 - unreleased

### Changed
- `DateFormatExtension::dateFormat` method has changed.

### Removed
- `SmartyCycleExtension` was removed
- Short template names (without file extensions `".html.twig"`) are not longer supported.
4 changes: 2 additions & 2 deletions src/Extensions/Filters/DateFormatExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getFilters()
*
* @return string|null
*/
public function dateFormat($string, $format = '%b %e, %Y', $defaultDate = '')
public function dateFormat($string, $format = 'M j, Y', $defaultDate = ''): ?string
{
if ($string != '') {
$timestamp = $this->getTimestamp($string);
Expand All @@ -48,7 +48,7 @@ public function dateFormat($string, $format = '%b %e, %Y', $defaultDate = '')
$format = $this->dateFormatHelper->fixWindowsTimeFormat($format, $timestamp);
}

return strftime($format, $timestamp);
return date($format, $timestamp);
}

/**
Expand Down
14 changes: 6 additions & 8 deletions tests/Unit/Extensions/Filters/DateFormatExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ public static function provider(): array
['foo', '', '', null],
['', 'foo', '', null],
['', '', 'foo', false],
['foo', 'foo', '', 'foo'],
['foo', 'foo', 'foo', 'foo'],

//provided input string
[20_181_201_101_525, '%Y-%m-%d %H:%M:%S', '', '2018-12-01 10:15:25'], //mysql format
[1_543_850_519, '%Y-%m-%d %H:%M:%S', '', '2018-12-03 16:21:59'], //time()
['Dec 03 15:21:59 2018', '%Y-%m-%d %H:%M:%S', '', '2018-12-03 15:21:59'], //string time
[20_181_201_101_525, 'Y-m-d H:i:s', '', '2018-12-01 10:15:25'], //mysql format
[1_543_850_519, 'Y-m-d H:i:s', '', '2018-12-03 16:21:59'], //time()
['Dec 03 15:21:59 2018', 'Y-m-d H:i:s', '', '2018-12-03 15:21:59'], //string time

//no input string provided, default date used
['', '%Y-%m-%d %H:%M:%S', 20_181_201_101_525, '2018-12-01 10:15:25'], //mysql format
['', '%Y-%m-%d %H:%M:%S', 1_543_850_519, '2018-12-03 16:21:59'], //time()
['', '%Y-%m-%d %H:%M:%S', 'Dec 03 15:21:59 2018', '2018-12-03 15:21:59'], //string time
['', 'Y-m-d H:i:s', 20_181_201_101_525, '2018-12-01 10:15:25'], //mysql format
['', 'Y-m-d H:i:s', 1_543_850_519, '2018-12-03 16:21:59'], //time()
['', 'Y-m-d H:i:s', 'Dec 03 15:21:59 2018', '2018-12-03 15:21:59'], //string time
];
}

Expand Down

0 comments on commit 2838672

Please sign in to comment.