{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/86300180","pull_request_review_id":6963641,"id":86300180,"diff_hunk":"@@ -48,3 +58,216 @@ exports.getAppropriateMoment = function (schedule, duration, workingHours) {\n         }\n     };\n };\n+\n+function parseBankObj(workingHours) {\n+    var bankSchedual = [];\n+    var time = [];\n+\n+    var objectProp = Object.keys(workingHours);\n+    for (var i = 0; i < objectProp.length; i++) {\n+        time = parseTime(workingHours[objectProp[i]]);\n+        bankSchedual.push((Number(time[0]) * 60) + Number(time[1]));\n+    }\n+    bankSchedual.push(Number(time[2]));\n+\n+    return bankSchedual;\n+}\n+\n+function parseTime(time, day) {\n+    if (!day) {\n+        var regTime = /[:]|[+]/;\n+        time = time.split(regTime);\n+    } else {\n+        var regTimeDay = /\\s|[:]|[+]/;\n+        time = time.split(regTimeDay);\n+    }\n+\n+    return time;\n+}\n+\n+function parseGangObj(schedule, timeZone) {\n+    var gangSchedule = {};\n+\n+    Object.keys(schedule).forEach(function (item) {\n+        gangSchedule[item] = [];\n+        for (var i = 0; i < schedule[item].length; i++) {\n+            var eachDay = parsEachDay(schedule[item][i], timeZone);\n+            gangSchedule[item].push(eachDay);\n+        }\n+    });\n+\n+    return gangSchedule;\n+}\n+\n+function parsEachDay(daysAnaTime, timeZone) {\n+    var convertTimeObj = {};\n+\n+    Object.keys(daysAnaTime).forEach(function (item) {\n+        var convertTime = parseTime(daysAnaTime[item], true);\n+        var resetZone = 0;\n+        var dayIndex = DAYS.indexOf(convertTime[0]);\n+        if (Number(convertTime[3]) !== timeZone) {\n+            resetZone = (timeZone - convertTime[3]) * 60;\n+        }\n+        var time = + Number(convertTime[1]) * 60 + Number(convertTime[2]) +\n+                                                    Number(resetZone) +\n+                                                    (dayIndex * 1440);\n+        convertTimeObj['day' + item] = convertTime[0];\n+        convertTimeObj[item] = time;\n+    });\n+\n+    return convertTimeObj;\n+}\n+\n+function findFreeTime(gangSchedule, bankSchedual, duration) {\n+    var arrayOfWeekDays = buildArrayOfWeek(bankSchedual);\n+    var arrGangTime = setkGangTime(gangSchedule, bankSchedual, arrayOfWeekDays);\n+    var processingTime = checkGangTime(arrGangTime, duration);\n+\n+    return processingTime;\n+}\n+\n+function buildArrayOfWeek(bankSchedual) {\n+    var weekDaysString = [];\n+    var bankOn = bankSchedual[0];\n+    var bankOff = bankSchedual[1];\n+    for (var i = 0; i < 7; i++) {\n+        for (var j = 0; j < MINUTES_IN_DAY; j++) {\n+            weekDaysString.push(setArrPosition(i, j, bankOn, bankOff));\n+        }\n+    }\n+\n+    return weekDaysString;\n+}\n+\n+function setArrPosition(i, j, bankOn, bankOff) {\n+    if (j >= bankOn && j < bankOff) {\n+        return 1;\n+    }\n+\n+    return 0;\n+}\n+\n+function setkGangTime(gangSchedule, bankSchedual, arrDays) {\n+    Object.keys(gangSchedule).forEach(function (item) {\n+        for (var i = 0; i < gangSchedule[item].length; i++) {\n+            var dataOfEach = gangSchedule[item][i];\n+            arrDays = checkInterval(dataOfEach, bankSchedual, arrDays);\n+        }\n+    });\n+\n+    return arrDays;\n+}\n+\n+function checkInterval(timeOfEach, bankSchedual, arrDays) {\n+    var data = {\n+        busyFrom: timeOfEach.from,\n+        busyTo: timeOfEach.to\n+    };\n+\n+    return setTimeForThis(data, arrDays);\n+}\n+\n+function setTimeForThis(data, arrDays) {\n+    for (var i = data.busyFrom; i < data.busyTo; i++) {\n+        arrDays[i] = 0;\n+    }\n+\n+    return arrDays;\n+}\n+\n+function checkGangTime(arrGangTime, duration) {\n+    var timeData = [];\n+    var indexForDay = 0;\n+    var sortedTime = [];\n+\n+    for (var i = 0; i < arrGangTime.length; i++) {\n+        if ((i % 1440) === 0 && indexForDay < 3) {\n+            var forEachDay = arrGangTime.slice(i, (i + 1440)).join('');\n+            sortedTime = sortArr(forEachDay, indexForDay, duration);\n+            indexForDay++;\n+            timeData.push(sortedTime);\n+        }\n+    }\n+\n+    return timeData;\n+}\n+\n+function sortArr(forEachDay, indexForDay, duration) {","path":"robbery.js","position":186,"original_position":186,"commit_id":"7d7ae554b0055449a6aeb3c9117a927c36c1c331","original_commit_id":"7d7ae554b0055449a6aeb3c9117a927c36c1c331","user":{"login":"chipolinka","id":11631479,"avatar_url":"https://avatars.githubusercontent.com/u/11631479?v=3","gravatar_id":"","url":"https://api.github.com/users/chipolinka","html_url":"https://github.com/chipolinka","followers_url":"https://api.github.com/users/chipolinka/followers","following_url":"https://api.github.com/users/chipolinka/following{/other_user}","gists_url":"https://api.github.com/users/chipolinka/gists{/gist_id}","starred_url":"https://api.github.com/users/chipolinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipolinka/subscriptions","organizations_url":"https://api.github.com/users/chipolinka/orgs","repos_url":"https://api.github.com/users/chipolinka/repos","events_url":"https://api.github.com/users/chipolinka/events{/privacy}","received_events_url":"https://api.github.com/users/chipolinka/received_events","type":"User","site_admin":false},"body":"Если тут правда происходит сортировка массива, то есть такая встроенная функция. ","created_at":"2016-11-03T08:34:24Z","updated_at":"2016-11-03T08:34:24Z","html_url":"https://github.com/urfu-2016/javascript-task-3/pull/64#discussion_r86300180","pull_request_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/comments/86300180"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/64#discussion_r86300180"},"pull_request":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64","id":91093295,"html_url":"https://github.com/urfu-2016/javascript-task-3/pull/64","diff_url":"https://github.com/urfu-2016/javascript-task-3/pull/64.diff","patch_url":"https://github.com/urfu-2016/javascript-task-3/pull/64.patch","issue_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/64","number":64,"state":"open","locked":false,"title":"Гульчук Петр","user":{"login":"PetrGch","id":15795248,"avatar_url":"https://avatars.githubusercontent.com/u/15795248?v=3","gravatar_id":"","url":"https://api.github.com/users/PetrGch","html_url":"https://github.com/PetrGch","followers_url":"https://api.github.com/users/PetrGch/followers","following_url":"https://api.github.com/users/PetrGch/following{/other_user}","gists_url":"https://api.github.com/users/PetrGch/gists{/gist_id}","starred_url":"https://api.github.com/users/PetrGch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PetrGch/subscriptions","organizations_url":"https://api.github.com/users/PetrGch/orgs","repos_url":"https://api.github.com/users/PetrGch/repos","events_url":"https://api.github.com/users/PetrGch/events{/privacy}","received_events_url":"https://api.github.com/users/PetrGch/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-26T21:35:17Z","updated_at":"2016-11-03T08:34:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70ae16fedf523a85fd48130ee80aede647e6055f","assignee":{"login":"chipolinka","id":11631479,"avatar_url":"https://avatars.githubusercontent.com/u/11631479?v=3","gravatar_id":"","url":"https://api.github.com/users/chipolinka","html_url":"https://github.com/chipolinka","followers_url":"https://api.github.com/users/chipolinka/followers","following_url":"https://api.github.com/users/chipolinka/following{/other_user}","gists_url":"https://api.github.com/users/chipolinka/gists{/gist_id}","starred_url":"https://api.github.com/users/chipolinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipolinka/subscriptions","organizations_url":"https://api.github.com/users/chipolinka/orgs","repos_url":"https://api.github.com/users/chipolinka/repos","events_url":"https://api.github.com/users/chipolinka/events{/privacy}","received_events_url":"https://api.github.com/users/chipolinka/received_events","type":"User","site_admin":false},"assignees":[{"login":"chipolinka","id":11631479,"avatar_url":"https://avatars.githubusercontent.com/u/11631479?v=3","gravatar_id":"","url":"https://api.github.com/users/chipolinka","html_url":"https://github.com/chipolinka","followers_url":"https://api.github.com/users/chipolinka/followers","following_url":"https://api.github.com/users/chipolinka/following{/other_user}","gists_url":"https://api.github.com/users/chipolinka/gists{/gist_id}","starred_url":"https://api.github.com/users/chipolinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chipolinka/subscriptions","organizations_url":"https://api.github.com/users/chipolinka/orgs","repos_url":"https://api.github.com/users/chipolinka/repos","events_url":"https://api.github.com/users/chipolinka/events{/privacy}","received_events_url":"https://api.github.com/users/chipolinka/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64/commits","review_comments_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64/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/64/comments","statuses_url":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/7d7ae554b0055449a6aeb3c9117a927c36c1c331","head":{"label":"PetrGch:master","ref":"master","sha":"7d7ae554b0055449a6aeb3c9117a927c36c1c331","user":{"login":"PetrGch","id":15795248,"avatar_url":"https://avatars.githubusercontent.com/u/15795248?v=3","gravatar_id":"","url":"https://api.github.com/users/PetrGch","html_url":"https://github.com/PetrGch","followers_url":"https://api.github.com/users/PetrGch/followers","following_url":"https://api.github.com/users/PetrGch/following{/other_user}","gists_url":"https://api.github.com/users/PetrGch/gists{/gist_id}","starred_url":"https://api.github.com/users/PetrGch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PetrGch/subscriptions","organizations_url":"https://api.github.com/users/PetrGch/orgs","repos_url":"https://api.github.com/users/PetrGch/repos","events_url":"https://api.github.com/users/PetrGch/events{/privacy}","received_events_url":"https://api.github.com/users/PetrGch/received_events","type":"User","site_admin":false},"repo":{"id":71590068,"name":"javascript-task-3","full_name":"PetrGch/javascript-task-3","owner":{"login":"PetrGch","id":15795248,"avatar_url":"https://avatars.githubusercontent.com/u/15795248?v=3","gravatar_id":"","url":"https://api.github.com/users/PetrGch","html_url":"https://github.com/PetrGch","followers_url":"https://api.github.com/users/PetrGch/followers","following_url":"https://api.github.com/users/PetrGch/following{/other_user}","gists_url":"https://api.github.com/users/PetrGch/gists{/gist_id}","starred_url":"https://api.github.com/users/PetrGch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PetrGch/subscriptions","organizations_url":"https://api.github.com/users/PetrGch/orgs","repos_url":"https://api.github.com/users/PetrGch/repos","events_url":"https://api.github.com/users/PetrGch/events{/privacy}","received_events_url":"https://api.github.com/users/PetrGch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PetrGch/javascript-task-3","description":"Задача «0b11 друзей Оушена»","fork":true,"url":"https://api.github.com/repos/PetrGch/javascript-task-3","forks_url":"https://api.github.com/repos/PetrGch/javascript-task-3/forks","keys_url":"https://api.github.com/repos/PetrGch/javascript-task-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PetrGch/javascript-task-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PetrGch/javascript-task-3/teams","hooks_url":"https://api.github.com/repos/PetrGch/javascript-task-3/hooks","issue_events_url":"https://api.github.com/repos/PetrGch/javascript-task-3/issues/events{/number}","events_url":"https://api.github.com/repos/PetrGch/javascript-task-3/events","assignees_url":"https://api.github.com/repos/PetrGch/javascript-task-3/assignees{/user}","branches_url":"https://api.github.com/repos/PetrGch/javascript-task-3/branches{/branch}","tags_url":"https://api.github.com/repos/PetrGch/javascript-task-3/tags","blobs_url":"https://api.github.com/repos/PetrGch/javascript-task-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PetrGch/javascript-task-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PetrGch/javascript-task-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/PetrGch/javascript-task-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PetrGch/javascript-task-3/statuses/{sha}","languages_url":"https://api.github.com/repos/PetrGch/javascript-task-3/languages","stargazers_url":"https://api.github.com/repos/PetrGch/javascript-task-3/stargazers","contributors_url":"https://api.github.com/repos/PetrGch/javascript-task-3/contributors","subscribers_url":"https://api.github.com/repos/PetrGch/javascript-task-3/subscribers","subscription_url":"https://api.github.com/repos/PetrGch/javascript-task-3/subscription","commits_url":"https://api.github.com/repos/PetrGch/javascript-task-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/PetrGch/javascript-task-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/PetrGch/javascript-task-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/PetrGch/javascript-task-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/PetrGch/javascript-task-3/contents/{+path}","compare_url":"https://api.github.com/repos/PetrGch/javascript-task-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PetrGch/javascript-task-3/merges","archive_url":"https://api.github.com/repos/PetrGch/javascript-task-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PetrGch/javascript-task-3/downloads","issues_url":"https://api.github.com/repos/PetrGch/javascript-task-3/issues{/number}","pulls_url":"https://api.github.com/repos/PetrGch/javascript-task-3/pulls{/number}","milestones_url":"https://api.github.com/repos/PetrGch/javascript-task-3/milestones{/number}","notifications_url":"https://api.github.com/repos/PetrGch/javascript-task-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PetrGch/javascript-task-3/labels{/name}","releases_url":"https://api.github.com/repos/PetrGch/javascript-task-3/releases{/id}","deployments_url":"https://api.github.com/repos/PetrGch/javascript-task-3/deployments","created_at":"2016-10-21T19:14:04Z","updated_at":"2016-10-21T19:14:05Z","pushed_at":"2016-11-01T15:59:20Z","git_url":"git://github.com/PetrGch/javascript-task-3.git","ssh_url":"git@github.com:PetrGch/javascript-task-3.git","clone_url":"https://github.com/PetrGch/javascript-task-3.git","svn_url":"https://github.com/PetrGch/javascript-task-3","homepage":"","size":20,"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-03T08:09:48Z","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":32,"forks":95,"open_issues":32,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64"},"html":{"href":"https://github.com/urfu-2016/javascript-task-3/pull/64"},"issue":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/64"},"comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/pulls/64/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/64/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2016/javascript-task-3/statuses/7d7ae554b0055449a6aeb3c9117a927c36c1c331"}}}}
{"actor":{"display_login":"chipolinka"}}