{"action":"created","issue":{"url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/27","repository_url":"https://api.github.com/repos/MetaModels/attribute_timestamp","labels_url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/27/comments","events_url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/27/events","html_url":"https://github.com/MetaModels/attribute_timestamp/issues/27","id":213114482,"number":27,"title":"Enhance data input to clear certain parts of the timestamp.","user":{"login":"discordier","id":940331,"avatar_url":"https://avatars1.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"labels":[{"id":30875736,"url":"https://api.github.com/repos/MetaModels/attribute_timestamp/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":113304892,"url":"https://api.github.com/repos/MetaModels/attribute_timestamp/labels/Up%20for%20discussion","name":"Up for discussion","color":"009800","default":false}],"state":"open","locked":false,"assignee":{"login":"discordier","id":940331,"avatar_url":"https://avatars1.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"assignees":[{"login":"discordier","id":940331,"avatar_url":"https://avatars1.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},{"login":"stefanheimes","id":988286,"avatar_url":"https://avatars3.githubusercontent.com/u/988286?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanheimes","html_url":"https://github.com/stefanheimes","followers_url":"https://api.github.com/users/stefanheimes/followers","following_url":"https://api.github.com/users/stefanheimes/following{/other_user}","gists_url":"https://api.github.com/users/stefanheimes/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanheimes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanheimes/subscriptions","organizations_url":"https://api.github.com/users/stefanheimes/orgs","repos_url":"https://api.github.com/users/stefanheimes/repos","events_url":"https://api.github.com/users/stefanheimes/events{/privacy}","received_events_url":"https://api.github.com/users/stefanheimes/received_events","type":"User","site_admin":false},{"login":"zonky2","id":1045318,"avatar_url":"https://avatars1.githubusercontent.com/u/1045318?v=3","gravatar_id":"","url":"https://api.github.com/users/zonky2","html_url":"https://github.com/zonky2","followers_url":"https://api.github.com/users/zonky2/followers","following_url":"https://api.github.com/users/zonky2/following{/other_user}","gists_url":"https://api.github.com/users/zonky2/gists{/gist_id}","starred_url":"https://api.github.com/users/zonky2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zonky2/subscriptions","organizations_url":"https://api.github.com/users/zonky2/orgs","repos_url":"https://api.github.com/users/zonky2/repos","events_url":"https://api.github.com/users/zonky2/events{/privacy}","received_events_url":"https://api.github.com/users/zonky2/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2017-03-09T17:48:31Z","updated_at":"2017-03-09T18:21:18Z","closed_at":null,"body":"## Issue description\r\n\r\nWhen editing timestamps with formats where parts are missing (Year, day, month, hour, minute, second), PHP does initialize it with the current `time()` value.\r\nThis is correct and good from PHP side, as formats like `+1 week` are perfectly legal and useful, yet it will break our filtering.\r\n\r\nSo we need some way to restrict time or date to \"zero\" in order to allow valid filtering and omit hickups like discussed in MetaModels/filter_fromto#9.\r\n\r\n## Proposed solution\r\nThe idea I had is to add some input screen configuration setting where the user can select one of three possible settings:\r\n1. do nothing (default and current behaviour)\r\n2. clear data part (will restrict the date to 01.01.1970 internally).\r\n3. clear time part (will restrict the time to 00:00:00 internally).\r\n \r\nI'd put this setting into the input screen definition of the attribute instance to allow variation of this in the concrete input screens.\r\n\r\nImplementation would then be to [change the current implementation](https://github.com/MetaModels/attribute_timestamp/blob/7b22eede3065c7cdb7a1e7529668e133d596bb33/src/MetaModels/Attribute/Timestamp/BackendSubscriber.php#L68) something along the lines of:\r\n```php\r\n    public function handleEncodePropertyValueFromWidget(EncodePropertyValueFromWidgetEvent $event)\r\n    {\r\n        $attribute = $this->getSupportedAttribute($event);\r\n        if (!$attribute) {\r\n            return;\r\n        }\r\n\r\n        $date       = \\DateTime::createFromFormat($attribute->getDateTimeFormatString(), $event->getValue());\r\n        $properties = $event->getEnvironment()->getDataDefinition()->getPropertiesDefinition();\r\n        $property   = $properties->getProperty($event->getProperty());\r\n        $extra      = $property->getExtra();\r\n        if (isset($extra['clear'])) {\r\n            switch ($extra['clear']) {\r\n                case 'time':\r\n                    $date->setTime(0, 0, 0);\r\n                    break;\r\n                case 'date':\r\n                    $date->setDate(0, 0, 0);\r\n                    break;\r\n                default:\r\n            }\r\n        }\r\n\r\n        if ($date) {\r\n            $event->setValue($date->getTimestamp());\r\n        }\r\n    }\r\n```\r\n\r\nOf course we would also have to add such setting to the fromto filter regarding dates, as otherwise date filtering would begin and end \"now\" and therefore might not find items due to the offset."},"comment":{"url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/comments/285435467","html_url":"https://github.com/MetaModels/attribute_timestamp/issues/27#issuecomment-285435467","issue_url":"https://api.github.com/repos/MetaModels/attribute_timestamp/issues/27","id":285435467,"user":{"login":"discordier","id":940331,"avatar_url":"https://avatars1.githubusercontent.com/u/940331?v=3","gravatar_id":"","url":"https://api.github.com/users/discordier","html_url":"https://github.com/discordier","followers_url":"https://api.github.com/users/discordier/followers","following_url":"https://api.github.com/users/discordier/following{/other_user}","gists_url":"https://api.github.com/users/discordier/gists{/gist_id}","starred_url":"https://api.github.com/users/discordier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discordier/subscriptions","organizations_url":"https://api.github.com/users/discordier/orgs","repos_url":"https://api.github.com/users/discordier/repos","events_url":"https://api.github.com/users/discordier/events{/privacy}","received_events_url":"https://api.github.com/users/discordier/received_events","type":"User","site_admin":false},"created_at":"2017-03-09T18:21:18Z","updated_at":"2017-03-09T18:21:18Z","body":"Addendum: We also should move the `timeformat` setting from the attribute to the input screen setting to allow different input formats per input screen (different formats for different user groups from different countries i.e.)."}}
{"actor":{"display_login":"discordier"}}