ecere: Initial Emscripten support
[sdk] / ecere / src / sys / Time.ec
index c586035..1af3f14 100644 (file)
@@ -1,5 +1,7 @@
 namespace sys;
 
+#define _Noreturn
+
 #define set _set
 #define Date _Date
 #define uint _uint
@@ -83,7 +85,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;
@@ -296,6 +298,17 @@ public class SecSince1970 : int64
       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?
    int OnCompare(SecSince1970 data2)
    {
@@ -322,7 +335,7 @@ public:
          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;
@@ -374,7 +387,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;
@@ -418,7 +431,7 @@ public class TimeStamp32 : uint32
 public:
    const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
-      return ((DateTime)this).OnGetString(tempString, fieldData, needClass);
+      return ((DateTime)(TimeStamp)this).OnGetString(tempString, fieldData, needClass);
    }
 
    // Is this required?
@@ -501,7 +514,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;
@@ -543,7 +556,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;
@@ -682,7 +695,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;