Skip to content

Commit

Permalink
Fix localdate/localtime/localdatetime with timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jasny committed Dec 9, 2015
1 parent 37e97d0 commit 17df9aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Jasny/Twig/DateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function localDate($date, $format=null, $calendar='gregorian')
if (!isset($date)) return null;

if ($date instanceof \DateTime);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $time);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $date);
else $date = new \DateTime((string)$date);

$calendar = $calendar == 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN;
Expand All @@ -114,7 +114,7 @@ public function localTime($date, $format='short', $calendar='gregorian')
if (!isset($date)) return null;

if ($date instanceof \DateTime);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $time);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $date);
else $date = new \DateTime((string)$date);

$calendar = $calendar == 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN;
Expand All @@ -137,7 +137,7 @@ public function localDateTime($date, $format=null, $calendar='gregorian')
if (!isset($date)) return null;

if ($date instanceof \DateTime);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $time);
elseif (is_int($date)) $date = \DateTime::createFromFormat('U', $date);
else $date = new \DateTime((string)$date);

$calendar = $calendar == 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN;
Expand Down

0 comments on commit 17df9aa

Please sign in to comment.