def is_valid_date(given_date):
"""
Given a date string this function checks if the date is in the future
"""
given_date = given_date.split("/")
current_date = get_current_date().split("/")
given_day = int(given_date[1])
given_month = int(given_date[0])
given_year = int(given_date[2])
current_day = int(current_date[1])
current_month = int(current_date[0])
current_year = int(current_date[2])
try:
calendar.weekday(given_year, given_month, given_day)
except ValueError:
return False
return (
(given_year == current_year and given_month == current_month and given_day > current_day) or
(given_year == current_year and given_month > current_month) or
(given_year > current_year))
评论列表
文章目录