#endif
// we have to use our own implementation if the date is out of range of
// strftime() or if we use non standard specificators
-#ifdef HAVE_STRFTIME
+#ifdef wxHAS_STRFTIME
time_t time = GetTicks();
if ( (time != (time_t)-1) && !wxStrstr(format, _T("%l")) )
}
}
//else: use generic code below
-#endif // HAVE_STRFTIME
+#endif // wxHAS_STRFTIME
// we only parse ANSI C format specifications here, no POSIX 2
// complications, no GNU extensions but we do add support for a "%l" format
case _T('c'): // locale default date and time representation
case _T('x'): // locale default date representation
-#ifdef HAVE_STRFTIME
+#ifdef wxHAS_STRFTIME
//
// the problem: there is no way to know what do these format
// specifications correspond to for the current locale.
res += str;
}
-#else // !HAVE_STRFTIME
+#else // !wxHAS_STRFTIME
// Use "%m/%d/%y %H:%M:%S" format instead
res += wxString::Format(wxT("%02d/%02d/%04d %02d:%02d:%02d"),
tm.mon+1,tm.mday, tm.year, tm.hour, tm.min, tm.sec);
-#endif // HAVE_STRFTIME/!HAVE_STRFTIME
+#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
case _T('d'): // day of a month (01-31)
break;
case _T('p'): // AM or PM string
-#ifdef HAVE_STRFTIME
+#ifdef wxHAS_STRFTIME
res += CallStrftime(_T("%p"), &tmTimeOnly);
-#else // !HAVE_STRFTIME
+#else // !wxHAS_STRFTIME
res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am");
-#endif // HAVE_STRFTIME/!HAVE_STRFTIME
+#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
case _T('S'): // second as a decimal number (00-61)
case _T('X'): // locale default time representation
// just use strftime() to format the time for us
-#ifdef HAVE_STRFTIME
+#ifdef wxHAS_STRFTIME
res += CallStrftime(_T("%X"), &tmTimeOnly);
-#else // !HAVE_STRFTIME
+#else // !wxHAS_STRFTIME
res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec);
-#endif // HAVE_STRFTIME/!HAVE_STRFTIME
+#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
case _T('y'): // year without century (00-99)
break;
case _T('Z'): // timezone name
-#ifdef HAVE_STRFTIME
+#ifdef wxHAS_STRFTIME
res += CallStrftime(_T("%Z"), &tmTimeOnly);
#endif
break;
case _T('p'): // AM or PM string
{
- wxString am, pm, token = GetAlphaToken(input, end);
+ wxString am, pm;
+ GetAmPmStrings(&am, &pm);
- // some locales have empty AM/PM tokens and thus when formatting
- // dates with the %p specifier nothing is generated; when trying to
- // parse them back, we get an empty token here... but that's not
- // an error.
- if (token.empty())
- break;
+ // we can never match %p in locales which don't use AM/PM
+ if ( am.empty() || pm.empty() )
+ return false;
- GetAmPmStrings(&am, &pm);
- if (am.empty() && pm.empty())
- return false; // no am/pm strings defined
- if ( token.CmpNoCase(pm) == 0 )
+ const size_t pos = input - date.begin();
+ if ( date.compare(pos, pm.length(), pm) == 0 )
{
isPM = true;
+ input += pm.length();
}
- else if ( token.CmpNoCase(am) != 0 )
+ else if ( date.compare(pos, am.length(), am) == 0 )
+ {
+ input += am.length();
+ }
+ else // no match
{
- // no match
return false;
}
}
int year = 0;
// tokenize the string
- static const wxStringCharType *dateDelimiters = wxS(".,/-\t\r\n ");
while ( p != pEnd )
{
// skip white space and date delimiters