add:添加获取时间戳

This commit is contained in:
taynpg 2025-04-07 23:11:32 +08:00
parent f6bc83b0de
commit 931380105b
2 changed files with 16 additions and 0 deletions

View File

@ -48,6 +48,8 @@ public:
static ofString now_time(); static ofString now_time();
static ofString get_file_size(long long bytes); static ofString get_file_size(long long bytes);
static ofString get_uuid(); static ofString get_uuid();
static uint64_t get_timestamp_ms();
static uint64_t get_timestamp_s();
}; };
class CMutBuffer class CMutBuffer

View File

@ -150,6 +150,20 @@ ofString OfUtil::get_uuid()
#endif #endif
} }
uint64_t OfUtil::get_timestamp_ms()
{
auto now = std::chrono::system_clock::now();
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(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<std::chrono::seconds>(now.time_since_epoch()).count();
return s;
}
#ifdef _WIN32 #ifdef _WIN32
std::string CCodec::u8_to_ansi(const std::string& str) std::string CCodec::u8_to_ansi(const std::string& str)
{ {