def line2date(line, dlconfig):
    """
    Gets a date from a line of file according to dataloggerConfig object.

    Parameters
    ----------
    line: string
        line of file with date inside
    dlconfig: pymicra.dataloggerConfig
        configuration of the datalogger

    Returns
    -------
    timestamp: datetime object
    """
    import datetime as dt
    import numpy as np
    import re
    connector = dlconfig.date_connector
    date_col_names = dlconfig.date_col_names
    date_cols = dlconfig.date_cols
    sep = dlconfig.columns_separator
    datefmt = connector.join(date_col_names)
    if sep == 'whitespace':
        sep = '\\s*'
    line = np.array(re.split(sep, line.strip()))
    s = connector.join(line[date_cols])
    return dt.datetime.strptime(s, datefmt)
