Example #1
0
 def check_monthly_hours(self, day_date: str) -> float:
     day_date = Utils.to_date(day_date)
     first_day_of_the_month = HourMonitor.get_first_date_of_the_month(day_date)
     weekstarts = HourMonitor.get_week_starts(first_day_of_the_month)
     monthly_hours = 0
     for weekstart in weekstarts:
         weekstart = Utils.day_date_to_string(weekstart)
         monthly_hours += self.check_weekly_hours(weekstart)
     return monthly_hours
Example #2
0
 def create_today_and_tomorrow_dictionary():
     entry_hour = Utils.to_time("8:00")
     exit_hour = Utils.to_time("18:00")
     today = Day(date.today(), entry_hour, exit_hour)
     tomorrow = Day(date.today() + timedelta(days=1), entry_hour, exit_hour)
     days = dict()
     days[today.day_date] = today
     days[tomorrow.day_date] = tomorrow
     return days
Example #3
0
 def create_from_json_dict(json_dict):
     day_date = Utils.to_date(json_dict[Day.day_date_attribute_name])
     if Day.entry_hour_attribute_name in json_dict.keys(
     ):  # todo refactor conditionals?
         entry_hour = Utils.to_time(
             json_dict[Day.entry_hour_attribute_name])
     else:
         entry_hour = None
     if Day.exit_hour_attribute_name in json_dict.keys():
         exit_hour = Utils.to_time(json_dict[Day.exit_hour_attribute_name])
     else:
         exit_hour = None
     return Day(day_date, entry_hour, exit_hour)
Example #4
0
 def to_json_dict(self):
     json_writable_dict = dict()
     json_writable_dict[
         self.day_date_attribute_name] = Utils.day_date_to_string(
             self.day_date)
     if self.entry_hour is not None:
         json_writable_dict[
             self.entry_hour_attribute_name] = Utils.hour_to_string(
                 self.entry_hour)
     if self.exit_hour is not None:
         json_writable_dict[
             self.exit_hour_attribute_name] = Utils.hour_to_string(
                 self.exit_hour)
     return json_writable_dict
Example #5
0
 def check_weekly_hours(self, day_date: str) -> float:
     day_date = Utils.to_date(day_date)
     first_date_of_the_week = HourMonitor.get_first_date_of_the_week(day_date)
     week = self.get_week(first_date_of_the_week)
     weekly_hours = 0
     for day in week:
         weekly_hours += day.get_daily_hours()
     return weekly_hours
Example #6
0
 def check_daily_hours(self, day_date: str) -> float:
     day_date = Utils.to_date(day_date)
     day = self.days.get_day(day_date)
     return day.get_daily_hours()
Example #7
0
 def update_exit_hour(self, day_date: str, new_exit_hour: str) -> None:
     day_date = Utils.to_date(day_date)
     new_exit_hour = Utils.to_time(new_exit_hour)
     day_to_update = self.days.get_day(day_date)
     day_to_update.exit_hour = new_exit_hour
     self.days.update_day(day_date, day_to_update)
Example #8
0
 def check_exit_hour(self, day_date: str) -> str:
     day_date = Utils.to_date(day_date)
     day = self.days.get_day(day_date)
     return Utils.hour_to_string(day.exit_hour)
Example #9
0
 def store_exit_hour(self, day_date: str, exit_hour: str) -> None:
     day_date = Utils.to_date(day_date)
     exit_hour = Utils.to_time(exit_hour)
     day_to_store = Day(day_date, exit_hour=exit_hour)
     self.store_day(day_date, day_to_store)
Example #10
0
 def remove_day(self, day_date: str) -> None:
     day_date = Utils.to_date(day_date)
     self.days.remove_day(day_date)
Example #11
0
 def check_remaining_daily_hours(self, day_date: str) -> float:
     day_date = Utils.to_date(day_date)
     day = self.days.get_day(day_date)
     return Config.DAILY_HOURS - day.get_daily_hours()