Skip to content

Commit 286a284

Browse files
committed
timedelta_total_seconds()
1 parent 23bf9b4 commit 286a284

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Modules/_datetimemodule.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,10 +2852,21 @@ _delta_total_seconds(datetime_state *st, PyObject *self)
28522852
return total_seconds;
28532853
}
28542854

2855+
/*[clinic input]
2856+
datetime.timedelta.total_seconds
2857+
2858+
self: self(type="PyObject *")
2859+
defcls: defining_class
2860+
/
2861+
2862+
Total seconds in the duration.
2863+
[clinic start generated code]*/
2864+
28552865
static PyObject *
2856-
delta_total_seconds(PyObject *self, PyObject *Py_UNUSED(ignored))
2866+
datetime_timedelta_total_seconds_impl(PyObject *self, PyTypeObject *defcls)
2867+
/*[clinic end generated code: output=d702744694267dbf input=324f72e0d662f3b3]*/
28572868
{
2858-
datetime_state *st = find_module_state_by_def(Py_TYPE(self));
2869+
datetime_state *st = get_module_state_by_cls(defcls);
28592870
return _delta_total_seconds(st, self);
28602871
}
28612872

@@ -2897,8 +2908,7 @@ static PyMemberDef delta_members[] = {
28972908
};
28982909

28992910
static PyMethodDef delta_methods[] = {
2900-
{"total_seconds", delta_total_seconds, METH_NOARGS,
2901-
PyDoc_STR("Total seconds in the duration.")},
2911+
DATETIME_TIMEDELTA_TOTAL_SECONDS_METHODDEF
29022912

29032913
{"__reduce__", (PyCFunction)delta_reduce, METH_NOARGS,
29042914
PyDoc_STR("__reduce__() -> (cls, state)")},

0 commit comments

Comments
 (0)