From 05ced5ce018bbdbaddb4d188674dda276937589e Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Sat, 15 Jul 2017 19:08:21 +0300 Subject: [PATCH] Handle stand-alone weekday and month names in macOS date formats macOS returns "cccc" (stand-alone weekday name) as a part of the preferred date+time format for Finnish, and possiblly others. This was not handled at all by wxTranslateFromUnicodeFormat(), and the user saw the raw "cccc". Similarly, handle stand-alone month name ("LLLL"). Closes https://github.com/wxWidgets/wxWidgets/pull/518 --- src/common/intl.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 5d816b284d..d3453894ec 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1212,7 +1212,7 @@ wxString wxTranslateFromUnicodeFormat(const wxString& fmt) #ifdef __WINDOWS__ "t" #else - "EawD" + "EcLawD" #endif ; for ( wxString::const_iterator p = fmt.begin(); /* end handled inside */; ++p ) @@ -1309,6 +1309,53 @@ wxString wxTranslateFromUnicodeFormat(const wxString& fmt) wxFAIL_MSG( "wrong number of 'E's" ); } break; + case 'c': + switch ( lastCount ) + { + case 1: // c + // TODO: unsupported: first day of week as numeric value + fmtWX += "1"; + break; + case 3: // ccc + fmtWX += "%a"; + break; + case 4: // cccc + fmtWX += "%A"; + break; + case 5: // ccccc + // no "narrow form" in strftime(), use abbrev. + fmtWX += "%a"; + break; + + default: + wxFAIL_MSG( "wrong number of 'c's" ); + } + break; + case 'L': + switch ( lastCount ) + { + case 1: // L + case 2: // LL + fmtWX += "%m"; + break; + + case 3: // LLL + fmtWX += "%b"; + break; + + case 4: // LLLL + fmtWX += "%B"; + break; + + case 5: // LLLLL + // no "narrow form" in strftime(), use abbrev. + fmtWX += "%b"; + break; + + default: + wxFAIL_MSG( "too many 'L's" ); + } + break; #endif case 'M': switch ( lastCount )