diff --git a/include/of_util.h b/include/of_util.h index 2427828..4bbfd8e 100644 --- a/include/of_util.h +++ b/include/of_util.h @@ -48,6 +48,8 @@ public: static ofString now_time(); static ofString get_file_size(long long bytes); static ofString get_uuid(); + static uint64_t get_timestamp_ms(); + static uint64_t get_timestamp_s(); }; class CMutBuffer diff --git a/src/of_util.cpp b/src/of_util.cpp index c4ac551..79071f2 100644 --- a/src/of_util.cpp +++ b/src/of_util.cpp @@ -150,6 +150,20 @@ ofString OfUtil::get_uuid() #endif } +uint64_t OfUtil::get_timestamp_ms() +{ + auto now = std::chrono::system_clock::now(); + uint64_t ms = std::chrono::duration_cast(now.time_since_epoch()).count(); + return ms; +} + +uint64_t OfUtil::get_timestamp_s() +{ + auto now = std::chrono::system_clock::now(); + uint64_t s = std::chrono::duration_cast(now.time_since_epoch()).count(); + return s; +} + #ifdef _WIN32 std::string CCodec::u8_to_ansi(const std::string& str) {