From 56aa94c61e1cb47271aa02c5be99b7945a7010ea Mon Sep 17 00:00:00 2001 From: "Kevin B. McCarty" Date: Sat, 9 May 2015 19:28:04 +0200 Subject: [PATCH] Allow using wxDateTime::operator==() and !=() with invalid objects Unlike the other operators, we comparing for equality has a well-defined semantics even for invalid objects, so there doesn't seem any reason to not allow it. --- include/wx/datetime.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 6375f06a1a..c3cedad7a4 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -836,12 +836,15 @@ public: inline bool operator==(const wxDateTime& dt) const { - return GetValue() == dt.GetValue(); + // Intentionally do not call GetValue() here, in order that + // invalid wxDateTimes may be compared for equality + return m_time == dt.m_time; } inline bool operator!=(const wxDateTime& dt) const { - return GetValue() != dt.GetValue(); + // As above, don't use GetValue() here. + return m_time != dt.m_time; } // arithmetics with dates (see also below for more operators)