code: def to_datetime(date_or_datetime):
      
      if isinstance(date_or_datetime, date) and \
              not isinstance(date_or_datetime, datetime):
          d = date_or_datetime
          return datetime.strptime(
              '%04d-%02d-%02d' % (d.year, d.month, d.day), '%Y-%m-%d')
      return date_or_datetime
docs: Convert a date object to a datetime object,
      or return as it is if it's not a date object.
  
      :param date_or_datetime: date or datetime object
      :return: a datetime object