]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't assert in wxDateTime::Format("%p") in locales not using AM/PM.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 13 Oct 2011 14:54:29 +0000 (14:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 13 Oct 2011 14:54:29 +0000 (14:54 +0000)
If a locale doesn't use AM/PM strings, strftime() can return an empty string
which does not indicate an error, so don't assert that strftime() failed in
this case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69411 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/datetime.cpp

index 49bfa98e1a61487ef90a8e387214a46b76737d10..790de959aa7fd3cbb732593e4fd087167b1edbe7 100644 (file)
@@ -437,8 +437,15 @@ wxString CallStrftime(const wxString& format, const tm* tm)
 
     if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) )
     {
-        // if the format is valid, buffer must be too small?
-        wxFAIL_MSG(wxT("strftime() failed"));
+        // There is one special case in which strftime() can return 0 without
+        // indicating an error: "%p" may give empty string depending on the
+        // locale, so check for it explicitly. Apparently it's really the only
+        // exception.
+        if ( format != wxS("%p") )
+        {
+            // if the format is valid, buffer must be too small?
+            wxFAIL_MSG(wxT("strftime() failed"));
+        }
 
         buf[0] = '\0';
     }