X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b8c7ba607a15a2ff8a04448138df9ffff7df6c5..303f572ea95a88622fd93b33008de75f756ff068:/wxPython/src/_datetime.i diff --git a/wxPython/src/_datetime.i b/wxPython/src/_datetime.i index d932869e94..4bba1d2124 100644 --- a/wxPython/src/_datetime.i +++ b/wxPython/src/_datetime.i @@ -18,10 +18,10 @@ %{ #include - %} -MAKE_CONST_WXSTRING2(DateFormatStr, wxT("%c")); -MAKE_CONST_WXSTRING2(TimeSpanFormatStr, wxT("%H:%M:%S")); + +MAKE_CONST_WXSTRING(DefaultDateTimeFormat); +MAKE_CONST_WXSTRING(DefaultTimeSpanFormat); //--------------------------------------------------------------------------- @@ -363,11 +363,24 @@ public: static wxString GetWeekDayName(WeekDay weekday, NameFlags flags = Name_Full); - DocDeclAStr( - static void, GetAmPmStrings(wxString *OUTPUT, wxString *OUTPUT), - "GetAmPmStrings() -> (am, pm)", - "Get the AM and PM strings in the current locale (may be empty)", ""); - + %extend { + DocAStr( + GetAmPmStrings, + "GetAmPmStrings() -> (am, pm)", + "Get the AM and PM strings in the current locale (may be empty)", ""); + static PyObject* GetAmPmStrings() { + wxString am; + wxString pm; + wxDateTime::GetAmPmStrings(&am, &pm); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); + PyObject* tup = PyTuple_New(2); + PyTuple_SET_ITEM(tup, 0, wx2PyString(am)); + PyTuple_SET_ITEM(tup, 1, wx2PyString(pm)); + wxPyEndBlockThreads(blocked); + return tup; + } + } + // return True if the given country uses DST for this year static bool IsDSTApplicable(int year = Inv_Year, Country country = Country_Default); @@ -708,14 +721,15 @@ public: 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; } @@ -724,14 +738,9 @@ public: 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); @@ -759,6 +768,9 @@ public: } } + + + // ------------------------------------------------------------------------ // conversion from text: all conversions from text return -1 on failure, @@ -783,7 +795,7 @@ public: // 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; @@ -828,7 +840,7 @@ public: // 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 @@ -995,7 +1007,7 @@ public: // 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):