Example #1
0
    def calculate_hours_worked():
        """Calculates the number of hours (and minutes) worked so far"""
        time_worked = None
        for b in TimeCard.timecard_blocks:
            if time_worked is None:
                time_worked = b.get_delta()
            else:
                time_worked += b.get_delta()

        # Use method to convert time_worked to desired output format
        hours_worked = Dates.convert_timedelta(time_worked)
        print('\nHours worked (Rounded to nearest six minutes):')
        print(hours_worked)

        remaining = timedelta(hours=TimeCard.min_hours) - time_worked
        hours_left = Dates.convert_timedelta(remaining)
        hl_max = Dates.convert_timedelta((remaining + timedelta(minutes=3)))
        print('Hours Remaining (Rounded to nearest six minutes):')
        print(hours_left, 'to', hl_max)

        TimeCard.calculate_clockout_time(remaining)