MCPcopy Create free account
hub / github.com/VitalAudio/visage / formatTime

Function formatTime

visage_utils/time_utils.cpp:25–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24namespace visage::time {
25 std::string formatTime(const Time& time, const char* format_string) {
26 static constexpr int kMaxLength = 100;
27
28 auto t = std::chrono::system_clock::to_time_t(time);
29 tm time_info {};
30#if VISAGE_WINDOWS
31 localtime_s(&time_info, &t);
32#else
33 localtime_r(&t, &time_info);
34#endif
35
36 char buffer[kMaxLength];
37 if (std::strftime(buffer, kMaxLength, format_string, &time_info) == 0)
38 return "";
39
40 return buffer;
41 }
42}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected