diff --git a/projects/dev/pto_countdown/main.py b/projects/dev/pto_countdown/main.py new file mode 100644 index 0000000..7a4ab8a --- /dev/null +++ b/projects/dev/pto_countdown/main.py @@ -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')}") \ No newline at end of file