{"action":"created","comment":{"url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/comments/43043182","id":43043182,"diff_hunk":"@@ -0,0 +1,143 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Text.RegularExpressions;\n+using Google.Apis.Calendar.v3.Data;\n+\n+namespace GoogleCalendarService.Manager\n+{\n+    public class EventPeriodicityHolder\n+    {\n+        public Event RealEvent;\n+        public string Frequency;\n+        public List<DayOfWeek> DayOfWeeksList;\n+        public List<Event> WeekEventList;\n+        public int Count;\n+        public FrequencyType FreqType;\n+        public DateTime UntilDateTime;\n+        public List<Event> EventList;\n+\n+        public EventPeriodicityHolder(Event eventForAdd)\n+        {\n+            RealEvent = eventForAdd;\n+            if (eventForAdd.Recurrence == null)\n+            {\n+                FreqType = FrequencyType.COUNT;\n+                Count = 1;\n+                Frequency = \"DAILY\";\n+            }\n+            else\n+            {\n+                string pattern = @\":FREQ=(?<FREQ>\\w+);(COUNT=(?<COUNT>\\w+);)?(COUNT=(?<COUNT>\\w+))?(UNTIL=(?<UNTIL>\\d+\\w+\\d+\\w+);)?(UNTIL=(?<UNTIL>\\d+\\w+\\d+\\w+))?(BYDAY=(?<BYDAY>[\\w,]+))?\";\n+                Regex regex = new Regex(pattern);\n+                Match match = regex.Match(eventForAdd.Recurrence[0]);\n+\n+                Frequency = match.Groups[\"FREQ\"].Value;\n+                if(match.Groups[\"BYDAY\"].Value != \"\")\n+                    SetDayOfWeeksList(match.Groups[\"BYDAY\"].Value);\n+                if (match.Groups[\"COUNT\"].Value != \"\")\n+                {\n+                    FreqType = FrequencyType.COUNT;\n+                    Count = Convert.ToInt32(match.Groups[\"COUNT\"].Value);\n+                }\n+                if (match.Groups[\"UNTIL\"].Value != \"\")\n+                {\n+                    FreqType = FrequencyType.UNTIL;\n+                    UntilDateTime = GetUntilDateTime(match.Groups[\"UNTIL\"].Value);\n+                }\n+            }\n+\n+            if(Frequency == \"DAILY\")\n+                EventList = EventsListBuilder.StartConstruction().WithDailyEvents(this).Build();\n+            else if(Frequency == \"WEEKLY\")\n+                EventList = EventsListBuilder.StartConstruction().WithWeeklyEvents(this).Build();\n+            else if (Frequency == \"MONTHLY\")\n+                EventList = EventsListBuilder.StartConstruction().WithMonthlyEvents(this).Build();\n+            else if (Frequency == \"YEARLY\")\n+                EventList = EventsListBuilder.StartConstruction().WithYearlyEvents(this).Build();\n+        }\n+\n+        private DateTime GetUntilDateTime(string untilDate)\n+        {\n+            string pattern = @\"(?<Year>\\d{4})(?<Month>\\d{2})(?<Day>\\d{2})T(?<Hour>\\d{2})(?<Minute>\\d{2})(?<Second>\\d{2})Z\";\n+            Regex regex = new Regex(pattern);\n+            Match match = regex.Match(untilDate);\n+\n+            var hour = match.Groups[\"Hour\"].Value == \"00\" ? 0 : Convert.ToInt32(match.Groups[\"Hour\"].Value);\n+            var minute = match.Groups[\"Minute\"].Value == \"00\" ? 0 : Convert.ToInt32(match.Groups[\"Minute\"].Value);\n+            var second = match.Groups[\"Second\"].Value == \"00\" ? 0 : Convert.ToInt32(match.Groups[\"Second\"].Value);\n+\n+            return new DateTime(\n+                Convert.ToInt32(match.Groups[\"Year\"].Value),\n+                Convert.ToInt32(match.Groups[\"Month\"].Value),\n+                Convert.ToInt32(match.Groups[\"Day\"].Value),\n+                hour,\n+                minute,\n+                second\n+                );\n+        }\n+\n+        private void SetDayOfWeeksList(string byDay)\n+        {\n+            DayOfWeeksList = byDay.Split(',').Select(ExtractDay).ToList();\n+            WeekEventList = DayOfWeeksList.Select(ExtractEventTime).ToList();\n+        }\n+\n+        private Event ExtractEventTime(DayOfWeek dayOfWeek)\n+        {\n+            DayOfWeek realEventDay = RealEvent.Start.DateTime.Value.DayOfWeek;\n+            Event newEvent = null;\n+            int day;\n+            if (realEventDay == DayOfWeek.Sunday)\n+                day = 7;\n+            else\n+                day = (int) realEventDay;","path":"CalendarApp/GoogleCalendarService/Manager/EventPeriodicityHolder.cs","position":94,"original_position":94,"commit_id":"bcc045e77c89fb75d2617c9d03e9da0a69419b76","original_commit_id":"bcc045e77c89fb75d2617c9d03e9da0a69419b76","user":{"login":"oloandriy","id":10503958,"avatar_url":"https://avatars.githubusercontent.com/u/10503958?v=3","gravatar_id":"","url":"https://api.github.com/users/oloandriy","html_url":"https://github.com/oloandriy","followers_url":"https://api.github.com/users/oloandriy/followers","following_url":"https://api.github.com/users/oloandriy/following{/other_user}","gists_url":"https://api.github.com/users/oloandriy/gists{/gist_id}","starred_url":"https://api.github.com/users/oloandriy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oloandriy/subscriptions","organizations_url":"https://api.github.com/users/oloandriy/orgs","repos_url":"https://api.github.com/users/oloandriy/repos","events_url":"https://api.github.com/users/oloandriy/events{/privacy}","received_events_url":"https://api.github.com/users/oloandriy/received_events","type":"User","site_admin":false},"body":"conditional operator is much readable in such cases","created_at":"2015-10-26T19:50:29Z","updated_at":"2015-10-26T19:50:29Z","html_url":"https://github.com/OrestHurskiy/CalenderApp/pull/11#discussion_r43043182","pull_request_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/comments/43043182"},"html":{"href":"https://github.com/OrestHurskiy/CalenderApp/pull/11#discussion_r43043182"},"pull_request":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11","id":48023592,"html_url":"https://github.com/OrestHurskiy/CalenderApp/pull/11","diff_url":"https://github.com/OrestHurskiy/CalenderApp/pull/11.diff","patch_url":"https://github.com/OrestHurskiy/CalenderApp/pull/11.patch","issue_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/11","number":11,"state":"open","locked":false,"title":"Creating checking for events conflicts","user":{"login":"KarpaDmytro","id":14778235,"avatar_url":"https://avatars.githubusercontent.com/u/14778235?v=3","gravatar_id":"","url":"https://api.github.com/users/KarpaDmytro","html_url":"https://github.com/KarpaDmytro","followers_url":"https://api.github.com/users/KarpaDmytro/followers","following_url":"https://api.github.com/users/KarpaDmytro/following{/other_user}","gists_url":"https://api.github.com/users/KarpaDmytro/gists{/gist_id}","starred_url":"https://api.github.com/users/KarpaDmytro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KarpaDmytro/subscriptions","organizations_url":"https://api.github.com/users/KarpaDmytro/orgs","repos_url":"https://api.github.com/users/KarpaDmytro/repos","events_url":"https://api.github.com/users/KarpaDmytro/events{/privacy}","received_events_url":"https://api.github.com/users/KarpaDmytro/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-19T01:09:42Z","updated_at":"2015-10-26T19:50:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88d7e567fa08ff49c2d2e0c8ac2709cf1a081b39","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11/commits","review_comments_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11/comments","review_comment_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/11/comments","statuses_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/statuses/bcc045e77c89fb75d2617c9d03e9da0a69419b76","head":{"label":"OrestHurskiy:Including-Checking-Conflicts","ref":"Including-Checking-Conflicts","sha":"bcc045e77c89fb75d2617c9d03e9da0a69419b76","user":{"login":"OrestHurskiy","id":11854706,"avatar_url":"https://avatars.githubusercontent.com/u/11854706?v=3","gravatar_id":"","url":"https://api.github.com/users/OrestHurskiy","html_url":"https://github.com/OrestHurskiy","followers_url":"https://api.github.com/users/OrestHurskiy/followers","following_url":"https://api.github.com/users/OrestHurskiy/following{/other_user}","gists_url":"https://api.github.com/users/OrestHurskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/OrestHurskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrestHurskiy/subscriptions","organizations_url":"https://api.github.com/users/OrestHurskiy/orgs","repos_url":"https://api.github.com/users/OrestHurskiy/repos","events_url":"https://api.github.com/users/OrestHurskiy/events{/privacy}","received_events_url":"https://api.github.com/users/OrestHurskiy/received_events","type":"User","site_admin":false},"repo":{"id":42934225,"name":"CalenderApp","full_name":"OrestHurskiy/CalenderApp","owner":{"login":"OrestHurskiy","id":11854706,"avatar_url":"https://avatars.githubusercontent.com/u/11854706?v=3","gravatar_id":"","url":"https://api.github.com/users/OrestHurskiy","html_url":"https://github.com/OrestHurskiy","followers_url":"https://api.github.com/users/OrestHurskiy/followers","following_url":"https://api.github.com/users/OrestHurskiy/following{/other_user}","gists_url":"https://api.github.com/users/OrestHurskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/OrestHurskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrestHurskiy/subscriptions","organizations_url":"https://api.github.com/users/OrestHurskiy/orgs","repos_url":"https://api.github.com/users/OrestHurskiy/repos","events_url":"https://api.github.com/users/OrestHurskiy/events{/privacy}","received_events_url":"https://api.github.com/users/OrestHurskiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OrestHurskiy/CalenderApp","description":"Booking meeting rooms","fork":false,"url":"https://api.github.com/repos/OrestHurskiy/CalenderApp","forks_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/forks","keys_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/teams","hooks_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/hooks","issue_events_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/events{/number}","events_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/events","assignees_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/assignees{/user}","branches_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/branches{/branch}","tags_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/tags","blobs_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/statuses/{sha}","languages_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/languages","stargazers_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/stargazers","contributors_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/contributors","subscribers_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/subscribers","subscription_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/subscription","commits_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/contents/{+path}","compare_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/merges","archive_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/downloads","issues_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues{/number}","pulls_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls{/number}","milestones_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/milestones{/number}","notifications_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/labels{/name}","releases_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/releases{/id}","created_at":"2015-09-22T13:06:53Z","updated_at":"2015-09-25T07:43:48Z","pushed_at":"2015-10-26T14:11:09Z","git_url":"git://github.com/OrestHurskiy/CalenderApp.git","ssh_url":"git@github.com:OrestHurskiy/CalenderApp.git","clone_url":"https://github.com/OrestHurskiy/CalenderApp.git","svn_url":"https://github.com/OrestHurskiy/CalenderApp","homepage":null,"size":13016,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"OrestHurskiy:dev","ref":"dev","sha":"6f2b5b970cd05592abf3f8e7578fa91e4e53ee4a","user":{"login":"OrestHurskiy","id":11854706,"avatar_url":"https://avatars.githubusercontent.com/u/11854706?v=3","gravatar_id":"","url":"https://api.github.com/users/OrestHurskiy","html_url":"https://github.com/OrestHurskiy","followers_url":"https://api.github.com/users/OrestHurskiy/followers","following_url":"https://api.github.com/users/OrestHurskiy/following{/other_user}","gists_url":"https://api.github.com/users/OrestHurskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/OrestHurskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrestHurskiy/subscriptions","organizations_url":"https://api.github.com/users/OrestHurskiy/orgs","repos_url":"https://api.github.com/users/OrestHurskiy/repos","events_url":"https://api.github.com/users/OrestHurskiy/events{/privacy}","received_events_url":"https://api.github.com/users/OrestHurskiy/received_events","type":"User","site_admin":false},"repo":{"id":42934225,"name":"CalenderApp","full_name":"OrestHurskiy/CalenderApp","owner":{"login":"OrestHurskiy","id":11854706,"avatar_url":"https://avatars.githubusercontent.com/u/11854706?v=3","gravatar_id":"","url":"https://api.github.com/users/OrestHurskiy","html_url":"https://github.com/OrestHurskiy","followers_url":"https://api.github.com/users/OrestHurskiy/followers","following_url":"https://api.github.com/users/OrestHurskiy/following{/other_user}","gists_url":"https://api.github.com/users/OrestHurskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/OrestHurskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrestHurskiy/subscriptions","organizations_url":"https://api.github.com/users/OrestHurskiy/orgs","repos_url":"https://api.github.com/users/OrestHurskiy/repos","events_url":"https://api.github.com/users/OrestHurskiy/events{/privacy}","received_events_url":"https://api.github.com/users/OrestHurskiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/OrestHurskiy/CalenderApp","description":"Booking meeting rooms","fork":false,"url":"https://api.github.com/repos/OrestHurskiy/CalenderApp","forks_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/forks","keys_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/teams","hooks_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/hooks","issue_events_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/events{/number}","events_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/events","assignees_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/assignees{/user}","branches_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/branches{/branch}","tags_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/tags","blobs_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/statuses/{sha}","languages_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/languages","stargazers_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/stargazers","contributors_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/contributors","subscribers_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/subscribers","subscription_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/subscription","commits_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/contents/{+path}","compare_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/merges","archive_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/downloads","issues_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues{/number}","pulls_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls{/number}","milestones_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/milestones{/number}","notifications_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/labels{/name}","releases_url":"https://api.github.com/repos/OrestHurskiy/CalenderApp/releases{/id}","created_at":"2015-09-22T13:06:53Z","updated_at":"2015-09-25T07:43:48Z","pushed_at":"2015-10-26T14:11:09Z","git_url":"git://github.com/OrestHurskiy/CalenderApp.git","ssh_url":"git@github.com:OrestHurskiy/CalenderApp.git","clone_url":"https://github.com/OrestHurskiy/CalenderApp.git","svn_url":"https://github.com/OrestHurskiy/CalenderApp","homepage":null,"size":13016,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11"},"html":{"href":"https://github.com/OrestHurskiy/CalenderApp/pull/11"},"issue":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/11"},"comments":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/OrestHurskiy/CalenderApp/statuses/bcc045e77c89fb75d2617c9d03e9da0a69419b76"}}}}