Skip to content

Is the Date Today

Write a simple function that takes as a parameter a date object and returns a boolean value representing whether the date is today or not.

Make sure that your function does not return a false positive by just checking just the day.

Solution

py
from datetime import datetime


def is_the_date_today(date):
    return datetime.today().date() == date.date()


print(is_the_date_today(datetime.strptime('2022-03-03', '%Y-%m-%d')))

my thoughts are neither my employer's nor my wife's