diff --git a/src/lib/utils/clock.cpp b/src/lib/utils/clock.cpp index 60bb27f0..1befe810 100755 --- a/src/lib/utils/clock.cpp +++ b/src/lib/utils/clock.cpp @@ -44,4 +44,10 @@ void clockGettime(struct timespec* t) { #endif } +long long clockGetMillis() { + struct timespec t; + clockGettime(&t); + return t.tv_sec*1000LL + t.tv_nsec / 1000000; +} + } // namespace ebusd diff --git a/src/lib/utils/clock.h b/src/lib/utils/clock.h index 6d2f75ed..7f046433 100755 --- a/src/lib/utils/clock.h +++ b/src/lib/utils/clock.h @@ -31,6 +31,11 @@ namespace ebusd { */ void clockGettime(struct timespec* t); +/** + * Get the current system time in milliseconds since the Epoch. + */ +long long clockGetMillis(); + } // namespace ebusd #endif // LIB_UTILS_CLOCK_H_