+// wxDateTime comparison
+// ----------------------------------------------------------------------------
+
+inline bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const
+{
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+
+ return m_time == datetime.m_time;
+}
+
+inline bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const
+{
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+
+ return m_time < datetime.m_time;
+}
+
+inline bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const
+{
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+
+ return m_time > datetime.m_time;
+}
+
+inline bool wxDateTime::IsStrictlyBetween(const wxDateTime& t1,
+ const wxDateTime& t2) const
+{
+ // no need for assert, will be checked by the functions we call
+ return IsLaterThan(t1) && IsEarlierThan(t2);
+}
+
+inline bool wxDateTime::IsBetween(const wxDateTime& t1,
+ const wxDateTime& t2) const
+{
+ // no need for assert, will be checked by the functions we call
+ return IsEqualTo(t1) || IsEqualTo(t2) || IsStrictlyBetween(t1, t2);
+}
+
+inline bool wxDateTime::IsSameDate(const wxDateTime& dt) const
+{
+ Tm tm1 = GetTm(),
+ tm2 = dt.GetTm();
+
+ return tm1.year == tm2.year &&
+ tm1.mon == tm2.mon &&
+ tm1.mday == tm2.mday;
+}
+
+inline bool wxDateTime::IsSameTime(const wxDateTime& dt) const
+{
+ // notice that we can't do something like this:
+ //
+ // m_time % MILLISECONDS_PER_DAY == dt.m_time % MILLISECONDS_PER_DAY
+ //
+ // because we have also to deal with (possibly) different DST settings!
+ Tm tm1 = GetTm(),
+ tm2 = dt.GetTm();
+
+ return tm1.hour == tm2.hour &&
+ tm1.min == tm2.min &&
+ tm1.sec == tm2.sec &&
+ tm1.msec == tm2.msec;
+}
+
+inline bool wxDateTime::IsEqualUpTo(const wxDateTime& dt,
+ const wxTimeSpan& ts) const
+{
+ return IsBetween(dt.Subtract(ts), dt.Add(ts));
+}
+
+// ----------------------------------------------------------------------------
+// wxDateTime arithmetics
+// ----------------------------------------------------------------------------
+
+inline wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const
+{
+ wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+
+ return wxDateTime(m_time + diff.GetValue());
+}
+
+inline wxDateTime& wxDateTime::Add(const wxTimeSpan& diff)
+{
+ wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+
+ m_time += diff.GetValue();
+
+ return *this;
+}
+
+inline wxDateTime& wxDateTime::operator+=(const wxTimeSpan& diff)
+{
+ return Add(diff);
+}
+
+inline wxDateTime wxDateTime::Subtract(const wxTimeSpan& diff) const
+{
+ wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+
+ return wxDateTime(m_time - diff.GetValue());
+}
+
+inline wxDateTime& wxDateTime::Subtract(const wxTimeSpan& diff)
+{
+ wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+
+ m_time -= diff.GetValue();
+
+ return *this;
+}
+
+inline wxDateTime& wxDateTime::operator-=(const wxTimeSpan& diff)
+{
+ return Subtract(diff);
+}
+
+inline wxTimeSpan wxDateTime::Subtract(const wxDateTime& datetime) const
+{
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+
+ return wxTimeSpan(GetValue() - datetime.GetValue());
+}
+
+inline wxTimeSpan wxDateTime::operator-(const wxDateTime& dt2) const
+{
+ return this->Subtract(dt2);
+}
+
+inline wxDateTime wxDateTime::Add(const wxDateSpan& diff) const
+{
+ return wxDateTime(*this).Add(diff);
+}
+
+inline wxDateTime& wxDateTime::Subtract(const wxDateSpan& diff)
+{
+ return Add(diff.Negate());
+}
+
+inline wxDateTime wxDateTime::Subtract(const wxDateSpan& diff) const
+{
+ return wxDateTime(*this).Subtract(diff);
+}
+
+inline wxDateTime& wxDateTime::operator-=(const wxDateSpan& diff)
+{
+ return Subtract(diff);
+}
+
+inline wxDateTime& wxDateTime::operator+=(const wxDateSpan& diff)
+{
+ return Add(diff);
+}
+
+// ----------------------------------------------------------------------------
+// wxDateTime and timezones