<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Ical.Net;

namespace StruggleApplication.domain
{
    class Planner
    {
        private int learingTimeHours;
        private int learingTimeMinutes;
        private int learingTimeSeconds;

        public Planner()
        {
            this.learingTimeHours = 8;
            this.learingTimeMinutes = 0;
            this.learingTimeSeconds = 0;
        }

        public void planExamPreparation(DateTime start, DateTime exam, String examTitle, int effort, int maxLearningHoursPerDay)
        {
            Console.WriteLine("Start: " + start);
            Console.WriteLine("Exam '" + examTitle + "': " + exam);
            Console.WriteLine("Effort: " + effort);

            int numOfWeeks = GetNumberOfWeeks(start, exam);
            int effortPerDay = effort / numOfWeeks;

            TimeSpan totalAvailableTime = GetAvailableTimeOf(start, exam.AddDays(-1));



        }

        public int GetNumberOfWeeks(DateTime start, DateTime exam)
        {
            // Weeks(02.10.17, 09.10.17) = 1
            // Weeks(02.10.17, 03.10.17) = 0
            TimeSpan diff = exam.AddDays(-1).Subtract(start);
            return (int)Math.Ceiling(diff.TotalDays / 7);
        }

        public TimeSpan GetAvailableTimeOf(DateTime start, DateTime end)
        {
            TimeSpan availableTime = new TimeSpan(0, 0, 0);

            double dayDiff = end.Subtract(start).TotalDays;
            int numberOfDays = (int)Math.Ceiling(dayDiff) + 1;
            // Diff(08.10.17, 02.10.17) = 6 days ; 6 + 1 = 7 days (start and end inclusive)
            // Diff(05.10.17, 02.10.17) = 3 days ; 3 + 1 = 4 days (start and end inclusive)
            // ...

            // available time of start
            ArrayList events = GetEventsOfDay(start);
            availableTime = availableTime.Add(GetAvailableTimeOfDay(events));

            // available time till end (inclusive)
            DateTime currentDay = start;
            for (int i = 1; i < numberOfDays; i++)
            {
                currentDay = currentDay.AddDays(1);
                events = GetEventsOfDay(currentDay);
                availableTime = availableTime.Add(GetAvailableTimeOfDay(events));
            }

            return availableTime;
        }

        public ArrayList GetEventsOfDay(DateTime day)
        {
            return new ArrayList();
        }

        public TimeSpan GetAvailableTimeOfDay(ArrayList events)
        {
            TimeSpan availableTime = new TimeSpan(learingTimeHours, learingTimeMinutes, learingTimeSeconds);
            foreach (Object obj in events)
            {
                CalendarEvent currentEvent = (CalendarEvent)obj;
                availableTime = availableTime.Subtract(currentEvent.Duration);
            }

            if (availableTime.TotalMilliseconds < 0)
            {
                return new TimeSpan(0, 0, 0);
            }

            return availableTime;
        }



    }
}<commit_msg>Updated Planner<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Ical.Net;
using StruggleApplication.api;
using StruggleApplication.framework;
using Google.Apis.Calendar.v3.Data;

namespace StruggleApplication.domain
{
    class Planner
    {
        private int learingTimeHours;
        private int learingTimeMinutes;
        private int learingTimeSeconds;

        private ICalendarInstance instance;

        public Planner()
        {
            this.learingTimeHours = 8;
            this.learingTimeMinutes = 0;
            this.learingTimeSeconds = 0;

            this.instance = new GoogleCalendarInstance();
            instance.Initialize();
        }

        public void planExamPreparation(DateTime start, DateTime exam, String examTitle, int effort, int maxLearningHoursPerDay)
        {
            Console.WriteLine("Start: " + start);
            Console.WriteLine("Exam '" + examTitle + "': " + exam);
            Console.WriteLine("Effort: " + effort + "h");

            int numOfWeeks = GetNumberOfWeeks(start, exam);
            double remainingEffort = effort * 60;
            double effortPerDay = (effort * 1.2) / numOfWeeks;
            double carryOver = 0;
            double totalAvailableTime = GetAvailableTimeOf(start, exam.AddDays(-1)).TotalHours;



        }

        public int GetNumberOfWeeks(DateTime start, DateTime exam)
        {
            // Weeks(02.10.17, 09.10.17) = 1
            // Weeks(02.10.17, 03.10.17) = 0
            TimeSpan diff = exam.AddDays(-1).Subtract(start);
            return (int)Math.Ceiling(diff.TotalDays / 7);
        }

        public TimeSpan GetAvailableTimeOf(DateTime start, DateTime end)
        {
            TimeSpan availableTime = new TimeSpan(0, 0, 0);

            double dayDiff = end.Subtract(start).TotalDays;
            int numberOfDays = (int)Math.Ceiling(dayDiff) + 1;
            // Diff(08.10.17, 02.10.17) = 6 days ; 6 + 1 = 7 days (start and end inclusive)
            // Diff(05.10.17, 02.10.17) = 3 days ; 3 + 1 = 4 days (start and end inclusive)
            // ...

            // available time of start
            availableTime = availableTime.Add(GetAvailableTimeOfDay(start));

            // available time till end (inclusive)
            DateTime currentDay = start;
            for (int i = 1; i < numberOfDays; i++)
            {
                currentDay = currentDay.AddDays(1);
                availableTime = availableTime.Add(GetAvailableTimeOfDay(currentDay));
            }

            return availableTime;
        }

        public TimeSpan GetAvailableTimeOfDay(DateTime day)
        {
            TimeSpan availableTime = new TimeSpan(learingTimeHours, learingTimeMinutes, learingTimeSeconds);
            List<Event> events = this.instance.GetEventsForDate(day);

            foreach (Object obj in events)
            {
                CalendarEvent currentEvent = (CalendarEvent)obj;
                availableTime = availableTime.Subtract(currentEvent.Duration);
            }

            if (availableTime.TotalMilliseconds < 0)
            {
                return new TimeSpan(0, 0, 0);
            }

            return availableTime;
        }

    }
{'fraction_non_alphanumeric': 0.09304541124166402, 'fraction_numerical': 0.024452207049857098, 'mean_word_length': 1.9000920810313076, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3730597', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1660, 'n_words': 398}