def _add_duration_information(data, ev, duration):
    """Determine event duration in one of a few ways."""
    if duration is None:
        duration = 0
    elif duration in data:
        duration = data[duration]
    ev['duration'] = duration
    return ev
