Browse Source

Merge pull request #74 from bmx-ng/task/fix-stdc-timet

Use time_t directly.
Brucey 8 months ago
parent
commit
6a9fc292b9
1 changed files with 6 additions and 4 deletions
  1. 6 4
      stdc.mod/stdc.c

+ 6 - 4
stdc.mod/stdc.c

@@ -1164,11 +1164,12 @@ BBULONG bmx_current_unix_time() {
 
 int bmx_datetime_from_local_epoch(BBLONG epoch, SDateTime* dt) {
     struct tm* local;
+	time_t time = (time_t)epoch;
 #if defined(__linux__) || defined(__APPLE__)
     struct tm result;
-    local = localtime_r(&epoch, &result);
+    local = localtime_r(&time, &result);
 #elif defined(_WIN32) || defined(_WIN64)
-    local = localtime(&epoch);
+    local = localtime(&time);
 #else
     return -1; // Platform not supported
 #endif
@@ -1208,11 +1209,12 @@ SDateTime bmx_datetime_from_epoch(BBLONG epochTimeSecs, BBLONG fracNanoseconds,
 	}
 
     struct tm timeinfo;
+	time_t time = (time_t)epochTimeSecs;
 
 #if defined(_WIN32) || defined(_WIN64)
-    gmtime_s(&timeinfo, &epochTimeSecs);
+    gmtime_s(&timeinfo, &time);
 #else
-    gmtime_r(&epochTimeSecs, &timeinfo);
+    gmtime_r(&time, &timeinfo);
 #endif
 
     dt.year = timeinfo.tm_year + 1900;