'Decode datetime value from string to datetime'

def dict_to_object(self, d):

    for (k, v) in list(d.items()):
        if (isinstance(v, six.string_types) and (len(v) == 19)):
            try:
                d[k] = datetime.strptime(v, '%Y-%m-%dT%H:%M:%S')
            except ValueError:
                pass
        elif (isinstance(v, six.string_types) and (len(v) > 20)):
            try:
                d[k] = datetime.strptime(v, '%Y-%m-%dT%H:%M:%S.%f')
            except ValueError:
                pass
        elif isinstance(v, list):
            d[k] = [self.string_to_datetime(elem) for elem in v]
    return DotDict(d)
