From b6489395e103929445d78f9a8145cf62262fd82e Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 16 May 2014 10:34:31 +1000 Subject: Move timeDiff() to LumbrJack, it has more than one user now. --- src/libraries/LumbrJack.c | 24 ++++++++++++++++++++++++ src/libraries/LumbrJack.h | 2 ++ src/love/love.c | 24 ------------------------ 3 files changed, 26 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/libraries/LumbrJack.c b/src/libraries/LumbrJack.c index e873d02..8d08622 100644 --- a/src/libraries/LumbrJack.c +++ b/src/libraries/LumbrJack.c @@ -86,3 +86,27 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); return (dateTime); } + +float timeDiff(struct timeval *now, struct timeval *then) +{ + if (0 == gettimeofday(now, 0)) + { + struct timeval thisTime = { 0, 0 }; + double result = 0.0; + + thisTime.tv_sec = now->tv_sec; + thisTime.tv_usec = now->tv_usec; + if (thisTime.tv_usec < then->tv_usec) + { + thisTime.tv_sec--; + thisTime.tv_usec += 1000000; + } + thisTime.tv_usec -= then->tv_usec; + thisTime.tv_sec -= then->tv_sec; + result = ((double) thisTime.tv_usec) / ((double) 1000000.0); + result += thisTime.tv_sec; + return result; + } + else + return 0.0; +} diff --git a/src/libraries/LumbrJack.h b/src/libraries/LumbrJack.h index a096e7f..1912bef 100644 --- a/src/libraries/LumbrJack.h +++ b/src/libraries/LumbrJack.h @@ -33,5 +33,7 @@ typedef enum int loggingStartup(char *name, int logDom); char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); +float timeDiff(struct timeval *now, struct timeval *then); + #endif diff --git a/src/love/love.c b/src/love/love.c index efb686a..183e20e 100644 --- a/src/love/love.c +++ b/src/love/love.c @@ -74,30 +74,6 @@ static const char *names[] = }; -static float timeDiff(struct timeval *now, struct timeval *then) -{ - if (0 == gettimeofday(now, 0)) - { - struct timeval thisTime = { 0, 0 }; - double result = 0.0; - - thisTime.tv_sec = now->tv_sec; - thisTime.tv_usec = now->tv_usec; - if (thisTime.tv_usec < then->tv_usec) - { - thisTime.tv_sec--; - thisTime.tv_usec += 1000000; - } - thisTime.tv_usec -= then->tv_usec; - thisTime.tv_sec -= then->tv_sec; - result = ((double) thisTime.tv_usec) / ((double) 1000000.0); - result += thisTime.tv_sec; - return result; - } - else - return 0.0; -} - static void _edje_signal_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { -- cgit v1.1