A little bit confused on the goal of the script, but I assume you want to find the number of days between the current day and the following Monday.
Assumptions:
- The number of days is calculated until 12am Monday morning. In other words, the days count does not include Monday.
Code to count only the number of full days until Monday:
from datetime import datetime, timedelta
today = datetime.today()
print(int(6 - today.weekday()))
Output (current day is Wednesday 1:29AM):
4
Code to calculate the number of days including partial days (i.e. current day 1:29 on Wednesday, there is about 4.91 days until 12am on Monday).
Detailed view:
from datetime import datetime, timedelta
# Get current date
today = datetime.today()
# Calculate number of days until Monday (partial days count as full day)
days_until_monday = timedelta(days=int(6 - today.weekday()) + 1)
# Get date of next Monday
next_monday = today + days_until_monday
# Format dates
today = datetime(today.year, today.month, today.day, today.hour, today.minute, today.second)
next_monday = datetime(next_monday.year, next_monday.month, next_monday.day, 0, 0, 0)
# Difference up to the nearest second
delta = next_monday - today
delta = delta.total_seconds()
# Convert to days
delta = delta / 86400
# Print result
print(float(delta))
Output:
4.912685185185185
Hope this helps :)