def truncate_day(dt, measure):
 days = dt.toordinal()
 days = ((days // measure) * measure)
 return date.fromordinal(days)

def truncate_day ( dt , measure ) : days = dt . toordinal ( ) days = ( ( days // measure ) * measure ) return date . fromordinal ( days )
truncate by days .