Fixed date/time comparisons.
This commit is contained in:
parent
95508d3495
commit
e7569f5edb
@ -762,25 +762,29 @@ void datetime::setZone(const int zone) { m_zone = zone; }
|
||||
|
||||
const bool datetime::operator==(const datetime& other) const
|
||||
{
|
||||
return (m_year == other.m_year &&
|
||||
m_month == other.m_month &&
|
||||
m_day == other.m_day &&
|
||||
m_hour == other.m_hour &&
|
||||
m_minute == other.m_minute &&
|
||||
m_second == other.m_second &&
|
||||
m_zone == other.m_zone);
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year == ut2.m_year &&
|
||||
ut1.m_month == ut2.m_month &&
|
||||
ut1.m_day == ut2.m_day &&
|
||||
ut1.m_hour == ut2.m_hour &&
|
||||
ut1.m_minute == ut2.m_minute &&
|
||||
ut1.m_second == ut2.m_second);
|
||||
}
|
||||
|
||||
|
||||
const bool datetime::operator!=(const datetime& other) const
|
||||
{
|
||||
return (m_year != other.m_year ||
|
||||
m_month != other.m_month ||
|
||||
m_day != other.m_day ||
|
||||
m_hour != other.m_hour ||
|
||||
m_minute != other.m_minute ||
|
||||
m_second != other.m_second ||
|
||||
m_zone != other.m_zone);
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year != ut2.m_year ||
|
||||
ut1.m_month != ut2.m_month ||
|
||||
ut1.m_day != ut2.m_day ||
|
||||
ut1.m_hour != ut2.m_hour ||
|
||||
ut1.m_minute != ut2.m_minute ||
|
||||
ut1.m_second != ut2.m_second);
|
||||
}
|
||||
|
||||
|
||||
@ -789,12 +793,12 @@ const bool datetime::operator<(const datetime& other) const
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year < ut2.m_year &&
|
||||
ut1.m_month < ut2.m_month &&
|
||||
ut1.m_day < ut2.m_day &&
|
||||
ut1.m_hour < ut2.m_hour &&
|
||||
ut1.m_minute < ut2.m_minute &&
|
||||
ut1.m_second < ut2.m_second);
|
||||
return ((ut1.m_year < ut2.m_year) ||
|
||||
(ut1.m_year == ut2.m_year && ut1.m_month < ut2.m_month) ||
|
||||
(ut1.m_month == ut2.m_month && ut1.m_day < ut2.m_day) ||
|
||||
(ut1.m_day == ut2.m_day && ut1.m_hour < ut2.m_hour) ||
|
||||
(ut1.m_hour == ut2.m_hour && ut1.m_minute < ut2.m_minute) ||
|
||||
(ut1.m_minute == ut2.m_minute && ut1.m_second < ut2.m_second));
|
||||
}
|
||||
|
||||
|
||||
@ -803,12 +807,12 @@ const bool datetime::operator<=(const datetime& other) const
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year <= ut2.m_year &&
|
||||
ut1.m_month <= ut2.m_month &&
|
||||
ut1.m_day <= ut2.m_day &&
|
||||
ut1.m_hour <= ut2.m_hour &&
|
||||
ut1.m_minute <= ut2.m_minute &&
|
||||
ut1.m_second <= ut2.m_second);
|
||||
return ((ut1.m_year < ut2.m_year) ||
|
||||
(ut1.m_year == ut2.m_year && ut1.m_month < ut2.m_month) ||
|
||||
(ut1.m_month == ut2.m_month && ut1.m_day < ut2.m_day) ||
|
||||
(ut1.m_day == ut2.m_day && ut1.m_hour < ut2.m_hour) ||
|
||||
(ut1.m_hour == ut2.m_hour && ut1.m_minute < ut2.m_minute) ||
|
||||
(ut1.m_minute == ut2.m_minute && ut1.m_second <= ut2.m_second));
|
||||
}
|
||||
|
||||
|
||||
@ -817,12 +821,12 @@ const bool datetime::operator>(const datetime& other) const
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year > ut2.m_year &&
|
||||
ut1.m_month > ut2.m_month &&
|
||||
ut1.m_day > ut2.m_day &&
|
||||
ut1.m_hour > ut2.m_hour &&
|
||||
ut1.m_minute > ut2.m_minute &&
|
||||
ut1.m_second > ut2.m_second);
|
||||
return ((ut1.m_year > ut2.m_year) ||
|
||||
(ut1.m_year == ut2.m_year && ut1.m_month > ut2.m_month) ||
|
||||
(ut1.m_month == ut2.m_month && ut1.m_day > ut2.m_day) ||
|
||||
(ut1.m_day == ut2.m_day && ut1.m_hour > ut2.m_hour) ||
|
||||
(ut1.m_hour == ut2.m_hour && ut1.m_minute > ut2.m_minute) ||
|
||||
(ut1.m_minute == ut2.m_minute && ut1.m_second > ut2.m_second));
|
||||
}
|
||||
|
||||
|
||||
@ -831,12 +835,12 @@ const bool datetime::operator>=(const datetime& other) const
|
||||
const datetime ut1 = utility::datetimeUtils::localTimeToUniversalTime(*this);
|
||||
const datetime ut2 = utility::datetimeUtils::localTimeToUniversalTime(other);
|
||||
|
||||
return (ut1.m_year >= ut2.m_year &&
|
||||
ut1.m_month >= ut2.m_month &&
|
||||
ut1.m_day >= ut2.m_day &&
|
||||
ut1.m_hour >= ut2.m_hour &&
|
||||
ut1.m_minute >= ut2.m_minute &&
|
||||
ut1.m_second >= ut2.m_second);
|
||||
return ((ut1.m_year > ut2.m_year) ||
|
||||
(ut1.m_year == ut2.m_year && ut1.m_month > ut2.m_month) ||
|
||||
(ut1.m_month == ut2.m_month && ut1.m_day > ut2.m_day) ||
|
||||
(ut1.m_day == ut2.m_day && ut1.m_hour > ut2.m_hour) ||
|
||||
(ut1.m_hour == ut2.m_hour && ut1.m_minute > ut2.m_minute) ||
|
||||
(ut1.m_minute == ut2.m_minute && ut1.m_second >= ut2.m_second));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user