46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
def calculate_reach_date(current_hours, max_hours, hours_added_bi_weekly):
|
|
"""
|
|
Calculate the date when the maximum allowed hours will be reached.
|
|
|
|
Parameters:
|
|
- current_hours (float): The current total hours provided by the user.
|
|
- max_hours (float): The maximum hours allowed.
|
|
- hours_added_bi_weekly (float): The number of hours added every two weeks.
|
|
|
|
Returns:
|
|
- datetime.date: The estimated date when the max hours will be reached.
|
|
"""
|
|
# Calculate the difference needed to reach max
|
|
hours_needed = max_hours - current_hours
|
|
|
|
# Calculate the number of bi-weekly periods needed
|
|
bi_weekly_periods_needed = hours_needed / hours_added_bi_weekly
|
|
|
|
# Calculate the days needed
|
|
days_needed = bi_weekly_periods_needed * 14 # 14 days in 2 weeks
|
|
|
|
# Calculate the reach date
|
|
current_date = datetime.now()
|
|
reach_date = current_date + timedelta(days=days_needed)
|
|
|
|
return reach_date
|
|
|
|
# Constants
|
|
MAX_HOURS = 240
|
|
HOURS_ADDED_BI_WEEKLY = 6.15384615
|
|
# HOURS_ADDED_BI_WEEKLY = 7.69230769
|
|
|
|
# User input
|
|
current_hours = float(input("Enter the current hours: "))
|
|
|
|
# Calculate
|
|
reach_date = calculate_reach_date(current_hours, MAX_HOURS, HOURS_ADDED_BI_WEEKLY)
|
|
|
|
# Output
|
|
print(f"Current date: {datetime.now().strftime('%Y-%m-%d')}")
|
|
print(f"You will reach the maximum hours on: {reach_date.strftime('%Y-%m-%d')}")
|