给定一系列数字范围，生成一个随机的日期并将其格式化为YYYY-MM-DD格式，然后告诉用户这一天是一周中的哪一天。


数字范围：年份[2000, 2022]，月份[1, 12]，日期[1, 31]
import random

year = random.randint(2000, 2022)
month = random.randint(1, 12)
# 处理日期最大值
if month in [4, 6, 9, 11]:
    max_day = 30
elif month == 2:
    # 处理闰年
    if year % 400 == 0 or (year % 100 != 0 and year % 4 == 0):
        max_day = 29
    else:
        max_day = 28
else:
    max_day = 31
    
day = random.randint(1, max_day)

date_str = f"{year}-{month:02d}-{day:02d}"
# 处理星期几
weekday = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"][datetime.datetime.strptime(date_str, '%Y-%m-%d').weekday()]

print(f"The randomly generated date is {date_str}, which falls on a {weekday}.")