projects
/
konrad/twig.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
027f489
)
Allow setting of timezone on twig_date_format_filter method
author
Josh Turmel
<jturmel@gmail.com>
Wed, 22 Jun 2011 03:14:00 +0000 (20:14 -0700)
committer
Josh Turmel
<jturmel@gmail.com>
Wed, 22 Jun 2011 03:14:00 +0000 (20:14 -0700)
lib/Twig/Extension/Core.php
patch
|
blob
|
history
diff --git
a/lib/Twig/Extension/Core.php
b/lib/Twig/Extension/Core.php
index
d627360
..
c5b2e1b
100644
(file)
--- a/
lib/Twig/Extension/Core.php
+++ b/
lib/Twig/Extension/Core.php
@@
-201,7
+201,7
@@
class Twig_Extension_Core extends Twig_Extension
}
}
-function twig_date_format_filter($date, $format = 'F j, Y H:i')
+function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL)
{
if (!$date instanceof DateTime) {
if (ctype_digit((string) $date)) {
@@
-212,6
+212,14
@@
function twig_date_format_filter($date, $format = 'F j, Y H:i')
}
}
+ if ($timezone !== NULL) {
+ if (!$timezone instanceof DateTimeZone) {
+ $timezone = new DateTimeZone($timezone);
+ }
+
+ $date->setTimezone($timezone);
+ }
+
return $date->format($format);
}