Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #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
Beispiel #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
 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()
 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)
 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)
 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)
 def remove_day(self, day_date: str) -> None:
     day_date = Utils.to_date(day_date)
     self.days.remove_day(day_date)
 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()