#if !defined(wxUSE_DATETIME) || wxUSE_DATETIME
#ifndef WX_PRECOMP
- #ifdef __WXMSW__
+ #ifdef __WINDOWS__
#include "wx/msw/wrapwin.h"
#endif
#include "wx/string.h"
const wxString str(p, end);
wxString::const_iterator endParse;
wxDateTime dt;
- if ( dt.ParseFormat(str, fmt, &endParse) ||
- (!fmtAlt.empty() && dt.ParseFormat(str, fmtAlt, &endParse)) )
+
+ // Use a default date outside of the DST period to avoid problems with
+ // parsing the time differently depending on the todays date (which is used
+ // as the fall back date if none is explicitly specified).
+ static const wxDateTime dtDef(1, wxDateTime::Jan, 2012);
+
+ if ( dt.ParseFormat(str, fmt, dtDef, &endParse) ||
+ (!fmtAlt.empty() && dt.ParseFormat(str, fmtAlt, dtDef, &endParse)) )
{
p += endParse - str.begin();
}
time_t time = GetTicks();
if ( (time != (time_t)-1) && !wxStrstr(format, wxT("%l"))
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
&& !wxStrstr(format, wxT("%z"))
#endif
)
return true;
}
+const char* wxDateTime::ParseRfc822Date(const char* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseRfc822Date(dateStr, &end) )
+ return NULL;
+
+ return date + dateStr.IterOffsetInMBStr(end);
+}
+
+const wchar_t* wxDateTime::ParseRfc822Date(const wchar_t* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseRfc822Date(dateStr, &end) )
+ return NULL;
+
+ return date + (end - dateStr.begin());
+}
+
bool
wxDateTime::ParseFormat(const wxString& date,
const wxString& format,
case wxT('z'):
{
+ // check that we have something here at all
+ if ( input == end )
+ return false;
+
+ // and then check that it's either plus or minus sign
bool minusFound;
if ( *input == wxT('-') )
minusFound = true;
break;
case wxT('%'): // a percent sign
- if ( *input++ != wxT('%') )
+ if ( input == end || *input++ != wxT('%') )
{
// no match
return false;
return true;
}
+const char*
+wxDateTime::ParseFormat(const char* date,
+ const wxString& format,
+ const wxDateTime& dateDef)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseFormat(dateStr, format, dateDef, &end) )
+ return NULL;
+
+ return date + dateStr.IterOffsetInMBStr(end);
+}
+
+const wchar_t*
+wxDateTime::ParseFormat(const wchar_t* date,
+ const wxString& format,
+ const wxDateTime& dateDef)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseFormat(dateStr, format, dateDef, &end) )
+ return NULL;
+
+ return date + (end - dateStr.begin());
+}
+
bool
wxDateTime::ParseDateTime(const wxString& date, wxString::const_iterator *end)
{
return true;
}
+const char* wxDateTime::ParseDateTime(const char* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseDateTime(dateStr, &end) )
+ return NULL;
+
+ return date + dateStr.IterOffsetInMBStr(end);
+}
+
+const wchar_t* wxDateTime::ParseDateTime(const wchar_t* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseDateTime(dateStr, &end) )
+ return NULL;
+
+ return date + (end - dateStr.begin());
+}
+
bool
wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
{
return true;
}
+const char* wxDateTime::ParseDate(const char* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseDate(dateStr, &end) )
+ return NULL;
+
+ return date + dateStr.IterOffsetInMBStr(end);
+}
+
+const wchar_t* wxDateTime::ParseDate(const wchar_t* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseDate(dateStr, &end) )
+ return NULL;
+
+ return date + (end - dateStr.begin());
+}
+
bool
wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end)
{
return false;
}
+const char* wxDateTime::ParseTime(const char* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseTime(dateStr, &end) )
+ return NULL;
+
+ return date + dateStr.IterOffsetInMBStr(end);
+}
+
+const wchar_t* wxDateTime::ParseTime(const wchar_t* date)
+{
+ wxString::const_iterator end;
+ wxString dateStr(date);
+ if ( !ParseTime(dateStr, &end) )
+ return NULL;
+
+ return date + (end - dateStr.begin());
+}
+
// ----------------------------------------------------------------------------
// Workdays and holidays support
// ----------------------------------------------------------------------------