diff --git a/libs/libc/include/time.h b/libs/libc/include/time.h index 3921b6ff..1e66f35a 100644 --- a/libs/libc/include/time.h +++ b/libs/libc/include/time.h @@ -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 diff --git a/libs/libc/src/time.cpp b/libs/libc/src/time.cpp index 4643eec5..f6516871 100644 --- a/libs/libc/src/time.cpp +++ b/libs/libc/src/time.cpp @@ -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); + } } \ No newline at end of file