QDateTime: Remove the distinction between null and invalid date and time

Change-Id: Id5480807d25e49e78b79ffff144a523e6851c03f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Thiago Macieira 2016-04-30 19:57:37 -07:00
parent f402b4886d
commit b491fab02a
2 changed files with 3 additions and 7 deletions

View File

@ -2546,15 +2546,13 @@ void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)
if (!useTime.isValid() && date.isValid())
useTime = QTime::fromMSecsSinceStartOfDay(0);
StatusFlags newStatus;
StatusFlags newStatus = 0;
// Set date value and status
qint64 days = 0;
if (date.isValid()) {
days = date.toJulianDay() - JULIAN_DAY_FOR_EPOCH;
newStatus = ValidDate;
} else if (date.isNull()) {
newStatus = NullDate;
}
// Set time value and status
@ -2562,8 +2560,6 @@ void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)
if (useTime.isValid()) {
ds = useTime.msecsSinceStartOfDay();
newStatus |= ValidTime;
} else if (time.isNull()) {
newStatus |= NullTime;
}
// Set msecs serial value

View File

@ -131,8 +131,8 @@ public:
void refreshDateTime();
// Get/set date and time status
inline bool isNullDate() const { return m_status & NullDate; }
inline bool isNullTime() const { return m_status & NullTime; }
inline bool isNullDate() const { return !(m_status & ValidDate); }
inline bool isNullTime() const { return !(m_status & ValidTime); }
inline bool isValidDate() const { return m_status & ValidDate; }
inline bool isValidTime() const { return m_status & ValidTime; }
inline bool isValidDateTime() const { return m_status & ValidDateTime; }