<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_jid(name, append_date=None):
 """Generates a v alid JID based on the room name. :param append_date: appends the given date to the JID """

    if not append_date:
        return sanitize_jid(name)
    return '{}-{}'.format(sanitize_jid(name), append_date.strftime('%Y-%m-%d'))