Commit aa7d849c authored by Tim Peters's avatar Tim Peters

timedelta comparison and datetime addition: as the Python implementation

of datetime does, accept instances of subclasses too.
parent 9914227c
...@@ -1666,7 +1666,7 @@ delta_richcompare(PyDateTime_Delta *self, PyObject *other, int op) ...@@ -1666,7 +1666,7 @@ delta_richcompare(PyDateTime_Delta *self, PyObject *other, int op)
{ {
int diff = 42; /* nonsense */ int diff = 42; /* nonsense */
if (PyDelta_CheckExact(other)) { if (PyDelta_Check(other)) {
diff = GET_TD_DAYS(self) - GET_TD_DAYS(other); diff = GET_TD_DAYS(self) - GET_TD_DAYS(other);
if (diff == 0) { if (diff == 0) {
diff = GET_TD_SECONDS(self) - GET_TD_SECONDS(other); diff = GET_TD_SECONDS(self) - GET_TD_SECONDS(other);
...@@ -2299,7 +2299,7 @@ date_add(PyObject *left, PyObject *right) ...@@ -2299,7 +2299,7 @@ date_add(PyObject *left, PyObject *right)
Py_INCREF(Py_NotImplemented); Py_INCREF(Py_NotImplemented);
return Py_NotImplemented; return Py_NotImplemented;
} }
if (PyDate_CheckExact(left)) { if (PyDate_Check(left)) {
/* date + ??? */ /* date + ??? */
if (PyDelta_Check(right)) if (PyDelta_Check(right))
/* date + delta */ /* date + delta */
...@@ -2328,8 +2328,8 @@ date_subtract(PyObject *left, PyObject *right) ...@@ -2328,8 +2328,8 @@ date_subtract(PyObject *left, PyObject *right)
Py_INCREF(Py_NotImplemented); Py_INCREF(Py_NotImplemented);
return Py_NotImplemented; return Py_NotImplemented;
} }
if (PyDate_CheckExact(left)) { if (PyDate_Check(left)) {
if (PyDate_CheckExact(right)) { if (PyDate_Check(right)) {
/* date - date */ /* date - date */
int left_ord = ymd_to_ord(GET_YEAR(left), int left_ord = ymd_to_ord(GET_YEAR(left),
GET_MONTH(left), GET_MONTH(left),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment