{"action":"created","issue":{"url":"https://api.github.com/repos/shaarli/Shaarli/issues/270","labels_url":"https://api.github.com/repos/shaarli/Shaarli/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/shaarli/Shaarli/issues/270/comments","events_url":"https://api.github.com/repos/shaarli/Shaarli/issues/270/events","html_url":"https://github.com/shaarli/Shaarli/issues/270","id":94402778,"number":270,"title":"Use DateTime to format dates and timestamps","user":{"login":"virtualtam","id":1615162,"avatar_url":"https://avatars.githubusercontent.com/u/1615162?v=3","gravatar_id":"","url":"https://api.github.com/users/virtualtam","html_url":"https://github.com/virtualtam","followers_url":"https://api.github.com/users/virtualtam/followers","following_url":"https://api.github.com/users/virtualtam/following{/other_user}","gists_url":"https://api.github.com/users/virtualtam/gists{/gist_id}","starred_url":"https://api.github.com/users/virtualtam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtualtam/subscriptions","organizations_url":"https://api.github.com/users/virtualtam/orgs","repos_url":"https://api.github.com/users/virtualtam/repos","events_url":"https://api.github.com/users/virtualtam/events{/privacy}","received_events_url":"https://api.github.com/users/virtualtam/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/shaarli/Shaarli/labels/cleanup","name":"cleanup","color":"aff5Af"},{"url":"https://api.github.com/repos/shaarli/Shaarli/labels/easy","name":"easy","color":"009800"},{"url":"https://api.github.com/repos/shaarli/Shaarli/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-10T22:05:34Z","updated_at":"2015-07-11T08:19:28Z","closed_at":null,"body":"It would be more robust and flexible to use the built-in [DateTime](http://php.net/manual/en/class.datetime.php) object, and pass is to RainTPL templates, than relying on tedious string processing in `index.php`:\r\n\r\n```php\r\n/*  Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a timestamp (Unix epoch)                \r\n    (used to build the ADD_DATE attribute in Netscape-bookmarks file)                                   \r\n    PS: I could have used strptime(), but it does not exist on Windows. I'm too kind. */\r\nfunction linkdate2timestamp($linkdate)\r\n{\r\n    if(strcmp($linkdate, '_000000') !== 0 || !$linkdate){\r\n        $Y=$M=$D=$h=$m=$s=0;\r\n        $r = sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);\r\n        return mktime($h,$m,$s,$M,$D,$Y);\r\n    }\r\n    return time();\r\n}\r\n\r\n/*  Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a RFC822 date.                          \r\n    (used to build the pubDate attribute in RSS feed.)  */\r\nfunction linkdate2rfc822($linkdate)\r\n{\r\n    return date('r',linkdate2timestamp($linkdate)); // 'r' is for RFC822 date format.\r\n}\r\n\r\n/*  Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a ISO 8601 date.                        \r\n    (used to build the updated tags in ATOM feed.)  */\r\nfunction linkdate2iso8601($linkdate)\r\n{\r\n    return date('c',linkdate2timestamp($linkdate)); // 'c' is for ISO 8601 date format.\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/shaarli/Shaarli/issues/comments/120595726","html_url":"https://github.com/shaarli/Shaarli/issues/270#issuecomment-120595726","issue_url":"https://api.github.com/repos/shaarli/Shaarli/issues/270","id":120595726,"user":{"login":"ArthurHoaro","id":1962678,"avatar_url":"https://avatars.githubusercontent.com/u/1962678?v=3","gravatar_id":"","url":"https://api.github.com/users/ArthurHoaro","html_url":"https://github.com/ArthurHoaro","followers_url":"https://api.github.com/users/ArthurHoaro/followers","following_url":"https://api.github.com/users/ArthurHoaro/following{/other_user}","gists_url":"https://api.github.com/users/ArthurHoaro/gists{/gist_id}","starred_url":"https://api.github.com/users/ArthurHoaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArthurHoaro/subscriptions","organizations_url":"https://api.github.com/users/ArthurHoaro/orgs","repos_url":"https://api.github.com/users/ArthurHoaro/repos","events_url":"https://api.github.com/users/ArthurHoaro/events{/privacy}","received_events_url":"https://api.github.com/users/ArthurHoaro/received_events","type":"User","site_admin":false},"created_at":"2015-07-11T08:19:28Z","updated_at":"2015-07-11T08:19:28Z","body":"I've no idea how to call an object method from a RainTPL template. I'm not sure that's possible."}}