+// helper class setting the locale to "C" for its lifetime
+class CLocaleSetter
+{
+public:
+ CLocaleSetter() : m_locOld(setlocale(LC_ALL, "C")) { }
+ ~CLocaleSetter() { setlocale(LC_ALL, m_locOld); }
+
+private:
+ const char * const m_locOld;
+ wxDECLARE_NO_COPY_CLASS(CLocaleSetter);
+};
+
+// helper function translating week day/month names from English to the current
+// locale
+static wxString TranslateDate(const wxString& str)
+{
+ // small optimization: if there are no alphabetic characters in the string,
+ // there is nothing to translate
+ wxString::const_iterator i, end = str.end();
+ for ( i = str.begin(); i != end; ++i )
+ {
+ if ( isalpha(*i) )
+ break;
+ }
+
+ if ( i == end )
+ return str;
+
+ wxString trans(str);
+
+ for ( wxDateTime::WeekDay wd = wxDateTime::Sun;
+ wd < wxDateTime::Inv_WeekDay;
+ wxNextWDay(wd) )
+ {
+ trans.Replace
+ (
+ wxDateTime::GetEnglishWeekDayName(wd, wxDateTime::Name_Abbr),
+ wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr)
+ );
+ }
+
+ for ( wxDateTime::Month mon = wxDateTime::Jan;
+ mon < wxDateTime::Inv_Month;
+ wxNextMonth(mon) )
+ {
+ trans.Replace
+ (
+ wxDateTime::GetEnglishMonthName(mon, wxDateTime::Name_Abbr),
+ wxDateTime::GetMonthName(mon, wxDateTime::Name_Abbr)
+ );
+ }
+
+ return trans;
+}
+