Background
I am trying to write code in Python that print's some message 7 days before Day light savings. In USA Daylight saving time in the United States is the practice of setting the clock forward by one hour when there is longer daylight during the dayIn the U.S., daylight saving time starts on the second Sunday in March and ends on the first Sunday in November
Solution So Far
from datetime import datetime
def is_it_oct_31():
today_date = datetime.today()
return today_date.day == 31 and today_date.month == 10
def is_it_march_1():
today_date = datetime.today()
return today_date.day == 1 and today_date.month == 3
def check_if_it_is_daylight_saving():
if is_it_oct_31():
print("Time to set the clock 1 hour behind soon")
if is_it_march_1():
print("Time to set the clock 1 hour forward soon")
The idea behind my approach is simple, i try to check on dates that are few days before the day light saving event. However i am not sure if i can write code that would always alert me of a daylight saving event "7" days before the event. Any thoughts would be appreciated.