'Handles both Dates and DateTime objects'

def decode_datetime(self, value):

    if (value is None):
        return value
    try:
        if ('T' in value):
            if ('.' in value):
                return datetime.strptime(value.split('.')[0], '%Y-%m-%dT%H:%M:%S')
            else:
                return datetime.strptime(value, ISO8601)
        else:
            value = value.split('-')
            return date(int(value[0]), int(value[1]), int(value[2]))
    except Exception:
        return None
