def METHOD_NAME(val):
    try:
        # If it's only a date, don't turn it into a datetime
        val = datetime.datetime.strptime(val, '%Y-%m-%d').date()
    except ValueError:
        try:
            val = parse(val)
        except ValueError:
            raise ValueError(_("Cannot parse datetime '{val}'").format(val=val))
    return val