Fix date/time getter functions

Values returned by SACT2.System_GetDate etc. should correspond to the
Windows SYSTEMTIME structure, not struct tm.

This also fixes a bug where get_time() returns a value greater than 60
for `sec`.
This commit is contained in:
kichikuou
2022-05-08 14:20:45 +09:00
parent b499c432fd
commit 03f23c4339
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ static int File_GetTime(struct string *filename, struct page **page)
}
date[0].i = tm->tm_year + 1900;
date[1].i = tm->tm_mon;
date[1].i = tm->tm_mon + 1;
date[2].i = tm->tm_mday;
date[3].i = tm->tm_hour;
date[4].i = tm->tm_min;
+3 -3
View File
@@ -152,8 +152,8 @@ void get_date(int *year, int *month, int *mday, int *wday)
time_t t = time(NULL);
struct tm *tm = localtime(&t);
*year = tm->tm_year;
*month = tm->tm_mon;
*year = tm->tm_year + 1900;
*month = tm->tm_mon + 1;
*mday = tm->tm_mday;
*wday = tm->tm_wday;
}
@@ -167,6 +167,6 @@ void get_time(int *hour, int *min, int *sec, int *ms)
*hour = tm->tm_hour;
*min = tm->tm_min;
*sec = ts.tv_sec;
*sec = tm->tm_sec;
*ms = ts.tv_nsec / 1000000;
}