Changed the wxDateTime.Parse* methods to return an int that will be -1
on failure, and the index where parsing stopped otherwise. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -773,32 +773,68 @@ public:
|
||||
"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// conversion to/from text: all conversions from text return the pointer to
|
||||
// the next character following the date specification (i.e. the one where
|
||||
// the scan had to stop) or NULL on failure.
|
||||
// conversion from text: all conversions from text return -1 on failure,
|
||||
// or the index in the string where the next character following the date
|
||||
// specification (i.e. the one where the scan had to stop) is located.
|
||||
|
||||
%addmethods {
|
||||
|
||||
// parse a string in RFC 822 format (found e.g. in mail headers and
|
||||
// having the form "Wed, 10 Feb 1999 19:07:07 +0100")
|
||||
wxString ParseRfc822Date(const wxString& date);
|
||||
int ParseRfc822Date(const wxString& date) {
|
||||
const wxChar* rv;
|
||||
const wxChar* _date = date;
|
||||
rv = self->ParseRfc822Date(_date);
|
||||
if (rv == NULL) return -1;
|
||||
return rv - _date;
|
||||
}
|
||||
|
||||
|
||||
// parse a date/time in the given format (see strptime(3)), fill in
|
||||
// the missing (in the string) fields with the values of dateDef (by
|
||||
// default, they will not change if they had valid values or will
|
||||
// default to Today() otherwise)
|
||||
wxString ParseFormat(const wxString& date,
|
||||
const wxString& format = wxPyDateFormatStr,
|
||||
const wxDateTime& dateDef = wxDefaultDateTime);
|
||||
int ParseFormat(const wxString& date,
|
||||
const wxString& format = wxPyDateFormatStr,
|
||||
const wxDateTime& dateDef = wxDefaultDateTime) {
|
||||
const wxChar* rv;
|
||||
const wxChar* _date = date;
|
||||
rv = self->ParseFormat(_date, format, dateDef);
|
||||
if (rv == NULL) return -1;
|
||||
return rv - _date;
|
||||
}
|
||||
|
||||
// parse a string containing the date/time in "free" format, this
|
||||
// function will try to make an educated guess at the string contents
|
||||
wxString ParseDateTime(const wxString& datetime);
|
||||
int ParseDateTime(const wxString& datetime) {
|
||||
const wxChar* rv;
|
||||
const wxChar* _datetime = datetime;
|
||||
rv = self->ParseDateTime(_datetime);
|
||||
if (rv == NULL) return -1;
|
||||
return rv - _datetime;
|
||||
}
|
||||
|
||||
|
||||
// parse a string containing the date only in "free" format (less
|
||||
// flexible than ParseDateTime)
|
||||
wxString ParseDate(const wxString& date);
|
||||
int ParseDate(const wxString& date) {
|
||||
const wxChar* rv;
|
||||
const wxChar* _date = date;
|
||||
rv = self->ParseDate(_date);
|
||||
if (rv == NULL) return -1;
|
||||
return rv - _date;
|
||||
}
|
||||
|
||||
// parse a string containing the time only in "free" format
|
||||
wxString ParseTime(const wxString& time);
|
||||
int ParseTime(const wxString& time) {
|
||||
const wxChar* rv;
|
||||
const wxChar* _time = time;
|
||||
rv = self->ParseTime(_time);
|
||||
if (rv == NULL) return -1;
|
||||
return rv - _time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this function accepts strftime()-like format string (default
|
||||
// argument corresponds to the preferred date and time representation
|
||||
|
Reference in New Issue
Block a user