{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/86685042","pull_request_review_id":7331759,"id":86685042,"diff_hunk":"@@ -1,50 +1,270 @@\n 'use strict';\n \n-/**\n- * Сделано задание на звездочку\n- * Реализовано оба метода и tryLater\n- */\n exports.isStar = true;\n+var DAYS = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];\n \n-/**\n- * @param {Object} schedule – Расписание Банды\n- * @param {Number} duration - Время на ограбление в минутах\n- * @param {Object} workingHours – Время работы банка\n- * @param {String} workingHours.from – Время открытия, например, \"10:00+5\"\n- * @param {String} workingHours.to – Время закрытия, например, \"18:00+5\"\n- * @returns {Object}\n- */\n exports.getAppropriateMoment = function (schedule, duration, workingHours) {\n     console.info(schedule, duration, workingHours);\n+    var timeForWork = findTime(schedule, workingHours, duration);\n+\n+    var goodTime = normalizeMinAndHour(getTime(duration * 60000, timeForWork));\n \n     return {\n \n-        /**\n-         * Найдено ли время\n-         * @returns {Boolean}\n-         */\n         exists: function () {\n-            return false;\n+\n+            return typeof (goodTime) === 'object';\n         },\n \n-        /**\n-         * Возвращает отформатированную строку с часами для ограбления\n-         * Например,\n-         *   \"Начинаем в %HH:%MM (%DD)\" -> \"Начинаем в 14:59 (СР)\"\n-         * @param {String} template\n-         * @returns {String}\n-         */\n         format: function (template) {\n+            if (!this.exists()) {\n+\n+                return '';\n+            }\n+            if (typeof(goodTime) !== 'object' || duration === 0 || !template) {\n+\n+                return '';\n+            }\n+            template = template.replace(/(%DD)/g, goodTime[1]);\n+            template = template.replace(/(%HH)/g, goodTime[2]);\n+            template = template.replace(/(%MM)/g, goodTime[3]);\n+\n             return template;\n         },\n \n-        /**\n-         * Попробовать найти часы для ограбления позже [*]\n-         * @star\n-         * @returns {Boolean}\n-         */\n         tryLater: function () {\n+            var oldGoodTime = goodTime;\n+            if (!this.exists()) {\n+\n+                return false;\n+            }\n+            if ((goodTime = getTimeLater(duration * 60000, timeForWork, goodTime))) {\n+\n+                return true;\n+            }\n+            goodTime = oldGoodTime;\n+\n             return false;\n         }\n     };\n };\n+\n+function findTime(schedule, workingHours) {\n+    var workSchedule = addBankTime(workingHours);\n+\n+    return addSheduleTime(schedule, workingHours, workSchedule);\n+}\n+\n+function addBankTime(workingHours) {\n+    var open = workingHours.from.split(':');\n+    var close = workingHours.to.split(':');\n+    var dateArray = [];\n+    for (var i = 0; i < 3; i++) {\n+        var intHour = parseInt(close[0]);","path":"robbery.js","position":92,"original_position":92,"commit_id":"9969c8f445d14dd0e8f978a09576ac333d18a1df","original_commit_id":"9969c8f445d14dd0e8f978a09576ac333d18a1df","user":{"login":"Zeace","id":22629906,"avatar_url":"https://avatars.githubusercontent.com/u/22629906?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeace","html_url":"https://github.com/Zeace","followers_url":"https://api.github.com/users/Zeace/followers","following_url":"https://api.github.com/users/Zeace/following{/other_user}","gists_url":"https://api.github.com/users/Zeace/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeace/subscriptions","organizations_url":"https://api.github.com/users/Zeace/orgs","repos_url":"https://api.github.com/users/Zeace/repos","events_url":"https://api.github.com/users/Zeace/events{/privacy}","received_events_url":"https://api.github.com/users/Zeace/received_events","type":"User","site_admin":false},"body":"сделал\r\n","created_at":"2016-11-06T12:18:06Z","updated_at":"2016-11-06T12:18:06Z","html_url":"https://github.com/urfu-2016/javascript-task-3/pull/19#discussion_r86685042","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/86685042"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/19#discussion_r86685042"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19","id":90512403,"html_url":"https://github.com/urfu-2016/javascript-task-3/pull/19","diff_url":"https://github.com/urfu-2016/javascript-task-3/pull/19.diff","patch_url":"https://github.com/urfu-2016/javascript-task-3/pull/19.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/19","number":19,"state":"open","locked":false,"title":"Заморский Глеб","user":{"login":"Zeace","id":22629906,"avatar_url":"https://avatars.githubusercontent.com/u/22629906?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeace","html_url":"https://github.com/Zeace","followers_url":"https://api.github.com/users/Zeace/followers","following_url":"https://api.github.com/users/Zeace/following{/other_user}","gists_url":"https://api.github.com/users/Zeace/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeace/subscriptions","organizations_url":"https://api.github.com/users/Zeace/orgs","repos_url":"https://api.github.com/users/Zeace/repos","events_url":"https://api.github.com/users/Zeace/events{/privacy}","received_events_url":"https://api.github.com/users/Zeace/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-23T11:27:53Z","updated_at":"2016-11-06T12:18:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10d38066d097c51dbd5933e74b8f379b3f86071c","assignee":{"login":"Lakate","id":8994274,"avatar_url":"https://avatars.githubusercontent.com/u/8994274?v=3","gravatar_id":"","url":"https://api.github.com/users/Lakate","html_url":"https://github.com/Lakate","followers_url":"https://api.github.com/users/Lakate/followers","following_url":"https://api.github.com/users/Lakate/following{/other_user}","gists_url":"https://api.github.com/users/Lakate/gists{/gist_id}","starred_url":"https://api.github.com/users/Lakate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lakate/subscriptions","organizations_url":"https://api.github.com/users/Lakate/orgs","repos_url":"https://api.github.com/users/Lakate/repos","events_url":"https://api.github.com/users/Lakate/events{/privacy}","received_events_url":"https://api.github.com/users/Lakate/received_events","type":"User","site_admin":false},"assignees":[{"login":"Lakate","id":8994274,"avatar_url":"https://avatars.githubusercontent.com/u/8994274?v=3","gravatar_id":"","url":"https://api.github.com/users/Lakate","html_url":"https://github.com/Lakate","followers_url":"https://api.github.com/users/Lakate/followers","following_url":"https://api.github.com/users/Lakate/following{/other_user}","gists_url":"https://api.github.com/users/Lakate/gists{/gist_id}","starred_url":"https://api.github.com/users/Lakate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lakate/subscriptions","organizations_url":"https://api.github.com/users/Lakate/orgs","repos_url":"https://api.github.com/users/Lakate/repos","events_url":"https://api.github.com/users/Lakate/events{/privacy}","received_events_url":"https://api.github.com/users/Lakate/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19/comments","review_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/19/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/9969c8f445d14dd0e8f978a09576ac333d18a1df","head":{"label":"Zeace:master","ref":"master","sha":"9969c8f445d14dd0e8f978a09576ac333d18a1df","user":{"login":"Zeace","id":22629906,"avatar_url":"https://avatars.githubusercontent.com/u/22629906?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeace","html_url":"https://github.com/Zeace","followers_url":"https://api.github.com/users/Zeace/followers","following_url":"https://api.github.com/users/Zeace/following{/other_user}","gists_url":"https://api.github.com/users/Zeace/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeace/subscriptions","organizations_url":"https://api.github.com/users/Zeace/orgs","repos_url":"https://api.github.com/users/Zeace/repos","events_url":"https://api.github.com/users/Zeace/events{/privacy}","received_events_url":"https://api.github.com/users/Zeace/received_events","type":"User","site_admin":false},"repo":{"id":71527049,"name":"javascript-task-3","full_name":"Zeace/javascript-task-3","owner":{"login":"Zeace","id":22629906,"avatar_url":"https://avatars.githubusercontent.com/u/22629906?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeace","html_url":"https://github.com/Zeace","followers_url":"https://api.github.com/users/Zeace/followers","following_url":"https://api.github.com/users/Zeace/following{/other_user}","gists_url":"https://api.github.com/users/Zeace/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeace/subscriptions","organizations_url":"https://api.github.com/users/Zeace/orgs","repos_url":"https://api.github.com/users/Zeace/repos","events_url":"https://api.github.com/users/Zeace/events{/privacy}","received_events_url":"https://api.github.com/users/Zeace/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zeace/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":true,"url":"https://api.github.com/repos/Zeace/javascript-task-3","forks_url":"https://api.github.com/repos/Zeace/javascript-task-3/forks","keys_url":"https://api.github.com/repos/Zeace/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zeace/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zeace/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/Zeace/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/Zeace/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/Zeace/javascript-task-3/events","assignees_url":"https://api.github.com/repos/Zeace/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/Zeace/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/Zeace/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/Zeace/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zeace/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zeace/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zeace/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zeace/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/Zeace/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/Zeace/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/Zeace/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/Zeace/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/Zeace/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/Zeace/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zeace/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zeace/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zeace/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zeace/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/Zeace/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zeace/javascript-task-3/merges","archive_url":"https://api.github.com/repos/Zeace/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zeace/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/Zeace/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/Zeace/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/Zeace/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/Zeace/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zeace/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/Zeace/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/Zeace/javascript-task-3/deployments","created_at":"2016-10-21T03:39:06Z","updated_at":"2016-10-21T03:39:07Z","pushed_at":"2016-11-04T10:09:24Z","git_url":"git://github.com/Zeace/javascript-task-3.git","ssh_url":"git@github.com:Zeace/javascript-task-3.git","clone_url":"https://github.com/Zeace/javascript-task-3.git","svn_url":"https://github.com/Zeace/javascript-task-3","homepage":"","size":28,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"urfu-2016:master","ref":"master","sha":"bbdd8da0f05059541027bd2efc6038893eaaf2ae","user":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"repo":{"id":71448848,"name":"javascript-task-3","full_name":"urfu-2016/javascript-task-3","owner":{"login":"urfu-2016","id":22170529,"avatar_url":"https://avatars.githubusercontent.com/u/22170529?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2016","html_url":"https://github.com/urfu-2016","followers_url":"https://api.github.com/users/urfu-2016/followers","following_url":"https://api.github.com/users/urfu-2016/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2016/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2016/subscriptions","organizations_url":"https://api.github.com/users/urfu-2016/orgs","repos_url":"https://api.github.com/users/urfu-2016/repos","events_url":"https://api.github.com/users/urfu-2016/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2016/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2016/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":false,"url":"https://api.github.com/repos/urfu-2016/javascript-task-3","forks_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/forks","keys_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/events","assignees_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/merges","archive_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/deployments","created_at":"2016-10-20T09:49:39Z","updated_at":"2016-10-23T04:31:46Z","pushed_at":"2016-11-05T22:35:32Z","git_url":"git://github.com/urfu-2016/javascript-task-3.git","ssh_url":"git@github.com:urfu-2016/javascript-task-3.git","clone_url":"https://github.com/urfu-2016/javascript-task-3.git","svn_url":"https://github.com/urfu-2016/javascript-task-3","homepage":"","size":111,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":95,"mirror_url":null,"open_issues_count":30,"forks":95,"open_issues":30,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/19"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/19"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/9969c8f445d14dd0e8f978a09576ac333d18a1df"}}}}
{"actor":{"display_login":"Zeace"}}