]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datetimefmt.cpp
Fix calculation of the margins for owner-drawn menu items.
[wxWidgets.git] / src / common / datetimefmt.cpp
index 516d9a3347f33853b136a7c5e17f908f9342b2fc..f9404d864292692cc3fff9b1486545be18cfab5e 100644 (file)
@@ -1048,11 +1048,12 @@ wxDateTime::ParseFormat(const wxString& date,
                 {
                     wxDateTime dt;
 
+#if wxUSE_INTL
                     const wxString
                         fmtDateTime = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
                     if ( !fmtDateTime.empty() )
                         dt = ParseFormatAt(input, end, fmtDateTime);
-
+#endif // wxUSE_INTL
                     if ( !dt.IsValid() )
                     {
                         // also try the format which corresponds to ctime()
@@ -1269,10 +1270,13 @@ wxDateTime::ParseFormat(const wxString& date,
 
             case wxT('x'):       // locale default date representation
                 {
+#if wxUSE_INTL
                     wxString
                         fmtDate = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT),
                         fmtDateAlt = wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT);
-
+#else // !wxUSE_INTL
+                    wxString fmtDate, fmtDateAlt;
+#endif // wxUSE_INTL/!wxUSE_INTL
                     if ( fmtDate.empty() )
                     {
                         if ( IsWestEuropeanCountry(GetCountry()) ||
@@ -1317,9 +1321,12 @@ wxDateTime::ParseFormat(const wxString& date,
 
             case wxT('X'):       // locale default time representation
                 {
+#if wxUSE_INTL
                     wxString fmtTime = wxLocale::GetInfo(wxLOCALE_TIME_FMT),
                              fmtTimeAlt;
-
+#else // !wxUSE_INTL
+                    wxString fmtTime, fmtTimeAlt;
+#endif // wxUSE_INTL/!wxUSE_INTL
                     if ( fmtTime.empty() )
                     {
                         // try to parse what follows as "%H:%M:%S" and, if this
@@ -1552,7 +1559,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
     const wxString::const_iterator pEnd = date.end();
 
     wxString::const_iterator p = pBegin;
-    while ( wxIsspace(*p) )
+    while ( p != pEnd && wxIsspace(*p) )
         p++;
 
     // some special cases
@@ -1753,7 +1760,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
                 else // not a valid weekday name
                 {
                     // try the ordinals
-                    static const char *ordinals[] =
+                    static const char *const ordinals[] =
                     {
                         wxTRANSLATE("first"),
                         wxTRANSLATE("second"),
@@ -1915,14 +1922,13 @@ wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end)
     for ( size_t n = 0; n < WXSIZEOF(stdTimes); n++ )
     {
         const wxString timeString = wxGetTranslation(stdTimes[n].name);
-        const wxString::const_iterator p = time.begin() + timeString.length();
-        if ( timeString.CmpNoCase(wxString(time.begin(), p)) == 0 )
+        if ( timeString.CmpNoCase(wxString(time, timeString.length())) == 0 )
         {
             // casts required by DigitalMars
             Set(stdTimes[n].hour, wxDateTime_t(0), wxDateTime_t(0));
 
             if ( end )
-                *end = p;
+                *end = time.begin() + timeString.length();
 
             return true;
         }
@@ -1930,12 +1936,12 @@ wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end)
 
     // try all time formats we may think about in the order from longest to
     // shortest
-    static const char *timeFormats[] =
+    static const char *const timeFormats[] =
     {
         "%I:%M:%S %p",  // 12hour with AM/PM
         "%H:%M:%S",     // could be the same or 24 hour one so try it too
         "%I:%M %p",     // 12hour with AM/PM but without seconds
-        "%H:%M:%S",     // and a possibly 24 hour version without seconds
+        "%H:%M",        // and a possibly 24 hour version without seconds
         "%X",           // possibly something from above or maybe something
                         // completely different -- try it last