{"action":"opened","issue":{"url":"https://api.github.com/repos/dbushell/Pikaday/issues/461","labels_url":"https://api.github.com/repos/dbushell/Pikaday/issues/461/labels{/name}","comments_url":"https://api.github.com/repos/dbushell/Pikaday/issues/461/comments","events_url":"https://api.github.com/repos/dbushell/Pikaday/issues/461/events","html_url":"https://github.com/dbushell/Pikaday/issues/461","id":121909403,"number":461,"title":"a simple method to format date, maybe useful.","user":{"login":"acrazing","id":10029810,"avatar_url":"https://avatars.githubusercontent.com/u/10029810?v=3","gravatar_id":"","url":"https://api.github.com/users/acrazing","html_url":"https://github.com/acrazing","followers_url":"https://api.github.com/users/acrazing/followers","following_url":"https://api.github.com/users/acrazing/following{/other_user}","gists_url":"https://api.github.com/users/acrazing/gists{/gist_id}","starred_url":"https://api.github.com/users/acrazing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acrazing/subscriptions","organizations_url":"https://api.github.com/users/acrazing/orgs","repos_url":"https://api.github.com/users/acrazing/repos","events_url":"https://api.github.com/users/acrazing/events{/privacy}","received_events_url":"https://api.github.com/users/acrazing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-13T09:24:39Z","updated_at":"2015-12-13T09:24:39Z","closed_at":null,"body":"```js\r\nfunction toString (format) {\r\n    if (!isDate(this._d)) {\r\n        return '';\r\n    }\r\n    var sy = this._d.getYear(),\r\n        y = this._d.getFullYear(),\r\n        m = this._d.getMonth() + 1,\r\n        d = this._d.getDate(),\r\n        f = function (t) {\r\n            return t < 10 ? '0' + t : t;\r\n        },\r\n        syy = f(sy),\r\n        mm = f(m),\r\n        dd = f(d),\r\n        i = 0,\r\n        c = '',\r\n        o = '';\r\n    return (format || this._o.format).replace(/[A-Z]+/g, function (s) {\r\n        o = '';\r\n        for (i = 0; i < s.length; i++) {\r\n            c = s[i];\r\n            if (s[i + 1] === c) {\r\n                i += 1;\r\n                c += s[i];\r\n            }\r\n            switch (c) {\r\n                case 'Y':\r\n                    o += syy;\r\n                    break;\r\n                case 'YY':\r\n                    o += y;\r\n                    break;\r\n                case 'M':\r\n                    o += m;\r\n                    break;\r\n                case 'MM':\r\n                    o += mm;\r\n                    break;\r\n                case 'D':\r\n                    o += d;\r\n                    break;\r\n                case 'DD':\r\n                    o += dd;\r\n                    break;\r\n                default:\r\n                    o += c;\r\n                    break;\r\n            }\r\n        }\r\n        return o;\r\n    });\r\n}\r\n```\r\n"}}