From da543673d966567f77bcf9bd4a38d530e7bad3f3 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 9 Aug 2024 11:03:57 +0100 Subject: [PATCH] Add STIMESTAMP_MS --- libstuff/STime.cpp | 7 +++++-- libstuff/libstuff.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libstuff/STime.cpp b/libstuff/STime.cpp index 224ae6846..64cf13430 100644 --- a/libstuff/STime.cpp +++ b/libstuff/STime.cpp @@ -58,8 +58,7 @@ timeval SToTimeval(uint64_t when) { return {(time_t)(when / STIME_US_PER_S), (suseconds_t)(when % STIME_US_PER_S)}; } -string SCURRENT_TIMESTAMP_MS() { - uint64_t time = STimeNow(); +string STIMESTAMP_MS(uint64_t time) { uint64_t ms = (time % 1'000'000) / 1'000; string timestamp = SUNQUOTED_TIMESTAMP(time); char msString[5] = {0}; @@ -67,6 +66,10 @@ string SCURRENT_TIMESTAMP_MS() { return timestamp + "." + msString; } +string SCURRENT_TIMESTAMP_MS() { + return STIMESTAMP_MS(STimeNow()); +} + string SFirstOfMonth(const string& timeStamp, const int64_t& offset) { list parts = SParseList(timeStamp, '-'); diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index e00bed0b7..d881de440 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -617,6 +617,7 @@ string STIMESTAMP(uint64_t when); string SUNQUOTED_CURRENT_TIMESTAMP(); string SCURRENT_TIMESTAMP(); string SCURRENT_TIMESTAMP_MS(); +string STIMESTAMP_MS(uint64_t time); // -------------------------------------------------------------------------- // Miscellaneous stuff