fix parsing of %p for locales which use periods in AM/PM strings (see #10677)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60011 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1168,25 +1168,25 @@ wxDateTime::ParseFormat(const wxString& date,
|
|||||||
|
|
||||||
case _T('p'): // AM or PM string
|
case _T('p'): // AM or PM string
|
||||||
{
|
{
|
||||||
wxString am, pm, token = GetAlphaToken(input, end);
|
wxString 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;
|
|
||||||
|
|
||||||
GetAmPmStrings(&am, &pm);
|
GetAmPmStrings(&am, &pm);
|
||||||
if (am.empty() && pm.empty())
|
|
||||||
return false; // no am/pm strings defined
|
// we can never match %p in locales which don't use AM/PM
|
||||||
if ( token.CmpNoCase(pm) == 0 )
|
if ( am.empty() || pm.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const size_t pos = input - date.begin();
|
||||||
|
if ( date.compare(pos, pm.length(), pm) == 0 )
|
||||||
{
|
{
|
||||||
isPM = true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user