summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-02-11 02:34:38 +0800
committerMeco Man <[email protected]>2021-02-11 02:34:38 +0800
commitd67d4d3fd0ae292677cee9cf9a4d2bb5b5eefb1a (patch)
tree74bc7810118cc931144e6cee996229f584f8c293 /components
parent51cb109cf8386088368469769d14b1d039551dd1 (diff)
add difftime()
Diffstat (limited to 'components')
-rw-r--r--components/libc/compilers/common/time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 68cd7f0837..366bc28bd1 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -12,6 +12,7 @@
* 2021-02-08 Meco Man add settimeofday() stime()
* 2021-02-10 Meco Man add ctime_r() and re-implement ctime()
* 2021-02-11 Meco Man fix bug #3183 - align days[] and months[] to 4 bytes
+ * add difftime()
*/
#include <sys/time.h>
@@ -163,6 +164,11 @@ char* ctime(const time_t *tim_p)
return asctime (localtime (tim_p));
}
+double difftime (time_t tim1, time_t tim2)
+{
+ return (double)(tim1 - tim2);
+}
+
/**
* Returns the current time.
*