def full_schedule_to_dict(full_schedule):
    """Generate a dictionary from a schedule object for conversion to JSON.

    Generate a dictionary like:
        { dow: [ {'when': start, 'temp':  {zone: temp}} ] }
    """
    json_schedule = {}
    for dow in range(7):
        json_schedule[dow] = []
    for entry in full_schedule:
        entry_dow, entry_start, entry_zone, entry_temp = entry
        dow = json_schedule[entry_dow]
        entry_start_str = entry_start.strftime('%H:%M')
        added = False
        for e in dow:
            if e['when'] == entry_start_str:
                e['zones'].append({'zone': entry_zone, 'temp': entry_temp})
                added = True
                break
        if not added:
            dow.append({'when': entry_start.strftime('%H:%M'), 'zones': [{
                'zone': entry_zone, 'temp': entry_temp}]})
    return json_schedule
