further updates and pto calculator

This commit is contained in:
2024-03-08 11:44:28 -07:00
parent 8e1e12a2e8
commit 3c576ec2c0

View File

@@ -0,0 +1,42 @@
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
# 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')}")