+ 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
+// ----------------------------------------------------------------------------
+
+inline wxDateTime
+wxDateTime::ToTimezone(const wxDateTime::TimeZone& tz, bool noDST) const
+{
+ MODIFY_AND_RETURN( MakeTimezone(tz, noDST) );
+}
+
+#if wxABI_VERSION >= 20602
+
+inline wxDateTime
+wxDateTime::FromTimezone(const wxDateTime::TimeZone& tz, bool noDST) const
+{
+ MODIFY_AND_RETURN( MakeFromTimezone(tz, noDST) );
+}
+
+#endif // ABI >= 2.6.2
+
+// ----------------------------------------------------------------------------
+// wxTimeSpan construction
+// ----------------------------------------------------------------------------
+
+inline wxTimeSpan::wxTimeSpan(long hours,
+ long minutes,
+ long seconds,
+ long milliseconds)
+{
+ // assign first to avoid precision loss
+ m_diff = hours;
+ m_diff *= 60l;
+ m_diff += minutes;
+ m_diff *= 60l;
+ m_diff += seconds;
+ m_diff *= 1000l;
+ m_diff += milliseconds;
+}
+
+// ----------------------------------------------------------------------------
+// wxTimeSpan accessors
+// ----------------------------------------------------------------------------
+
+inline wxLongLong wxTimeSpan::GetSeconds() const
+{
+ return m_diff / 1000l;
+}
+
+inline int wxTimeSpan::GetMinutes() const
+{
+ return (GetSeconds() / 60l).GetLo();
+}
+
+inline int wxTimeSpan::GetHours() const
+{
+ return GetMinutes() / 60;
+}
+
+inline int wxTimeSpan::GetDays() const
+{
+ return GetHours() / 24;
+}
+
+inline int wxTimeSpan::GetWeeks() const
+{
+ return GetDays() / 7;
+}
+
+// ----------------------------------------------------------------------------
+// wxTimeSpan arithmetics
+// ----------------------------------------------------------------------------
+
+inline wxTimeSpan wxTimeSpan::Add(const wxTimeSpan& diff) const
+{
+ return wxTimeSpan(m_diff + diff.GetValue());
+}
+
+inline wxTimeSpan& wxTimeSpan::Add(const wxTimeSpan& diff)
+{
+ m_diff += diff.GetValue();
+
+ return *this;
+}
+
+inline wxTimeSpan wxTimeSpan::Subtract(const wxTimeSpan& diff) const
+{
+ return wxTimeSpan(m_diff - diff.GetValue());
+}
+
+inline wxTimeSpan& wxTimeSpan::Subtract(const wxTimeSpan& diff)
+{
+ m_diff -= diff.GetValue();
+
+ return *this;
+}
+
+inline wxTimeSpan& wxTimeSpan::Multiply(int n)
+{
+ m_diff *= (long)n;
+
+ return *this;
+}
+
+inline wxTimeSpan wxTimeSpan::Multiply(int n) const
+{
+ return wxTimeSpan(m_diff * (long)n);
+}
+
+inline wxTimeSpan wxTimeSpan::Abs() const
+{
+ return wxTimeSpan(GetValue().Abs());
+}
+
+inline bool wxTimeSpan::IsEqualTo(const wxTimeSpan& ts) const
+{
+ return GetValue() == ts.GetValue();
+}
+
+inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const
+{
+ return GetValue().Abs() > ts.GetValue().Abs();