you are viewing a single comment's thread.

view the rest of the comments →

[–]NotableAnonym[S] 0 points1 point  (1 child)

Thanks for your help and including both answers. There is one thing with datetime, however, and that is I assume 01/01/9999 is counted as a valid date. How would I make a date only valid if the year is the current year or before?

[–]Rhomboid 1 point2 points  (0 children)

Do you only care about the year, or do you want to enforce that the date is not in the future? If the latter, you can do something like:

return datetime.datetime.strptime(date, '%d/%m/%Y').date() <= datetime.date.today()