blob: e0f1dd9532d9a3095e3e99a861a05d085bde1a70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
namespace Shiboken {
template <>
struct PythonConverter<QDate>
{
static bool isPythonConvertible(PyObject* pyObj)
{
if (!PyDateTimeAPI)
PyDateTime_IMPORT;
return pyObj && PyDate_Check(pyObj);
}
static QDate* transformFromPython(PyObject* obj)
{
if (isPythonConvertible(obj)) {
int day = PyDateTime_GET_DAY(obj);
int month = PyDateTime_GET_MONTH(obj);
int year = PyDateTime_GET_YEAR(obj);
return new QDate(year, month, day);
}
return 0;
}
static PyObject* transformToPython(QDate* d)
{
if (d) {
if (!PyDateTimeAPI)
PyDateTime_IMPORT;
return PyDate_FromDate(d->year(), d->month(), d->day());
}
return 0;
}
};
}
|