// qdatetime.sip generated by MetaSIP on Fri Sep 28 17:07:47 2007 // // This file is part of the QtCore Python extension module. // // Copyright (c) 2007 // Phil Thompson // // This file is part of PyQt. // // This copy of PyQt is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License version 2 as published by // the Free Software Foundation and appearing in the file LICENSE included in the // packaging of this file. // // PyQt is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // PyQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %ModuleCode #include %End class QDate { %TypeHeaderCode #include %End %TypeCode #if PY_VERSION_HEX >= 0x02040000 #include #endif %End %ConvertToTypeCode #if PY_VERSION_HEX >= 0x02040000 if (!PyDateTimeAPI) PyDateTime_IMPORT; #endif // Allow a Python date object whenever a QDate is expected. if (sipIsErr == NULL) return ( #if PY_VERSION_HEX >= 0x02040000 PyDate_Check(sipPy) || #endif sipCanConvertToInstance(sipPy, sipClass_QDate, SIP_NO_CONVERTORS)); #if PY_VERSION_HEX >= 0x02040000 if (PyDate_Check(sipPy)) { *sipCppPtr = new QDate(PyDateTime_GET_YEAR(sipPy), PyDateTime_GET_MONTH(sipPy), PyDateTime_GET_DAY(sipPy)); return sipGetState(sipTransferObj); } #endif *sipCppPtr = reinterpret_cast(sipConvertToInstance(sipPy, sipClass_QDate, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); return 0; %End %PickleCode sipRes = Py_BuildValue((char *)"iii", sipCpp->year(), sipCpp->month(), sipCpp->day()); %End public: QDate(); QDate(int y, int m, int d); %If (Py_DateTime) SIP_PYOBJECT toPyDate() const; %MethodCode if (!PyDateTimeAPI) PyDateTime_IMPORT; // Convert to a Python date object. sipRes = PyDate_FromDate(sipCpp->year(), sipCpp->month(), sipCpp->day()); %End %End bool isNull() const; int __nonzero__() const; %MethodCode sipRes = !sipCpp->isNull(); %End bool isValid() const; int year() const; int month() const; int day() const; int dayOfWeek() const; int dayOfYear() const; int daysInMonth() const; int daysInYear() const; int weekNumber(int *yearNum = 0) const; static QString shortMonthName(int month); static QString shortDayName(int weekday); static QString longMonthName(int month); static QString longDayName(int weekday); QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; bool setYMD(int y, int m, int d); QDate addDays(int days) const; QDate addMonths(int months) const; QDate addYears(int years) const; int daysTo(const QDate &) const; bool operator==(const QDate &other) const; bool operator!=(const QDate &other) const; bool operator<(const QDate &other) const; bool operator<=(const QDate &other) const; bool operator>(const QDate &other) const; bool operator>=(const QDate &other) const; static QDate currentDate(); static QDate fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); static QDate fromString(const QString &s, const QString &format); static bool isValid(int y, int m, int d); static bool isLeapYear(int year); static uint gregorianToJulian(int y, int m, int d); static void julianToGregorian(uint jd, int &y, int &m, int &d); static QDate fromJulianDay(int jd); int toJulianDay() const; %If (Qt_4_2_0 -) bool setDate(int year, int month, int date); %End }; class QTime { %TypeHeaderCode #include %End %TypeCode #if PY_VERSION_HEX >= 0x02040000 #include #endif %End %ConvertToTypeCode #if PY_VERSION_HEX >= 0x02040000 if (!PyDateTimeAPI) PyDateTime_IMPORT; #endif // Allow a Python time object whenever a QTime is expected. if (sipIsErr == NULL) return ( #if PY_VERSION_HEX >= 0x02040000 PyTime_Check(sipPy) || #endif sipCanConvertToInstance(sipPy, sipClass_QTime, SIP_NO_CONVERTORS)); #if PY_VERSION_HEX >= 0x02040000 if (PyTime_Check(sipPy)) { *sipCppPtr = new QTime(PyDateTime_TIME_GET_HOUR(sipPy), PyDateTime_TIME_GET_MINUTE(sipPy), PyDateTime_TIME_GET_SECOND(sipPy), PyDateTime_TIME_GET_MICROSECOND(sipPy) / 1000); return sipGetState(sipTransferObj); } #endif *sipCppPtr = reinterpret_cast(sipConvertToInstance(sipPy, sipClass_QTime, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); return 0; %End %PickleCode sipRes = Py_BuildValue((char *)"iiii", sipCpp->hour(), sipCpp->minute(), sipCpp->second(), sipCpp->msec()); %End public: QTime(); QTime(int h, int m, int s = 0, int ms = 0); %If (Py_DateTime) SIP_PYOBJECT toPyTime() const; %MethodCode if (!PyDateTimeAPI) PyDateTime_IMPORT; // Convert to a Python time object. sipRes = PyTime_FromTime(sipCpp->hour(), sipCpp->minute(), sipCpp->second(), sipCpp->msec() * 1000); %End %End bool isNull() const; int __nonzero__() const; %MethodCode sipRes = !sipCpp->isNull(); %End bool isValid() const; int hour() const; int minute() const; int second() const; int msec() const; QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; bool setHMS(int h, int m, int s, int ms = 0); QTime addSecs(int secs) const; int secsTo(const QTime &) const; QTime addMSecs(int ms) const; int msecsTo(const QTime &) const; bool operator==(const QTime &other) const; bool operator!=(const QTime &other) const; bool operator<(const QTime &other) const; bool operator<=(const QTime &other) const; bool operator>(const QTime &other) const; bool operator>=(const QTime &other) const; static QTime currentTime(); static QTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); static QTime fromString(const QString &s, const QString &format); static bool isValid(int h, int m, int s, int ms = 0); void start(); int restart(); int elapsed() const; }; class QDateTime { %TypeHeaderCode #include %End %TypeCode #if PY_VERSION_HEX >= 0x02040000 #include #endif %End %ConvertToTypeCode #if PY_VERSION_HEX >= 0x02040000 if (!PyDateTimeAPI) PyDateTime_IMPORT; #endif // Allow a Python datetime object whenever a QDateTime is expected. if (sipIsErr == NULL) return ( #if PY_VERSION_HEX >= 0x02040000 PyDateTime_Check(sipPy) || #endif sipCanConvertToInstance(sipPy, sipClass_QDateTime, SIP_NO_CONVERTORS)); #if PY_VERSION_HEX >= 0x02040000 if (PyDateTime_Check(sipPy)) { QDate qdate(PyDateTime_GET_YEAR(sipPy), PyDateTime_GET_MONTH(sipPy), PyDateTime_GET_DAY(sipPy)); QTime qtime(PyDateTime_DATE_GET_HOUR(sipPy), PyDateTime_DATE_GET_MINUTE(sipPy), PyDateTime_DATE_GET_SECOND(sipPy), PyDateTime_DATE_GET_MICROSECOND(sipPy) / 1000); QDateTime *qdt = new QDateTime(qdate, qtime); *sipCppPtr = qdt; return sipGetState(sipTransferObj); } #endif *sipCppPtr = reinterpret_cast(sipConvertToInstance(sipPy, sipClass_QDateTime, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); return 0; %End %PickleCode QDate qd = sipCpp->date(); QTime qt = sipCpp->time(); sipRes = Py_BuildValue((char *)"iiiiiii", qd.year(), qd.month(), qd.day(), qt.hour(), qt.minute(), qt.second(), qt.msec()); %End public: QDateTime(); QDateTime(const QDateTime &other); explicit QDateTime(const QDate &); QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime); QDateTime(int y, int m, int d, int h, int m, int s = 0, int ms = 0) /NoDerived/; %MethodCode // This ctor is mainly supplied to allow pickling. QDate qd(a0, a1, a2); QTime qt(a3, a4, a5, a6); sipCpp = new QDateTime(qd, qt); %End ~QDateTime(); %If (Py_DateTime) SIP_PYOBJECT toPyDateTime() const; %MethodCode if (!PyDateTimeAPI) PyDateTime_IMPORT; // Convert to a Python datetime object. QDate qd = sipCpp->date(); QTime qt = sipCpp->time(); sipRes = PyDateTime_FromDateAndTime(qd.year(), qd.month(), qd.day(), qt.hour(), qt.minute(), qt.second(), qt.msec() * 1000); %End %End bool isNull() const; int __nonzero__() const; %MethodCode sipRes = !sipCpp->isNull(); %End bool isValid() const; QDate date() const; QTime time() const; Qt::TimeSpec timeSpec() const; uint toTime_t() const; void setDate(const QDate &date); void setTime(const QTime &time); void setTimeSpec(Qt::TimeSpec spec); void setTime_t(uint secsSince1Jan1970UTC); QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; QDateTime addDays(int days) const; QDateTime addMonths(int months) const; QDateTime addYears(int years) const; QDateTime addSecs(int secs) const; QDateTime addMSecs(qint64 msecs) const; QDateTime toTimeSpec(Qt::TimeSpec spec) const; QDateTime toLocalTime() const; QDateTime toUTC() const; int daysTo(const QDateTime &) const; int secsTo(const QDateTime &) const; bool operator==(const QDateTime &other) const; bool operator!=(const QDateTime &other) const; bool operator<(const QDateTime &other) const; bool operator<=(const QDateTime &other) const; bool operator>(const QDateTime &other) const; bool operator>=(const QDateTime &other) const; static QDateTime currentDateTime(); static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate); static QDateTime fromString(const QString &s, const QString &format); %If (Qt_4_2_0 -) static QDateTime fromTime_t(uint secsSince1Jan1970UTC); %End }; QDataStream &operator<<(QDataStream &, const QDate & /Constrained/); QDataStream &operator>>(QDataStream &, QDate & /Constrained/); QDataStream &operator<<(QDataStream &, const QTime & /Constrained/); QDataStream &operator>>(QDataStream &, QTime & /Constrained/); QDataStream &operator<<(QDataStream &, const QDateTime & /Constrained/); QDataStream &operator>>(QDataStream &, QDateTime & /Constrained/);