From c105b3cdd4ac47e095b257137db787821737317a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Oct 2011 14:54:29 +0000 Subject: [PATCH] Don't assert in wxDateTime::Format("%p") in locales not using AM/PM. 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 49bfa98e1a..790de959aa 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -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'; } -- 2.45.2