{"action":"created","issue":{"url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/181","labels_url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/181/comments","events_url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/181/events","html_url":"https://github.com/lexik/LexikFormFilterBundle/pull/181","id":110916286,"number":181,"title":"Handle timezones in a correct way.","user":{"login":"phjedi","id":14072809,"avatar_url":"https://avatars.githubusercontent.com/u/14072809?v=3","gravatar_id":"","url":"https://api.github.com/users/phjedi","html_url":"https://github.com/phjedi","followers_url":"https://api.github.com/users/phjedi/followers","following_url":"https://api.github.com/users/phjedi/following{/other_user}","gists_url":"https://api.github.com/users/phjedi/gists{/gist_id}","starred_url":"https://api.github.com/users/phjedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phjedi/subscriptions","organizations_url":"https://api.github.com/users/phjedi/orgs","repos_url":"https://api.github.com/users/phjedi/repos","events_url":"https://api.github.com/users/phjedi/events{/privacy}","received_events_url":"https://api.github.com/users/phjedi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-12T06:47:23Z","updated_at":"2015-10-16T10:54:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/pulls/181","html_url":"https://github.com/lexik/LexikFormFilterBundle/pull/181","diff_url":"https://github.com/lexik/LexikFormFilterBundle/pull/181.diff","patch_url":"https://github.com/lexik/LexikFormFilterBundle/pull/181.patch"},"body":"Hi guys.\r\nIt looks like you omitted Symfony2 form options like 'model_timezone' and 'view_timezone' using the next chunk of code:\r\n\r\n```php\r\n    protected function convertToSqlDate($date, $isMax = false)\r\n    {\r\n        if (! $date instanceof \\DateTime) {\r\n            return;\r\n        }\r\n\r\n        if ($isMax) {\r\n            $date->setTime(23, 59, 59);\r\n        } else {\r\n            $date->setTime(0, 0, 0);\r\n        }\r\n\r\n        return $this->expr()->literal($date->format(self::SQL_DATE_TIME));\r\n    }\r\n```\r\n\r\nWe kindly ask you to replace it with something like this one:\r\n\r\n```php\r\n    protected function convertToSqlDate($date, $isMax = false)\r\n    {\r\n        if (! $date instanceof \\DateTime) {\r\n            return;\r\n        }\r\n\r\n        if ($isMax) {\r\n            $date->modify('+1 day -1 second');\r\n        }\r\n\r\n        return $this->expr()->literal($date->format(self::SQL_DATE_TIME));\r\n    }\r\n```\r\n\r\nIt should handle timezones in a correct way.\r\n"},"comment":{"url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/comments/148682243","html_url":"https://github.com/lexik/LexikFormFilterBundle/pull/181#issuecomment-148682243","issue_url":"https://api.github.com/repos/lexik/LexikFormFilterBundle/issues/181","id":148682243,"user":{"login":"phjedi","id":14072809,"avatar_url":"https://avatars.githubusercontent.com/u/14072809?v=3","gravatar_id":"","url":"https://api.github.com/users/phjedi","html_url":"https://github.com/phjedi","followers_url":"https://api.github.com/users/phjedi/followers","following_url":"https://api.github.com/users/phjedi/following{/other_user}","gists_url":"https://api.github.com/users/phjedi/gists{/gist_id}","starred_url":"https://api.github.com/users/phjedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phjedi/subscriptions","organizations_url":"https://api.github.com/users/phjedi/orgs","repos_url":"https://api.github.com/users/phjedi/repos","events_url":"https://api.github.com/users/phjedi/events{/privacy}","received_events_url":"https://api.github.com/users/phjedi/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T10:54:31Z","updated_at":"2015-10-16T10:54:31Z","body":"It's not needed. \r\n\r\nFor example, we have form with date range and different timezones in view and data.\r\n\r\n```php\r\n        $builder->add('date_range', 'filter_date_range', [\r\n            'left_date_options' => [\r\n                'model_timezone'    => 'UTC',\r\n                'view_timezone'     => 'Asia/Karachi',\r\n            ],\r\n            'right_date_options' => [\r\n                'model_timezone'    => 'UTC',\r\n                'view_timezone'     => 'Asia/Karachi',\r\n            ],\r\n        ]);\r\n```\r\n\r\nUser input: `2015-10-01` and `2015-10-16` (timezone Asia/Karachi)\r\nAfter submit we have: `2015-09-30 19:00` and `2015-10-15 19:00` (timezone UTC)\r\n\r\nAnd after filter: `2015-09-30 00:00:00` and `2015-10-15 23:59:59` - **this is wrong**\r\n\r\nTrue way: do not change `left_date` and add 1 day to `right_way` to include this date in query."}}