Files
bin/countdown.py

30 lines
856 B
Python
Executable File

#!/usr/bin/env python3
from datetime import datetime, timedelta
def count_business_days(start_date, end_date):
business_days = 0
current_date = start_date
while current_date <= end_date:
# Check if the current day is a weekday (Mon-Fri)
if current_date.weekday() < 5: # 0 = Monday, 4 = Friday
business_days += 1
current_date += timedelta(days=1)
return business_days
# Get the current date and the target date
now = datetime.now()
target_date = datetime(now.year, 9, 17)
# Adjust the target year if Sept 17 is in the next year
if now > target_date:
target_date = target_date.replace(year=now.year + 1)
# Calculate the number of business days remaining
remaining_business_days = count_business_days(now, target_date)
print(f"Business days remaining until Sep 17: {remaining_business_days}")