+inline wxDateSpan& wxDateSpan::operator-=(const wxDateSpan& other)
+{
+ return *this += other.Negate();
+}
+
+inline wxDateSpan& wxDateSpan::Subtract(const wxDateSpan& other)
+{
+ return *this -= other;
+}
+
+inline wxDateSpan wxDateSpan::Subtract(const wxDateSpan& other) const
+{
+ wxDateSpan ds(*this);
+ ds.Subtract(other);
+ return ds;
+}
+
+#undef MILLISECONDS_PER_DAY
+
+#undef MODIFY_AND_RETURN
+
+// ============================================================================
+// binary operators
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxDateTime operators
+// ----------------------------------------------------------------------------
+
+// arithmetics
+// -----------
+
+// no need to check for validity - the member functions we call will do it
+
+inline wxDateTime WXDLLIMPEXP_BASE operator+(const wxDateTime& dt,
+ const wxTimeSpan& ts)
+{
+ return dt.Add(ts);
+}
+
+inline wxDateTime WXDLLIMPEXP_BASE operator-(const wxDateTime& dt,
+ const wxTimeSpan& ts)
+{
+ return dt.Subtract(ts);
+}
+
+inline wxDateTime WXDLLIMPEXP_BASE operator+(const wxDateTime& dt,
+ const wxDateSpan& ds)
+{
+ return dt.Add(ds);
+}
+
+inline wxDateTime WXDLLIMPEXP_BASE operator-(const wxDateTime& dt,
+ const wxDateSpan& ds)
+{
+ return dt.Subtract(ds);
+}
+
+inline wxTimeSpan WXDLLIMPEXP_BASE operator-(const wxDateTime& dt1,
+ const wxDateTime& dt2)
+{
+ return dt1.Subtract(dt2);
+}
+
+// comparison
+// ----------
+
+inline bool WXDLLIMPEXP_BASE operator<(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() < t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator<=(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() <= t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator>(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() > t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator>=(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() >= t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator==(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() == t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator!=(const wxDateTime& t1, const wxDateTime& t2)
+{
+ wxASSERT_MSG( t1.IsValid() && t2.IsValid(), _T("invalid wxDateTime") );
+
+ return t1.GetValue() != t2.GetValue();
+}
+
+// ----------------------------------------------------------------------------
+// wxTimeSpan operators
+// ----------------------------------------------------------------------------
+
+// arithmetics
+// -----------
+
+inline wxTimeSpan WXDLLIMPEXP_BASE operator+(const wxTimeSpan& ts1,
+ const wxTimeSpan& ts2)
+{
+ return wxTimeSpan(ts1.GetValue() + ts2.GetValue());
+}
+
+inline wxTimeSpan WXDLLIMPEXP_BASE operator-(const wxTimeSpan& ts1,
+ const wxTimeSpan& ts2)
+{
+ return wxTimeSpan(ts1.GetValue() - ts2.GetValue());
+}
+
+inline wxTimeSpan WXDLLIMPEXP_BASE operator*(const wxTimeSpan& ts, int n)
+{
+ return wxTimeSpan(ts).Multiply(n);
+}
+
+inline wxTimeSpan WXDLLIMPEXP_BASE operator*(int n, const wxTimeSpan& ts)
+{
+ return wxTimeSpan(ts).Multiply(n);
+}
+
+// comparison
+// ----------
+
+inline bool WXDLLIMPEXP_BASE operator<(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() < t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator<=(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() <= t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator>(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() > t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator>=(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() >= t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator==(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() == t2.GetValue();
+}
+
+inline bool WXDLLIMPEXP_BASE operator!=(const wxTimeSpan &t1, const wxTimeSpan &t2)
+{
+ return t1.GetValue() != t2.GetValue();
+}
+
+// ----------------------------------------------------------------------------
+// wxDateSpan
+// ----------------------------------------------------------------------------
+
+// comparison
+// ----------
+
+// ds1 == d2 if and only if for every wxDateTime t t + ds1 == t + ds2
+inline WXDLLIMPEXP_BASE bool operator==(const wxDateSpan& ds1,
+ const wxDateSpan& ds2)
+{
+ return ds1.GetYears() == ds2.GetYears() &&
+ ds1.GetMonths() == ds2.GetMonths() &&
+ ds1.GetTotalDays() == ds2.GetTotalDays();
+}
+
+inline WXDLLIMPEXP_BASE bool operator!=(const wxDateSpan& ds1,
+ const wxDateSpan& ds2)
+{
+ return !(ds1 == ds2);
+}
+
+// arithmetics
+// -----------
+
+inline WXDLLIMPEXP_BASE wxDateSpan operator+(const wxDateSpan& ds1,
+ const wxDateSpan& ds2)
+{
+ return wxDateSpan(ds1.GetYears() + ds2.GetYears(),
+ ds1.GetMonths() + ds2.GetMonths(),
+ ds1.GetWeeks() + ds2.GetWeeks(),
+ ds1.GetDays() + ds2.GetDays());
+}
+
+inline WXDLLIMPEXP_BASE wxDateSpan operator-(const wxDateSpan& ds1,
+ const wxDateSpan& ds2)
+{
+ return wxDateSpan(ds1.GetYears() - ds2.GetYears(),
+ ds1.GetMonths() - ds2.GetMonths(),
+ ds1.GetWeeks() - ds2.GetWeeks(),
+ ds1.GetDays() - ds2.GetDays());
+}
+
+inline WXDLLIMPEXP_BASE wxDateSpan operator*(const wxDateSpan& ds, int n)
+{
+ return wxDateSpan(ds).Multiply(n);
+}
+
+inline WXDLLIMPEXP_BASE wxDateSpan operator*(int n, const wxDateSpan& ds)
+{
+ return wxDateSpan(ds).Multiply(n);
+}
+
+// ============================================================================
+// other helper functions
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// iteration helpers: can be used to write a for loop over enum variable like
+// this:
+// for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) )
+// ----------------------------------------------------------------------------
+
+inline WXDLLIMPEXP_BASE void wxNextMonth(wxDateTime::Month& m)
+{
+ wxASSERT_MSG( m < wxDateTime::Inv_Month, _T("invalid month") );
+
+ // no wrapping or the for loop above would never end!
+ m = (wxDateTime::Month)(m + 1);
+}
+
+inline WXDLLIMPEXP_BASE void wxPrevMonth(wxDateTime::Month& m)
+{
+ wxASSERT_MSG( m < wxDateTime::Inv_Month, _T("invalid month") );
+
+ m = m == wxDateTime::Jan ? wxDateTime::Inv_Month
+ : (wxDateTime::Month)(m - 1);
+}
+
+inline WXDLLIMPEXP_BASE void wxNextWDay(wxDateTime::WeekDay& wd)
+{
+ wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, _T("invalid week day") );
+
+ // no wrapping or the for loop above would never end!
+ wd = (wxDateTime::WeekDay)(wd + 1);
+}
+
+inline WXDLLIMPEXP_BASE void wxPrevWDay(wxDateTime::WeekDay& wd)
+{
+ wxASSERT_MSG( wd < wxDateTime::Inv_WeekDay, _T("invalid week day") );
+
+ wd = wd == wxDateTime::Sun ? wxDateTime::Inv_WeekDay
+ : (wxDateTime::WeekDay)(wd - 1);
+}
+
+#endif // wxUSE_DATETIME
+
+#endif // _WX_DATETIME_H