import datetime

def parse_datetime(filename):
    """date and time parser
    Args:
        filename (str): filename that contains substring in format: 
                        'YYYYMMDDTHHMMSSmmm+XXXX'
    Returns:
        datetime object
    """
    idx = filename.index('T')
    splits = [(-8, -4), (-4, -2), (-2, 0),        # year, month, day,
              (1, 3), (3, 5), (5, 7), (7, 10)]   # hour, min, secs, ms
              # (10,13), (13,15)] # utc offset hours, minutes
    vals = [int(filename[idx+i:idx+j]) for i, j in splits]

    #utc_offset = datetime.timedelta(hours = vals[7]) + \
    #             datetime.timedelta(minutes = vals[8])
    #utc_offset = utc_offset.total_seconds() / 60 #convert to minutes  

    return datetime.datetime(vals[0], vals[1], vals[2], vals[3], vals[4],
                             vals[5], vals[6] * 1000) 
                             #FixedOffset(utc_offset, "UTC"))?
