{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/84716366","pull_request_review_id":5471498,"id":84716366,"diff_hunk":"@@ -5,6 +5,109 @@\n  * Реализовано оба метода и tryLater\n  */\n exports.isStar = true;\n+var MILLISECINMIN = 60000;\n+var MILLISECINHOUR = MILLISECINMIN * 60;\n+var FINISHTIME;\n+\n+var days = ['ПН', 'ВТ', 'СР'];\n+var daysInNum = {\n+    'ПН': 1,\n+    'ВТ': 2,\n+    'СР': 3,\n+    'ЧТ': 4,\n+    'ПТ': 5,\n+    'СБ': 6,\n+    'ВС': 7\n+};\n+\n+var daysFromNum = {\n+    1: 'ПН',\n+    2: 'ВТ',\n+    3: 'СР'\n+};\n+function toTimestamp(str) {\n+    var region = parseInt(str.slice(-2));\n+    var hours = parseInt(str.slice(2, 5));\n+    var minutes = parseInt(str.slice(6, 8));\n+    var day = daysInNum[str.slice(0, 2)];\n+\n+    return Date.UTC(2016, 7, day, hours, minutes) - region * MILLISECINHOUR;\n+}\n+\n+function makeListForAll(schedule) {\n+    var timeList = [];\n+    Object.keys(schedule).forEach(function (man) {\n+        for (var i = 0; i < schedule[man].length; i++) {\n+            timeList.push({ 'from': toTimestamp(schedule[man][i].from),\n+                'to': toTimestamp(schedule[man][i].to) });\n+        }\n+    });\n+\n+    return timeList;\n+}\n+\n+function checkEnoughTime(start, duration, time) {\n+    return (start + duration * MILLISECINMIN) <= time;\n+}\n+\n+function addBankHours(timeList, bankRegion, bankDays) {\n+    for (var i = 1; i <= bankDays.length; i++) {\n+        var start = Date.UTC(2016, 7, i, 0, 0) - bankRegion * MILLISECINHOUR;\n+        var end = Date.UTC(2016, 7, i, 23, 59) - bankRegion * MILLISECINHOUR;\n+        timeList.push({ 'from': start, 'to': bankDays[i - 1].from });\n+        timeList.push({ 'from': bankDays[i - 1].to, 'to': end });\n+    }\n+\n+    return timeList;\n+}\n+\n+function sortTimeList(timeList) {\n+    return timeList.sort(function (fst, scnd) {\n+        if (fst.from > scnd.from) {\n+\n+            return 1;\n+        } else if (fst.from === scnd.from) {\n+\n+            return 0;\n+        }\n+\n+        return -1;\n+    });\n+}\n+\n+\n+function makeBankDays(workingHours) {\n+    var bankDays = [];\n+    for (var i = 0; i < days.length; i++) {\n+        var from = toTimestamp(days[i] + ' ' + workingHours.from);\n+        var to = toTimestamp(days[i] + ' ' + workingHours.to);\n+        bankDays.push({ 'from': from, 'to': to });\n+    }\n+\n+    return bankDays;\n+}\n+\n+function chooseIntervals(startTime, duration, timeList) {\n+    for (var i = 0; i < timeList.length; i++) {\n+        if (startTime >= FINISHTIME) {\n+            return null;\n+        }\n+        var interval = timeList[i];\n+        if (checkEnoughTime(startTime, duration, interval.from)) {\n+            return startTime;\n+        } else if (startTime < interval.to) {\n+            startTime = interval.to;\n+","path":"robbery.js","position":96,"original_position":96,"commit_id":"c4caa4bd4b85113f5d5ca717c9ee17d816c8751f","original_commit_id":"c4caa4bd4b85113f5d5ca717c9ee17d816c8751f","user":{"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},"body":"лишняя строка","created_at":"2016-10-24T15:40:20Z","updated_at":"2016-10-24T15:45:38Z","html_url":"https://github.com/urfu-2016/javascript-task-3/pull/16#discussion_r84716366","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/84716366"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/16#discussion_r84716366"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16","id":90507491,"html_url":"https://github.com/urfu-2016/javascript-task-3/pull/16","diff_url":"https://github.com/urfu-2016/javascript-task-3/pull/16.diff","patch_url":"https://github.com/urfu-2016/javascript-task-3/pull/16.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/16","number":16,"state":"open","locked":false,"title":"Лунин Даниил","user":{"login":"danlunin","id":19825092,"avatar_url":"https://avatars.githubusercontent.com/u/19825092?v=3","gravatar_id":"","url":"https://api.github.com/users/danlunin","html_url":"https://github.com/danlunin","followers_url":"https://api.github.com/users/danlunin/followers","following_url":"https://api.github.com/users/danlunin/following{/other_user}","gists_url":"https://api.github.com/users/danlunin/gists{/gist_id}","starred_url":"https://api.github.com/users/danlunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlunin/subscriptions","organizations_url":"https://api.github.com/users/danlunin/orgs","repos_url":"https://api.github.com/users/danlunin/repos","events_url":"https://api.github.com/users/danlunin/events{/privacy}","received_events_url":"https://api.github.com/users/danlunin/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-23T07:16:30Z","updated_at":"2016-10-24T15:45:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1148f1d485fa6ccb0d94e91748587803073e2ff1","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/16/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16/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/16/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/c4caa4bd4b85113f5d5ca717c9ee17d816c8751f","head":{"label":"danlunin:master","ref":"master","sha":"c4caa4bd4b85113f5d5ca717c9ee17d816c8751f","user":{"login":"danlunin","id":19825092,"avatar_url":"https://avatars.githubusercontent.com/u/19825092?v=3","gravatar_id":"","url":"https://api.github.com/users/danlunin","html_url":"https://github.com/danlunin","followers_url":"https://api.github.com/users/danlunin/followers","following_url":"https://api.github.com/users/danlunin/following{/other_user}","gists_url":"https://api.github.com/users/danlunin/gists{/gist_id}","starred_url":"https://api.github.com/users/danlunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlunin/subscriptions","organizations_url":"https://api.github.com/users/danlunin/orgs","repos_url":"https://api.github.com/users/danlunin/repos","events_url":"https://api.github.com/users/danlunin/events{/privacy}","received_events_url":"https://api.github.com/users/danlunin/received_events","type":"User","site_admin":false},"repo":{"id":71558817,"name":"javascript-task-3","full_name":"danlunin/javascript-task-3","owner":{"login":"danlunin","id":19825092,"avatar_url":"https://avatars.githubusercontent.com/u/19825092?v=3","gravatar_id":"","url":"https://api.github.com/users/danlunin","html_url":"https://github.com/danlunin","followers_url":"https://api.github.com/users/danlunin/followers","following_url":"https://api.github.com/users/danlunin/following{/other_user}","gists_url":"https://api.github.com/users/danlunin/gists{/gist_id}","starred_url":"https://api.github.com/users/danlunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlunin/subscriptions","organizations_url":"https://api.github.com/users/danlunin/orgs","repos_url":"https://api.github.com/users/danlunin/repos","events_url":"https://api.github.com/users/danlunin/events{/privacy}","received_events_url":"https://api.github.com/users/danlunin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danlunin/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":true,"url":"https://api.github.com/repos/danlunin/javascript-task-3","forks_url":"https://api.github.com/repos/danlunin/javascript-task-3/forks","keys_url":"https://api.github.com/repos/danlunin/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danlunin/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danlunin/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/danlunin/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/danlunin/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/danlunin/javascript-task-3/events","assignees_url":"https://api.github.com/repos/danlunin/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/danlunin/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/danlunin/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/danlunin/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danlunin/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danlunin/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/danlunin/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danlunin/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/danlunin/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/danlunin/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/danlunin/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/danlunin/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/danlunin/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/danlunin/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/danlunin/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/danlunin/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/danlunin/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/danlunin/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/danlunin/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danlunin/javascript-task-3/merges","archive_url":"https://api.github.com/repos/danlunin/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danlunin/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/danlunin/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/danlunin/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/danlunin/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/danlunin/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danlunin/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/danlunin/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/danlunin/javascript-task-3/deployments","created_at":"2016-10-21T11:19:18Z","updated_at":"2016-10-21T11:19:19Z","pushed_at":"2016-10-23T14:07:48Z","git_url":"git://github.com/danlunin/javascript-task-3.git","ssh_url":"git@github.com:danlunin/javascript-task-3.git","clone_url":"https://github.com/danlunin/javascript-task-3.git","svn_url":"https://github.com/danlunin/javascript-task-3","homepage":"","size":15,"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-10-24T15:43:13Z","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":71,"mirror_url":null,"open_issues_count":30,"forks":71,"open_issues":30,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/16"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/16"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/16/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/16/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/c4caa4bd4b85113f5d5ca717c9ee17d816c8751f"}}}}
{"actor":{"display_login":"Lakate"}}