Skip to content

Commit

Permalink
[BUGFIX] fixed error cause by wrong argument in Format/Date view helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dwenzel committed Oct 21, 2015
1 parent 5a28bb4 commit 6419489
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Classes/ViewHelpers/Format/DateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* The TYPO3 project - inspiring people to share! *
* */
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;

/**
* Formats a \DateTime object. This is an extended version which allows to
Expand Down Expand Up @@ -69,7 +70,7 @@
*
* @api
*/
class DateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
class DateViewHelper extends AbstractViewHelper {

/**
* @var boolean
Expand All @@ -83,6 +84,7 @@ class DateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
* @param mixed $date either a DateTime object or a string that is accepted by DateTime constructor
* @param string $format Format String which is taken to format the Date/Time
* @param int $time an integer representing a time value
* @param mixed $base A base time (a DateTime object or a string) used if $date is a relative date specification. Defaults to current time.
* @return string Formatted date
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
*/
Expand All @@ -96,13 +98,10 @@ public function render($date = NULL, $format = '', $time = NULL, $base = NULL) {
}

if ($date === NULL) {
$modifiedDate = $this->renderChildren();
if ($modifiedDate === NULL) {
$date = $this->renderChildren();
if ($date === NULL) {
return '';
}
} else {
// we have to clone it - otherwise we would change the date!
$modifiedDate = clone($date);
}

if ($date === '') {
Expand All @@ -118,7 +117,10 @@ public function render($date = NULL, $format = '', $time = NULL, $base = NULL) {
} catch (\Exception $exception) {
throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('"' . $date . '" could not be parsed by \DateTime constructor.', 1241722579);
}
} else {
$modifiedDate = clone($date);
}

if ($time !== NULL) {
$modifiedDate->setTimestamp($modifiedDate->getTimestamp() + $time);
}
Expand Down

0 comments on commit 6419489

Please sign in to comment.