def _trim(tr, time_interval):
    """Trim traces of stream relative to mid sample"""
    starttime = tr.stats.starttime
    mid = starttime + (tr.stats.endtime - starttime) / 2
    if time_interval is not None:
        start, end = time_interval
        if start is not None:
            start = mid + start
        if end is not None:
            end = mid + end
        tr.trim(start, end)
    times = tr.times(reftime=mid)
    tr.stats.starttime = starttime
    return times
