0

I have two objects:

#include <datetime.h>
#include <Python.h>
....
PyObject *first_date = PyDate_FromDate(2022, 08, 31);
PyObject *time_delta = PyDelta_FromDSU(2, 0, 0);

How can i subtract time_delta from first_date? As i found, there is https://github.com/python/cpython/blob/main/Modules/_datetimemodule.c with methods i need but i can not import it from my main file

1 Answers1

1
PyObject* Date = PyDate_FromDate(year, month, day);
PyObject* TimeDelta = PyDelta_FromDSU(days, seconds, microseconds);

PyObject* result = PyNumber_Add(Date, TimeDelta);

You should do like these...

vatsal mangukiya
  • 261
  • 2
  • 14