]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datetime.cpp
1. wxWizard supports setting images for each page, sample updated to show it
[wxWidgets.git] / src / common / datetime.cpp
index e933221766669dae48e32f7c6572d19948c1dfed..b2f65e9f618c5158641d22d4d269aa0a77a60113 100644 (file)
@@ -75,6 +75,8 @@
 
 #define wxDEFINE_TIME_CONSTANTS // before including datetime.h
 
+#include <ctype.h>
+
 #include "wx/datetime.h"
 
 // ----------------------------------------------------------------------------
@@ -95,6 +97,9 @@
 #ifndef WX_TIMEZONE
     #if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
         #define WX_TIMEZONE _timezone
+    #elif defined(__MWERKS__)
+       long wxmw_timezone = 28800;
+       #define WX_TIMEZONE wxmw_timezone ;
     #else // unknown platform - try timezone
         #define WX_TIMEZONE timezone
     #endif
@@ -190,7 +195,7 @@ wxDateTime::Country wxDateTime::ms_country = wxDateTime::Country_Unknown;
 #ifdef __WXDEBUG__
 extern const wxChar *wxDumpDate(const wxDateTime* dt)
 {
-    static wxChar buf[20];
+    static wxChar buf[128];
 
     wxStrcpy(buf, dt->Format(_T("%Y-%m-%d (%a) %H:%M:%S")));
 
@@ -2963,16 +2968,36 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
     while ( wxIsspace(*p) )
         p++;
 
-    wxString today = _T("today");
-    size_t len = today.length();
-    if ( wxString(p, len).CmpNoCase(today) == 0 )
+    // some special cases
+    static struct
+    {
+        const wxChar *str;
+        int dayDiffFromToday;
+    } literalDates[] =
     {
-        // nothing can follow this, so stop here
-        p += len;
+        { wxTRANSLATE("today"),             0 },
+        { wxTRANSLATE("yesterday"),        -1 },
+        { wxTRANSLATE("tomorrow"),          1 },
+    };
 
-        *this = Today();
+    for ( size_t n = 0; n < WXSIZEOF(literalDates); n++ )
+    {
+        wxString date = wxGetTranslation(literalDates[n].str);
+        size_t len = date.length();
+        if ( wxString(p, len).CmpNoCase(date) == 0 )
+        {
+            // nothing can follow this, so stop here
+            p += len;
 
-        return p;
+            int dayDiffFromToday = literalDates[n].dayDiffFromToday;
+            *this = Today();
+            if ( dayDiffFromToday )
+            {
+                *this += wxDateSpan::Days(dayDiffFromToday);
+            }
+
+            return p;
+        }
     }
 
     // what do we have?