Return a datetime object if the string value represents one

    Epoch integer or an ISO 8601 compatible string is
    supported.

    :param val: str
    :return: datetime
    :raise: ValueError

def str_to_dt(val):
    """ Return a datetime object if the string value represents one

    Epoch integer or an ISO 8601 compatible string is
    supported.

    :param val: str
    :return: datetime
    :raise: ValueError
    """

    if isinstance(val, dt):
        return val

    try:
        if val.isdigit():
            return dt.utcfromtimestamp(float(val))
        else:
            return dt.strptime(val, '%Y-%m-%dT%H:%M:%S.%f')
    except (AttributeError, TypeError):
        raise ValueError