]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/date.cpp
* Fixed two memory leaks.
[wxWidgets.git] / src / common / date.cpp
index 158aca78c8af65e81044bd9779d91c0cd728ae10..bda79ab3a2259318edfd7717a4f5a656c4425d35 100644 (file)
@@ -31,6 +31,7 @@
 #if USE_TIMEDATE
 
 #include "wx/date.h"
 #if USE_TIMEDATE
 
 #include "wx/date.h"
+#include <wx/intl.h>
 
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
 
 #define ABBR_LENGTH 3
 
 
 #define ABBR_LENGTH 3
 
-static const char *dayname[] = {"Sunday","Monday","Tuesday","Wednesday",
-          "Thursday","Friday","Saturday"} ;
+static const char *dayname[] = {
+  "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
+};
 
 
-static const char *mname[] = {"January","February","March","April","May",
-          "June","July","August","September","October","November","December"};
+static const char *mname[] = {
+  "January", "February", "March", "April", "May", "June", "July", "August",
+  "September", "October", "November", "December"
+};
 
 static int GauDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
 
 static int GauDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
@@ -101,8 +105,8 @@ wxDate::wxDate (const wxString& dat)
 
     char *token = strtok(buf,"/-");
     month = atoi(token);
 
     char *token = strtok(buf,"/-");
     month = atoi(token);
-    day   = atoi(strtok(NULL,"/-"));
-    year  = atoi(strtok(NULL," "));
+    day   = atoi(strtok((char *) NULL,"/-"));
+    year  = atoi(strtok((char *) NULL," "));
   }
 
   mdy_to_julian ();
   }
 
   mdy_to_julian ();
@@ -144,8 +148,8 @@ void wxDate::operator = (const wxString& dat)
 
     char *token = strtok(buf,"/-");
     month = atoi(token);
 
     char *token = strtok(buf,"/-");
     month = atoi(token);
-    day   = atoi(strtok(NULL,"/-"));
-    year  = atoi(strtok(NULL," "));
+    day   = atoi(strtok((char *) NULL,"/-"));
+    year  = atoi(strtok((char *) NULL," "));
   }
 
   mdy_to_julian ();
   }
 
   mdy_to_julian ();
@@ -346,17 +350,17 @@ wxString wxDate::FormatDate (int type) const
        {
                case wxDAY:
                        if ( (day_of_week < 1) || (day_of_week > 7) )
        {
                case wxDAY:
                        if ( (day_of_week < 1) || (day_of_week > 7) )
-                               strcpy(buf,"invalid day");
+                               strcpy(buf, _("invalid day"));
                        else
                        else
-                               strncpy( buf, dayname[day_of_week-1],
+                               strncpy( buf, _(dayname[day_of_week-1]),
                                        (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        return wxString(buf);
 
                case wxMONTH:
                        if ( (month < 1) || (month > 12) )
                                        (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        return wxString(buf);
 
                case wxMONTH:
                        if ( (month < 1) || (month > 12) )
-                               strcpy(buf,"invalid month");
+                               strcpy(buf, _("invalid month"));
                        else
                        else
-                               strncpy( buf, mname[month-1],
+                               strncpy( buf, _(mname[month-1]),
                                        (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        return wxString(buf);
 
                                        (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        return wxString(buf);
 
@@ -364,39 +368,39 @@ wxString wxDate::FormatDate (int type) const
                        if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
                                 (day_of_week > 7) )
                        {
                        if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
                                 (day_of_week > 7) )
                        {
-                               strcpy(buf,"invalid date");
+                               strcpy(buf, _("invalid date"));
                                return wxString(buf);
                        }
                                return wxString(buf);
                        }
-                       strncpy( buf, dayname[day_of_week-1],
+                       strncpy( buf, _(dayname[day_of_week-1]),
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        strcat( buf, ", ");
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        strcat( buf, ", ");
-                       strncat( buf, mname[month-1],
+                       strncat( buf, _(mname[month-1]),
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        strcat( buf, " ");
                        sprintf( buf+strlen(buf), "%d, %d", day, abs(year) );
                        if (year < 0)
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        strcat( buf, " ");
                        sprintf( buf+strlen(buf), "%d, %d", day, abs(year) );
                        if (year < 0)
-                               strcat(buf," B.C.");
+                               strcat(buf,_(" B.C."));
                        return wxString(buf);
 
                case wxEUROPEAN:
                        if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
                                 (day_of_week > 7) )
                        {
                        return wxString(buf);
 
                case wxEUROPEAN:
                        if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
                                 (day_of_week > 7) )
                        {
-                               strcpy(buf,"invalid date");
+                               strcpy(buf, _("invalid date"));
                                return wxString(buf);
                        }
                        sprintf(buf,"%d ",      day);
                                return wxString(buf);
                        }
                        sprintf(buf,"%d ",      day);
-                       strncat(buf, mname[month-1],
+                       strncat(buf, _(mname[month-1]),
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        sprintf( buf+strlen(buf), " %d", abs(year) );
                        if (year < 0)
                                (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        sprintf( buf+strlen(buf), " %d", abs(year) );
                        if (year < 0)
-                               strcat(buf," B.C.");
+                               strcat(buf, _(" B.C."));
                        return wxString(buf);
 
                case wxMDY:
                default:
                        if (day==0 || month==0 || year==0)
                        return wxString(buf);
 
                case wxMDY:
                default:
                        if (day==0 || month==0 || year==0)
-                               strcpy(buf,"invalid date");
+                               strcpy(buf, _("invalid date"));
                        else
                                sprintf( buf+strlen(buf), "%1d/%1d/%02d", month, day,
                                        (DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899)
                        else
                                sprintf( buf+strlen(buf), "%1d/%1d/%02d", month, day,
                                        (DisplayOptions & wxNO_CENTURY) && (abs(year) > 1899)
@@ -477,7 +481,7 @@ wxDate& wxDate::Set()
 
     mdy_to_julian();
 #else
 
     mdy_to_julian();
 #else
-    time_t now = time(NULL);
+    time_t now = time((time_t *) NULL);
     struct tm *localTime = localtime(&now);
 
     month = localTime->tm_mon + 1;
     struct tm *localTime = localtime(&now);
 
     month = localTime->tm_mon + 1;