def string_to_datetime(self, obj):
        """
        Decode a datetime string to a datetime object
        """
        if isinstance(obj, six.string_types) and len(obj) == 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) > 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S.%f")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) == 10:
            try:
                return datetime.strptime(obj, "%Y-%m-%d")
            except ValueError:
                pass
        return obj
def string_to_datetime ( self , obj ) : if isinstance ( obj , six . string_types ) and len ( obj ) == 19 : try : return datetime . strptime ( obj , "%Y-%m-%dT%H:%M:%S" ) except ValueError : pass if isinstance ( obj , six . string_types ) and len ( obj ) > 19 : try : return datetime . strptime ( obj , "%Y-%m-%dT%H:%M:%S.%f" ) except ValueError : pass if isinstance ( obj , six . string_types ) and len ( obj ) == 10 : try : return datetime . strptime ( obj , "%Y-%m-%d" ) except ValueError : pass return obj
Decode a datetime string to a datetime object