]> git.saurik.com Git - wxWidgets.git/commitdiff
move parsing helpers, too (part of r59656)
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Fri, 20 Mar 2009 19:25:48 +0000 (19:25 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Fri, 20 Mar 2009 19:25:48 +0000 (19:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/datetime.cpp
src/common/datetimefmt.cpp

index 5781bebe929ad5902c321ebae63beb524b2d77d9..927e7390be4683ffaaa2b108181c3b49fb9185ad 100644 (file)
@@ -391,7 +391,8 @@ extern const char *wxDumpDate(const wxDateTime* dt)
 #endif // Debug
 
 // get the number of days in the given month of the given year
-static inline
+// NOTE: not static because required by datetimefmt.cpp, too
+inline
 wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month)
 {
     // the number of days in month in Julian/Gregorian calendar: the first line
@@ -571,106 +572,6 @@ static void InitTm(struct tm& tm)
     tm.tm_isdst = -1; // auto determine
 }
 
-// parsing helpers
-// ---------------
-
-// return the month if the string is a month name or Inv_Month otherwise
-static wxDateTime::Month GetMonthFromName(const wxString& name, int flags)
-{
-    wxDateTime::Month mon;
-    for ( mon = wxDateTime::Jan; mon < wxDateTime::Inv_Month; wxNextMonth(mon) )
-    {
-        // case-insensitive comparison either one of or with both abbreviated
-        // and not versions
-        if ( flags & wxDateTime::Name_Full )
-        {
-            if ( name.CmpNoCase(wxDateTime::
-                        GetMonthName(mon, wxDateTime::Name_Full)) == 0 )
-            {
-                break;
-            }
-        }
-
-        if ( flags & wxDateTime::Name_Abbr )
-        {
-            if ( name.CmpNoCase(wxDateTime::
-                        GetMonthName(mon, wxDateTime::Name_Abbr)) == 0 )
-            {
-                break;
-            }
-        }
-    }
-
-    return mon;
-}
-
-// return the weekday if the string is a weekday name or Inv_WeekDay otherwise
-static wxDateTime::WeekDay GetWeekDayFromName(const wxString& name, int flags)
-{
-    wxDateTime::WeekDay wd;
-    for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) )
-    {
-        // case-insensitive comparison either one of or with both abbreviated
-        // and not versions
-        if ( flags & wxDateTime::Name_Full )
-        {
-            if ( name.CmpNoCase(wxDateTime::
-                        GetWeekDayName(wd, wxDateTime::Name_Full)) == 0 )
-            {
-                break;
-            }
-        }
-
-        if ( flags & wxDateTime::Name_Abbr )
-        {
-            if ( name.CmpNoCase(wxDateTime::
-                        GetWeekDayName(wd, wxDateTime::Name_Abbr)) == 0 )
-            {
-                break;
-            }
-        }
-    }
-
-    return wd;
-}
-
-/* static */
-struct tm *wxDateTime::GetTmNow(struct tm *tmstruct)
-{
-    time_t t = GetTimeNow();
-    return wxLocaltime_r(&t, tmstruct);
-}
-
-// scans all digits (but no more than len) and returns the resulting number
-static bool GetNumericToken(size_t len,
-                            const wxStringCharType*& p,
-                            unsigned long *number)
-{
-    size_t n = 1;
-    wxString s;
-    while ( wxIsdigit(*p) )
-    {
-        s += *p++;
-
-        if ( len && ++n > len )
-            break;
-    }
-
-    return !s.empty() && s.ToULong(number);
-}
-
-// scans all alphabetic characters and returns the resulting string
-static wxString GetAlphaToken(const wxStringCharType*& p)
-{
-    wxString s;
-    while ( wxIsalpha(*p) )
-    {
-        s += *p++;
-    }
-
-    return s;
-}
-
 // ============================================================================
 // implementation of wxDateTime
 // ============================================================================
@@ -1095,6 +996,7 @@ void wxDateTime::GetAmPmStrings(wxString *am, wxString *pm)
     }
 }
 
+
 // ----------------------------------------------------------------------------
 // Country stuff: date calculations depend on the country (DST, work days,
 // ...), so we need to know which rules to follow.
index f53e183dade438a9e8a6bd3fcd84ea0ba3df0e85..dae6e0f1a8d9e290195407457e969ec79639cdc2 100644 (file)
 // implementation of wxDateTime
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// constants (see also datetime.cpp)
+// ----------------------------------------------------------------------------
+
+static const int DAYS_PER_WEEK = 7;
+
+static const int HOURS_PER_DAY = 24;
+
+static const int SEC_PER_MIN = 60;
+
+static const int MIN_PER_HOUR = 60;
+
+// ----------------------------------------------------------------------------
+// parsing helpers
+// ----------------------------------------------------------------------------
+
+// see datetime.cpp:
+wxDateTime::wxDateTime_t GetNumOfDaysInMonth(int year, wxDateTime::Month month);
+
+// return the month if the string is a month name or Inv_Month otherwise
+static wxDateTime::Month GetMonthFromName(const wxString& name, int flags)
+{
+    wxDateTime::Month mon;
+    for ( mon = wxDateTime::Jan; mon < wxDateTime::Inv_Month; wxNextMonth(mon) )
+    {
+        // case-insensitive comparison either one of or with both abbreviated
+        // and not versions
+        if ( flags & wxDateTime::Name_Full )
+        {
+            if ( name.CmpNoCase(wxDateTime::
+                        GetMonthName(mon, wxDateTime::Name_Full)) == 0 )
+            {
+                break;
+            }
+        }
+
+        if ( flags & wxDateTime::Name_Abbr )
+        {
+            if ( name.CmpNoCase(wxDateTime::
+                        GetMonthName(mon, wxDateTime::Name_Abbr)) == 0 )
+            {
+                break;
+            }
+        }
+    }
+
+    return mon;
+}
+
+// return the weekday if the string is a weekday name or Inv_WeekDay otherwise
+static wxDateTime::WeekDay GetWeekDayFromName(const wxString& name, int flags)
+{
+    wxDateTime::WeekDay wd;
+    for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) )
+    {
+        // case-insensitive comparison either one of or with both abbreviated
+        // and not versions
+        if ( flags & wxDateTime::Name_Full )
+        {
+            if ( name.CmpNoCase(wxDateTime::
+                        GetWeekDayName(wd, wxDateTime::Name_Full)) == 0 )
+            {
+                break;
+            }
+        }
+
+        if ( flags & wxDateTime::Name_Abbr )
+        {
+            if ( name.CmpNoCase(wxDateTime::
+                        GetWeekDayName(wd, wxDateTime::Name_Abbr)) == 0 )
+            {
+                break;
+            }
+        }
+    }
+
+    return wd;
+}
+
+/* static */
+struct tm *wxDateTime::GetTmNow(struct tm *tmstruct)
+{
+    time_t t = GetTimeNow();
+    return wxLocaltime_r(&t, tmstruct);
+}
+
+// scans all digits (but no more than len) and returns the resulting number
+static bool GetNumericToken(size_t len,
+                            const wxStringCharType*& p,
+                            unsigned long *number)
+{
+    size_t n = 1;
+    wxString s;
+    while ( wxIsdigit(*p) )
+    {
+        s += *p++;
+
+        if ( len && ++n > len )
+            break;
+    }
+
+    return !s.empty() && s.ToULong(number);
+}
+
+// scans all alphabetic characters and returns the resulting string
+static wxString GetAlphaToken(const wxStringCharType*& p)
+{
+    wxString s;
+    while ( wxIsalpha(*p) )
+    {
+        s += *p++;
+    }
+
+    return s;
+}
+
 // ----------------------------------------------------------------------------
 // wxDateTime to/from text representations
 // ----------------------------------------------------------------------------