Make QDateTime's operators hidden friends
Update docs to match. Change-Id: I0ece9bcdba69c5dca48743894fe3347d9666f4e4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
c81893907e
commit
4398836817
|
|
@ -4434,16 +4434,14 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
|
|||
#endif // timezone
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Returns \c true if this datetime is equal to the \a other datetime;
|
||||
otherwise returns \c false.
|
||||
|
||||
Since 5.14, all invalid datetimes are equal to one another and differ from
|
||||
all other datetimes.
|
||||
|
||||
\sa operator!=()
|
||||
\sa precedes(), operator==()
|
||||
*/
|
||||
|
||||
bool QDateTime::operator==(const QDateTime &other) const
|
||||
bool QDateTime::equals(const QDateTime &other) const
|
||||
{
|
||||
if (!isValid())
|
||||
return !other.isValid();
|
||||
|
|
@ -4458,24 +4456,39 @@ bool QDateTime::operator==(const QDateTime &other) const
|
|||
}
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator!=(const QDateTime &other) const
|
||||
\fn bool QDateTime::operator==(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if this datetime is different from the \a other
|
||||
datetime; otherwise returns \c false.
|
||||
Returns \c true if \a lhs is the same as \a rhs; otherwise returns \c false.
|
||||
|
||||
Two datetimes are different if either the date, the time, or the time zone
|
||||
components are different. Since 5.14, any invalid datetime is less than all
|
||||
valid datetimes.
|
||||
components are different. Since 5.14, all invalid datetime are equal (and
|
||||
less than all valid datetimes).
|
||||
|
||||
\sa operator!=(), operator<(), operator<=(), operator>(), operator>=()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator!=(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if \a lhs is different from \a rhs; otherwise returns \c
|
||||
false.
|
||||
|
||||
Two datetimes are different if either the date, the time, or the time zone
|
||||
components are different. Since 5.14, all invalid datetime are equal (and
|
||||
less than all valid datetimes).
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns \c true if this datetime is earlier than the \a other
|
||||
\internal
|
||||
Returns \c true if \a lhs is earlier than the \a rhs
|
||||
datetime; otherwise returns \c false.
|
||||
|
||||
\sa equals(), operator<()
|
||||
*/
|
||||
|
||||
bool QDateTime::operator<(const QDateTime &other) const
|
||||
bool QDateTime::precedes(const QDateTime &other) const
|
||||
{
|
||||
if (!isValid())
|
||||
return other.isValid();
|
||||
|
|
@ -4490,24 +4503,38 @@ bool QDateTime::operator<(const QDateTime &other) const
|
|||
}
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator<=(const QDateTime &other) const
|
||||
\fn bool QDateTime::operator<(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if this datetime is earlier than or equal to the
|
||||
\a other datetime; otherwise returns \c false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator>(const QDateTime &other) const
|
||||
|
||||
Returns \c true if this datetime is later than the \a other datetime;
|
||||
Returns \c true if \a lhs is earlier than \a rhs;
|
||||
otherwise returns \c false.
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator>=(const QDateTime &other) const
|
||||
\fn bool QDateTime::operator<=(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if this datetime is later than or equal to the
|
||||
\a other datetime; otherwise returns \c false.
|
||||
Returns \c true if \a lhs is earlier than or equal to \a rhs; otherwise
|
||||
returns \c false.
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator>(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if \a lhs is later than \a rhs; otherwise returns \c false.
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDateTime::operator>=(const QDateTime &lhs, const QDateTime &rhs)
|
||||
|
||||
Returns \c true if \a lhs is later than or equal to \a rhs;
|
||||
otherwise returns \c false.
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -340,13 +340,6 @@ public:
|
|||
qint64 secsTo(const QDateTime &) const;
|
||||
qint64 msecsTo(const QDateTime &) const;
|
||||
|
||||
bool operator==(const QDateTime &other) const;
|
||||
inline bool operator!=(const QDateTime &other) const { return !(*this == other); }
|
||||
bool operator<(const QDateTime &other) const;
|
||||
inline bool operator<=(const QDateTime &other) const { return !(other < *this); }
|
||||
inline bool operator>(const QDateTime &other) const { return other < *this; }
|
||||
inline bool operator>=(const QDateTime &other) const { return !(*this < other); }
|
||||
|
||||
static QDateTime currentDateTime();
|
||||
static QDateTime currentDateTimeUtc();
|
||||
#if QT_CONFIG(datestring)
|
||||
|
|
@ -390,10 +383,19 @@ public:
|
|||
enum class YearRange : qint32 { First = -292275056, Last = +292278994 };
|
||||
|
||||
private:
|
||||
bool equals(const QDateTime &other) const;
|
||||
bool precedes(const QDateTime &other) const;
|
||||
friend class QDateTimePrivate;
|
||||
|
||||
Data d;
|
||||
|
||||
friend bool operator==(const QDateTime &lhs, const QDateTime &rhs) { return lhs.equals(rhs); }
|
||||
friend bool operator!=(const QDateTime &lhs, const QDateTime &rhs) { return !(lhs == rhs); }
|
||||
friend bool operator<(const QDateTime &lhs, const QDateTime &rhs) { return lhs.precedes(rhs); }
|
||||
friend bool operator<=(const QDateTime &lhs, const QDateTime &rhs) { return !(rhs < lhs); }
|
||||
friend bool operator>(const QDateTime &lhs, const QDateTime &rhs) { return rhs.precedes(lhs); }
|
||||
friend bool operator>=(const QDateTime &lhs, const QDateTime &rhs) { return !(lhs < rhs); }
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
|
||||
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
|
||||
|
|
|
|||
Loading…
Reference in New Issue