13 lines
355 B
Python
13 lines
355 B
Python
from datetime import datetime, timedelta
|
|
|
|
def time_until_end_of_day(dt=None):
|
|
|
|
if dt is None:
|
|
today = datetime.today()
|
|
current_weekday = today.weekday()
|
|
|
|
days_until_sunday = (6 - current_weekday) % 7
|
|
first_sunday = today + timedelta(days=days_until_sunday)
|
|
return ((first_sunday.date() - today.date()).days)
|
|
|
|
|