Skip to content
Snippets Groups Projects
Commit bb92edbb authored by Felix Kopp's avatar Felix Kopp Committed by Anja Leichsenring
Browse files

[!!!][TASK] Set f:format.date format to system default

TYPO3 configuration knows a global date format configuration
within the installation tool. See TYPO3_CONF_VARS/SYS/ddmmyy.

Use this global format as the default for all fluid based date
format outputs if not overwritten in place.

Change-Id: I508d7f61f63760aa1301f52663c432feeb539bf4
Resolves: #55790
Releases: 6.2
Reviewed-on: https://review.typo3.org/27456
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Marcin Sągol
Tested-by: Marcin Sągol
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
parent cf94a271
Branches
Tags
No related merge requests found
...@@ -194,6 +194,12 @@ Example: ...@@ -194,6 +194,12 @@ Example:
and not and not
<img src="fileadmin/xxxx.jpg" alt="Alt-Attribute" title="Alt-Attribute" /> <img src="fileadmin/xxxx.jpg" alt="Alt-Attribute" title="Alt-Attribute" />
* Date view helper uses configured default format
The fluid date view helper now uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']
as fallback format instead of hardcoded Y-m-d if no explicit format is given as
argument. This may change the output of dates from Y-m-d to d-m-y.
### System categories ### System categories
* Activated by default * Activated by default
......
...@@ -90,7 +90,11 @@ class DateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper ...@@ -90,7 +90,11 @@ class DateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
* @api * @api
*/ */
public function render($date = NULL, $format = 'Y-m-d') { public function render($date = NULL, $format = '') {
if ($format === '') {
$format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d';
}
if ($date === NULL) { if ($date === NULL) {
$date = $this->renderChildren(); $date = $this->renderChildren();
if ($date === NULL) { if ($date === NULL) {
......
...@@ -33,6 +33,7 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { ...@@ -33,6 +33,7 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
'LC_TIME' => setlocale(LC_TIME, 0), 'LC_TIME' => setlocale(LC_TIME, 0),
); );
$this->timezone = @date_default_timezone_get(); $this->timezone = @date_default_timezone_get();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'Y-m-d';
} }
public function tearDown() { public function tearDown() {
...@@ -79,6 +80,26 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { ...@@ -79,6 +80,26 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
$this->assertEquals('', $actualResult); $this->assertEquals('', $actualResult);
} }
/**
* @test
*/
public function viewHelperUsesDefaultIfNoSystemFormatIsAvailable() {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = '';
$viewHelper = new \TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper();
$actualResult = $viewHelper->render('@1391876733');
$this->assertEquals('2014-02-08', $actualResult);
}
/**
* @test
*/
public function viewHelperUsesSystemFormat() {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] = 'l, j. M y';
$viewHelper = new \TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper();
$actualResult = $viewHelper->render('@1391876733');
$this->assertEquals('Saturday, 8. Feb 14', $actualResult);
}
/** /**
* @test * @test
* @expectedException \TYPO3\CMS\Fluid\Core\ViewHelper\Exception * @expectedException \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment