{"action":"closed","issue":{"url":"https://api.github.com/repos/getgrav/grav/issues/748","repository_url":"https://api.github.com/repos/getgrav/grav","labels_url":"https://api.github.com/repos/getgrav/grav/issues/748/labels{/name}","comments_url":"https://api.github.com/repos/getgrav/grav/issues/748/comments","events_url":"https://api.github.com/repos/getgrav/grav/issues/748/events","html_url":"https://github.com/getgrav/grav/issues/748","id":143199834,"number":748,"title":"The Twig `date` filter stopped working correctly after changing to own filter","user":{"login":"maxlysenko","id":12494082,"avatar_url":"https://avatars.githubusercontent.com/u/12494082?v=3","gravatar_id":"","url":"https://api.github.com/users/maxlysenko","html_url":"https://github.com/maxlysenko","followers_url":"https://api.github.com/users/maxlysenko/followers","following_url":"https://api.github.com/users/maxlysenko/following{/other_user}","gists_url":"https://api.github.com/users/maxlysenko/gists{/gist_id}","starred_url":"https://api.github.com/users/maxlysenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxlysenko/subscriptions","organizations_url":"https://api.github.com/users/maxlysenko/orgs","repos_url":"https://api.github.com/users/maxlysenko/repos","events_url":"https://api.github.com/users/maxlysenko/events{/privacy}","received_events_url":"https://api.github.com/users/maxlysenko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/getgrav/grav/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"flaviocopes","id":11783388,"avatar_url":"https://avatars.githubusercontent.com/u/11783388?v=3","gravatar_id":"","url":"https://api.github.com/users/flaviocopes","html_url":"https://github.com/flaviocopes","followers_url":"https://api.github.com/users/flaviocopes/followers","following_url":"https://api.github.com/users/flaviocopes/following{/other_user}","gists_url":"https://api.github.com/users/flaviocopes/gists{/gist_id}","starred_url":"https://api.github.com/users/flaviocopes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flaviocopes/subscriptions","organizations_url":"https://api.github.com/users/flaviocopes/orgs","repos_url":"https://api.github.com/users/flaviocopes/repos","events_url":"https://api.github.com/users/flaviocopes/events{/privacy}","received_events_url":"https://api.github.com/users/flaviocopes/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2016-03-24T09:43:36Z","updated_at":"2016-03-26T21:02:27Z","closed_at":"2016-03-26T21:02:27Z","body":"Hello\r\nAs the title says the `date` filter not working correctly.\r\nAll of the following variants do not work:\r\n```twig\r\n{{ 'now'|date('F jS \\\\a\\\\t H:i') }}\r\n{{ 'now'|date('F jS, Y') }}\r\n{{ 'now'|date(config.system.pages.dateformat.short) }}\r\n{{ 'now'|date(config.system.pages.dateformat.long) }}\r\n```\r\nbut they work with the standard Twig `date` filter.\r\n\r\nAlso, maybe you'll consider changing own filter name to something different (maybe `tdate` if it's related to translation) from the predefined standard Twig filter name to avoid confusion.\r\nI guess when someone uses standard Twig filter, the results are expected as they described in Twig documentation.\r\n\r\nBesides, Twig has some [extensions](http://twig.sensiolabs.org/doc/extensions/index.html) ([`Intl`](http://twig.sensiolabs.org/doc/extensions/intl.html) and [`Date`](http://twig.sensiolabs.org/doc/extensions/date.html) in particular) which are working fine. For example:\r\n```twig\r\n{{ page.date|localizeddate('long', 'short', grav.language.getLanguage) }}\r\n{{ '01.01.2017'|time_diff }}\r\n```\r\nI personally use these extensions as a plugin:\r\n```php\r\n<?php\r\nnamespace Grav\\Plugin;\r\n\r\nuse Grav\\Common\\Plugin;\r\nuse Symfony\\Component\\Translation\\Translator;\r\nuse Symfony\\Component\\Translation\\Loader\\YamlFileLoader;\r\n\r\nclass TwigExtensionsPlugin extends Plugin\r\n{\r\n    /**\r\n     * @return array\r\n     */\r\n    public static function getSubscribedEvents()\r\n    {\r\n        return [\r\n            'onPluginsInitialized' => ['onPluginsInitialized', 0],\r\n        ];\r\n    }\r\n\r\n    /**\r\n     * Initialize configuration\r\n     */\r\n    public function onPluginsInitialized()\r\n    {\r\n        if ($this->isAdmin()) {\r\n            $this->active = false;\r\n            return;\r\n        }\r\n\r\n        $autoload = __DIR__ . '/vendor/autoload.php';\r\n\r\n        if (file_exists($autoload)) {\r\n            require_once $autoload;\r\n\r\n            $this->enable([\r\n                'onTwigExtensions' => ['onTwigExtensions', 0]\r\n            ]);\r\n        }\r\n    }\r\n\r\n    public function onTwigExtensions()\r\n    {\r\n        $extensions = (array) $this->config->get('plugins.twigextensions.extensions');\r\n\r\n        if (in_array('date', array_map('strtolower', $extensions))) {\r\n            $language = $this->grav['language']->getLanguage();\r\n\r\n            $translation = __DIR__ . '/translations/date.' . $language . '.yaml';\r\n\r\n            if (file_exists($translation)) {\r\n                $translator = new Translator($language);\r\n                $translator->addLoader('yaml', new YamlFileLoader());\r\n                $translator->addResource('yaml', $translation, $language, 'date');\r\n            }\r\n        }\r\n\r\n        foreach($extensions as $extension) {\r\n            $extension_class = '\\Twig_Extensions_Extension_' . ucfirst($extension);\r\n            if (class_exists($extension_class)) {\r\n                if (stripos($extension, 'date') !== false && isset($translator)) {\r\n                    $this->grav['twig']->twig->addExtension(new $extension_class($translator));\r\n                } else {\r\n                    $this->grav['twig']->twig->addExtension(new $extension_class());\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```"}}