libc: Add difftime()

This commit is contained in:
apio 2022-11-06 15:09:38 +01:00
parent 2980ee3973
commit 04ae97a6ec
2 changed files with 8 additions and 0 deletions

View File

@ -77,6 +77,9 @@ extern "C"
/* Fills str with a formatted string representation of time according to the format string. */
size_t strftime(char* str, size_t max, const char* format, const struct tm* time);
/* Returns the difference between two times. */
double difftime(time_t time2, time_t time1);
#ifdef __cplusplus
}
#endif

View File

@ -175,4 +175,9 @@ extern "C"
{
return broken_down_to_unix(time->tm_year, time->tm_yday, time->tm_hour, time->tm_min, time->tm_sec);
}
double difftime(time_t time2, time_t time1)
{
return (double)(time2 - time1);
}
}