%{
#include <wx/datetime.h>
-
%}
-MAKE_CONST_WXSTRING2(DateFormatStr, wxT("%c"));
-MAKE_CONST_WXSTRING2(TimeSpanFormatStr, wxT("%H:%M:%S"));
+
+MAKE_CONST_WXSTRING(DefaultDateTimeFormat);
+MAKE_CONST_WXSTRING(DefaultTimeSpanFormat);
//---------------------------------------------------------------------------
inline wxDateTime& operator-=(const wxDateSpan& diff);
+// inline bool operator<(const wxDateTime& dt) const;
+// inline bool operator<=(const wxDateTime& dt) const;
+// inline bool operator>(const wxDateTime& dt) const;
+// inline bool operator>=(const wxDateTime& dt) const;
+// inline bool operator==(const wxDateTime& dt) const;
+// inline bool operator!=(const wxDateTime& dt) const;
+
%nokwargs __add__;
%nokwargs __sub__;
- %nokwargs __lt__;
- %nokwargs __le__;
- %nokwargs __gt__;
- %nokwargs __ge__;
- %nokwargs __eq__;
- %nokwargs __ne__;
%extend {
wxDateTime __add__(const wxTimeSpan& other) { return *self + other; }
wxDateTime __add__(const wxDateSpan& other) { return *self + other; }
wxDateTime __sub__(const wxTimeSpan& other) { return *self - other; }
wxDateTime __sub__(const wxDateSpan& other) { return *self - other; }
-// bool __lt__(const wxDateTime* other) { return other ? (*self < *other) : false; }
-// bool __le__(const wxDateTime* other) { return other ? (*self <= *other) : false; }
-// bool __gt__(const wxDateTime* other) { return other ? (*self > *other) : true; }
-// bool __ge__(const wxDateTime* other) { return other ? (*self >= *other) : true; }
-
-
// These fall back to just comparing pointers if other is NULL, or if
- // either operand is invalid.
+ // either operand is invalid. This allows Python comparrisons to None
+ // to not assert and to return a sane value for the compare.
bool __lt__(const wxDateTime* other) {
if (!other || !self->IsValid() || !other->IsValid()) return self < other;
return (*self < *other);
}
}
+
+
+
// ------------------------------------------------------------------------
// conversion from text: all conversions from text return -1 on failure,
// default, they will not change if they had valid values or will
// default to Today() otherwise)
int ParseFormat(const wxString& date,
- const wxString& format = wxPyDateFormatStr,
+ const wxString& format = wxPyDefaultDateTimeFormat,
const wxDateTime& dateDef = wxDefaultDateTime) {
const wxChar* rv;
const wxChar* _date = date;
// argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the
// resulting text representation
- wxString Format(const wxString& format = wxPyDateFormatStr,
+ wxString Format(const wxString& format = wxPyDefaultDateTimeFormat,
const wxDateTime::TimeZone& tz = LOCAL_TZ) const;
// preferred date representation for the current locale
// resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example.
- wxString Format(const wxString& format = wxPyTimeSpanFormatStr) const;
+ wxString Format(const wxString& format = wxPyDefaultTimeSpanFormat) const;
%pythoncode {
def __repr__(self):