mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
fixed previous merge and added some unit tests
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
* 1.4.0-RC2
|
||||
|
||||
* added negative timestamp support to the date filter
|
||||
|
||||
* 1.4.0-RC1 (2011-11-20)
|
||||
|
||||
* optimized variable access when using PHP 5.4
|
||||
|
||||
@@ -237,11 +237,8 @@ function twig_cycle($values, $i)
|
||||
function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = null)
|
||||
{
|
||||
if (!$date instanceof DateTime && !$date instanceof DateInterval) {
|
||||
if (ctype_digit((string) $date)
|
||||
|| (!empty($date)
|
||||
&& ('-' === $date[0])
|
||||
&& ctype_digit(substr($date, 1)))
|
||||
) {
|
||||
$asString = (string) $date;
|
||||
if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
|
||||
$date = new DateTime('@'.$date);
|
||||
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
} else {
|
||||
|
||||
@@ -9,9 +9,17 @@
|
||||
{{ date3|date('d/m/Y') }}
|
||||
{{ date4|date }}
|
||||
{{ date4|date('d/m/Y') }}
|
||||
{{ date5|date }}
|
||||
{{ date5|date('d/m/Y') }}
|
||||
--DATA--
|
||||
date_default_timezone_set('UTC');
|
||||
return array('date1' => mktime(13, 45, 0, 10, 4, 2010), 'date2' => new DateTime('2010-10-04 13:45'), 'date3' => '2010-10-04 13:45', 'date4' => 1286199900)
|
||||
return array(
|
||||
'date1' => mktime(13, 45, 0, 10, 4, 2010),
|
||||
'date2' => new DateTime('2010-10-04 13:45'),
|
||||
'date3' => '2010-10-04 13:45',
|
||||
'date4' => 1286199900,
|
||||
'date5' => -86410,
|
||||
)
|
||||
--EXPECT--
|
||||
October 4, 2010 13:45
|
||||
04/10/2010
|
||||
@@ -21,3 +29,5 @@ October 4, 2010 13:45
|
||||
04/10/2010
|
||||
October 4, 2010 13:45
|
||||
04/10/2010
|
||||
December 30, 1969 23:59
|
||||
30/12/1969
|
||||
|
||||
Reference in New Issue
Block a user