]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/date.cpp
Sorry folks, a lot of changes to remedy GetFont, GetBrush etc.
[wxWidgets.git] / src / common / date.cpp
index c0a1495af21957a40c567c53f4437824985cd175..1097624d59a5efd04bfde5e6112ed8a77ce35efa 100644 (file)
 
 #include "wx/setup.h"
 
-#if USE_TIMEDATE
+#if wxUSE_TIMEDATE
 
 #include "wx/date.h"
+#include <wx/intl.h>
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
-#if USE_IOSTREAMH
+#if wxUSE_IOSTREAMH
 #include <iostream.h>
 #else
 #include <iostream>
 
 #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 };
 
@@ -71,14 +75,14 @@ wxDate::wxDate()
   julian = 0;
 }
 
-wxDate::wxDate (const long j) : julian(j)
+wxDate::wxDate (long j) : julian(j)
 {
   DisplayFormat=wxMDY;
   DisplayOptions='\0';
   julian_to_mdy ();
 }
 
-wxDate::wxDate (const int m, const int d, const int y) : month(m), day(d), year(y)
+wxDate::wxDate (int m, int d, int y) : month(m), day(d), year(y)
 {
   DisplayFormat=wxMDY;
   DisplayOptions='\0';
@@ -101,8 +105,8 @@ wxDate::wxDate (const wxString& dat)
 
     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 ();
@@ -144,8 +148,8 @@ void wxDate::operator = (const wxString& dat)
 
     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 ();
@@ -164,25 +168,25 @@ wxDate::operator wxString( void )
 // Date Arithmetic
 //////////////////////////////////////////////////////////////
 
-wxDate wxDate::operator + (const long i)
+wxDate wxDate::operator + (long i)
 {
   wxDate dp(julian + i);
   return dp;
 }
 
-wxDate wxDate::operator + (const int i)
+wxDate wxDate::operator + (int i)
 {
   wxDate dp(julian + (long)i);
   return dp;
 }
 
-wxDate wxDate::operator - (const long i)
+wxDate wxDate::operator - (long i)
 {
   wxDate dp(julian - i);
   return dp;
 }
 
-wxDate wxDate::operator - (const int i)
+wxDate wxDate::operator - (int i)
 {
   wxDate dp(julian - (long)i);
   return dp;
@@ -193,14 +197,14 @@ long wxDate::operator - (const wxDate &dt)
        return ( julian - dt.julian );
 }
 
-wxDate &wxDate::operator += (const long i)
+wxDate &wxDate::operator += (long i)
 {
         julian += i;
      julian_to_mdy();
         return *this;
 }
 
-wxDate &wxDate::operator -= (const long i)
+wxDate &wxDate::operator -= (long i)
 {
         julian -= i;
      julian_to_mdy();
@@ -333,7 +337,7 @@ void wxDate::mdy_to_julian (void)
 // Format routine
 ////////////////////////////////////////////////////////////////
 
-wxString wxDate::FormatDate (const int type) const
+wxString wxDate::FormatDate (int type) const
 {
   int actualType = type;
   if (actualType == -1)
@@ -346,17 +350,17 @@ wxString wxDate::FormatDate (const int type) const
        {
                case wxDAY:
                        if ( (day_of_week < 1) || (day_of_week > 7) )
-                               strcpy(buf,"invalid day");
+                               strcpy(buf, _("invalid day"));
                        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) )
-                               strcpy(buf,"invalid month");
+                               strcpy(buf, _("invalid month"));
                        else
-                               strncpy( buf, mname[month-1],
+                               strncpy( buf, _(mname[month-1]),
                                        (DisplayOptions & wxDATE_ABBR) ? ABBR_LENGTH : 9);
                        return wxString(buf);
 
@@ -364,39 +368,39 @@ wxString wxDate::FormatDate (const int type) const
                        if ( (month < 1) || (month > 12) || (day_of_week < 0) ||
                                 (day_of_week > 7) )
                        {
-                               strcpy(buf,"invalid date");
+                               strcpy(buf, _("invalid date"));
                                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, ", ");
-                       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)
-                               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) )
                        {
-                               strcpy(buf,"invalid date");
+                               strcpy(buf, _("invalid date"));
                                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)
-                               strcat(buf," B.C.");
+                               strcat(buf, _(" B.C."));
                        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)
@@ -407,12 +411,12 @@ wxString wxDate::FormatDate (const int type) const
   return wxString("");
 }
 
-void wxDate::SetFormat( const int format )
+void wxDate::SetFormat( int format )
 {
        DisplayFormat = format;
 }
 
-int wxDate::SetOption( const int option, const bool action )
+int wxDate::SetOption( int option, bool action )
 {
        switch ( option )
        {
@@ -466,7 +470,7 @@ bool wxDate::IsLeapYear( void ) const
 
 wxDate& wxDate::Set()
 {
-//#ifdef __WINDOWS__
+//#ifdef __WXMSW__
 #if 0
     struct _dosdate_t sDate;
     _dos_getdate(&sDate);
@@ -477,7 +481,7 @@ wxDate& wxDate::Set()
 
     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;
@@ -623,7 +627,7 @@ bool wxDate::IsBetween(const wxDate& first, const wxDate& second) const
 }
 
 // This function is from NIHCL
-wxDate wxDate::Previous(const int dayOfWeek) const
+wxDate wxDate::Previous(int dayOfWeek) const
 {
         int this_day_Of_Week, desired_day_Of_Week;
         long j;