def append_date_string(url, day_time, date_key=None, date_format='%Y-%m-%d',
    trailing_slash=False):
    """Add date string to the URL.

    >>> url = "https://mochart.com"
    >>> dt = datetime(2018, 11, 17)
    >>> append_date_string(url, dt)
    'https://mochart.com/2018-11-17'
    """
    dt_str = day_time.strftime(date_format)
    slash = ''
    if trailing_slash:
        slash = '/'
    if date_key:
        return f'{url}?{date_key}={dt_str}{slash}'
    return f'{url}/{dt_str}{slash}'
