MCPcopy Create free account
hub / github.com/Haivision/srt / FormatTimeSys

Function FormatTimeSys

srtcore/sync.cpp:63–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63std::string FormatTimeSys(const steady_clock::time_point& timestamp)
64{
65 const time_t now_s = ::time(NULL); // get current time in seconds
66 const steady_clock::time_point now_timestamp = steady_clock::now();
67 const int64_t delta_us = count_microseconds(timestamp - now_timestamp);
68 const int64_t delta_s =
69 static_cast<int64_t>(floor((static_cast<double>(count_microseconds(now_timestamp.time_since_epoch()) % 1000000) + delta_us) / 1000000.0));
70 const time_t tt = now_s + delta_s;
71 struct tm tm = SysLocalTime(tt); // in seconds
72 char tmp_buf[512];
73 strftime(tmp_buf, 512, "%X.", &tm);
74
75 ostringstream out;
76 out << tmp_buf << setfill('0') << setw(6) << (count_microseconds(timestamp.time_since_epoch()) % 1000000) << " [SYST]";
77 return out.str();
78}
79
80
81#ifdef ENABLE_STDCXX_SYNC

Callers 6

create_fileMethod · 0.85
traceMethod · 0.85
create_fileMethod · 0.85
create_fileMethod · 0.85
create_fileMethod · 0.85
TESTFunction · 0.85

Calls 4

count_microsecondsFunction · 0.85
SysLocalTimeFunction · 0.85
time_since_epochMethod · 0.80
strMethod · 0.45

Tested by 1

TESTFunction · 0.68