def generate_ics(courses):
    """.ics作るやつ"""
    events = ""
    for c in courses:
        created = strftime(datetime.datetime.utcnow()) + "Z"
        summary = c["title"]
        location = c["room"]
        description = "{id}・{modules}・{credit}単位".format(**c)

        try:
            dates = parse_stupid_date(c)
        except AssertionError as e:
            sys.stderr.write("無視: 日付またはモジュールのパースに失敗しました"
                "(title={title}, periods={periods},"
                "modules={modules})\n".format(**c))
            continue

        for start, end in dates:
            uid = str(uuid.uuid4())
            dt_start = strftime(start)
            dt_end = strftime(end)

            until = get_end_date(c['modules'])
            dt_until = strftime(datetime.datetime.utcfromtimestamp(until.timestamp())) + "Z"
            events = events.strip() + event.format(**locals())

    return "\n".join(map(lambda x: x.strip(), [header, events, footer]))