def todate(somedate):
 if isinstance(somedate, datetime):
  return date(somedate.year, somedate.month, somedate.day)
 assert isinstance(somedate, (date, DateTimeType)), repr(somedate)
 return somedate

def todate ( somedate ) : if isinstance ( somedate , datetime ) : return date ( somedate . year , somedate . month , somedate . day ) assert isinstance ( somedate , ( date , DateTimeType ) ) , repr ( somedate ) return somedate
return a date from a date or a datetime .