compiler/libec: (#205) Corrections to integer promotions
[sdk] / ecere / src / sys / Time.ec
index 9c548d3..a69e7de 100644 (file)
@@ -83,7 +83,7 @@ static int TIME_DayLightCompareDate(const SYSTEMTIME *date, const SYSTEMTIME *co
    {
       WORD First;
       int weekofmonth = compareDate->wDay;
-      First = ( 6 + compareDate->wDayOfWeek - date->wDayOfWeek + date->wDay ) % 7 + 1;
+      First = (WORD)(( 6 + compareDate->wDayOfWeek - date->wDayOfWeek + date->wDay ) % 7 + 1);
       limit_day = First + 7 * (weekofmonth - 1);
       if(limit_day > monthLengths[date->wMonth==2 && ISLEAP(date->wYear)][date->wMonth - 1])
          limit_day -= 7;
@@ -210,7 +210,7 @@ import "System"
 
 public class Time : double
 {
-   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
       Time time = this;
       int value;
@@ -291,13 +291,20 @@ static time_t MakeTimeTfromDT(DateTime dt)
 
 public class SecSince1970 : int64
 {
-   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
-      // TOFIX:  passing argument 2 of '__ecereProp___ecereNameSpace__ecere__sys__DateTime_Set___ecereNameSpace__ecere__sys__SecSince1970' makes integer from pointer without a cast
-      DateTime t = this;
-      return t.OnGetString(tempString, fieldData, needClass);
-      // TOFIX:
-      // return ((DateTime)this).OnGetString(tempString, fieldData, needClass);
+      return ((DateTime)this).OnGetString(tempString, fieldData, needClass);
+   }
+
+   bool OnGetDataFromString(const char * string)
+   {
+      DateTime dt { };
+      if(dt.OnGetDataFromString(string))
+      {
+         this = dt;
+         return true;
+      }
+      return false;
    }
 
    // Is this required?
@@ -320,13 +327,13 @@ public:
       {
       #if defined(__WIN32__)
          SYSTEMTIME localTime, systemTime;
-         FILETIME fileTime, localFileTime;
+         //FILETIME fileTime, localFileTime;
          DateTime input, global;
 
          input = this;
 
          localTime.wYear = (short)input.year;
-         localTime.wMonth = (short)input.month + 1;
+         localTime.wMonth = (short)(input.month + 1);
          localTime.wDay = (short)input.day;
          localTime.wHour = (short)input.hour;
          localTime.wMinute = (short)input.minute;
@@ -378,7 +385,7 @@ public:
          utc = this;
 
          systemTime.wYear = (short)utc.year;
-         systemTime.wMonth = (short)utc.month + 1;
+         systemTime.wMonth = (short)(utc.month + 1);
          systemTime.wDay = (short)utc.day;
          systemTime.wHour = (short)utc.hour;
          systemTime.wMinute = (short)utc.minute;
@@ -420,12 +427,9 @@ public:
 public class TimeStamp32 : uint32
 {
 public:
-   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
-      DateTime t = (SecSince1970)(int)this;
-      return t.OnGetString(tempString, fieldData, needClass);
-      // TOFIX:
-      // return ((DateTime)this).OnGetString(tempString, fieldData, needClass);
+      return ((DateTime)(TimeStamp)this).OnGetString(tempString, fieldData, needClass);
    }
 
    // Is this required?
@@ -508,7 +512,7 @@ public struct DateTime
          FILETIME fileTime, localFileTime;
 
          localTime.wYear = (short)year;
-         localTime.wMonth = (short)month + 1;
+         localTime.wMonth = (short)(month + 1);
          localTime.wDay = (short)day;
          localTime.wHour = (short)hour;
          localTime.wMinute = (short)minute;
@@ -550,7 +554,7 @@ public struct DateTime
          SYSTEMTIME systemTime, localTime;
 
          systemTime.wYear = (short)year;
-         systemTime.wMonth = (short)month + 1;
+         systemTime.wMonth = (short)(month + 1);
          systemTime.wDay = (short)day;
          systemTime.wHour = (short)hour;
          systemTime.wMinute = (short)minute;
@@ -660,10 +664,10 @@ public struct DateTime
          minute = 0;
          second = 0;
       }
-      get { return Date { year, month, day }; }
+      get { value = Date { year, month, day }; }
    }
 
-   char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
+   const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
    {
       static const char ampm[2][3] = { "AM", "PM" };
       int hour = this.hour;
@@ -681,7 +685,7 @@ public struct DateTime
       return stringOutput;
    }
 
-   bool OnGetDataFromString(char * string)
+   bool OnGetDataFromString(const char * string)
    {
       char * s = CopyString(string);
       char * tokens[20];
@@ -689,7 +693,7 @@ public struct DateTime
       int c;
       bool foundDayOfTheWeek = false;
       bool foundDate = false;
-      DayOfTheWeek dayOfTheWeek;
+      DayOfTheWeek dayOfTheWeek = 0;
       int day = 0;
       int minute = 0;
       int second = 0;