MCPcopy Create free account
hub / github.com/catboost/catboost / PrintLocalTimeS

Function PrintLocalTimeS

library/cpp/logger/global/rty_formater.cpp:14–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 constexpr size_t LocalTimeSBufferSize = sizeof("2017-07-24 12:20:34.313 +0300");
13
14 size_t PrintLocalTimeS(const TInstant instant, char* const begin, const char* const end) {
15 Y_ABORT_UNLESS(static_cast<size_t>(end - begin) >= LocalTimeSBufferSize);
16
17 struct tm tm;
18 instant.LocalTime(&tm);
19
20 // both stftime and snprintf exclude the terminating null byte from the return value
21 char* pos = begin;
22 pos += strftime(pos, end - pos, "%Y-%m-%d %H:%M:%S.", &tm);
23 pos += snprintf(pos, end - pos, "%03" PRIu32, instant.MilliSecondsOfSecond());
24 pos += strftime(pos, end - pos, " %z", &tm);
25 Y_ABORT_UNLESS(LocalTimeSBufferSize - 1 == pos - begin); // together with Y_ABORT_UNLESS above this also implies pos<=end
26 return (pos - begin);
27 }
28}
29
30namespace NLoggingImpl {

Callers 1

rty_formater.cppFile · 0.85

Calls 3

MilliSecondsOfSecondMethod · 0.80
snprintfFunction · 0.50
LocalTimeMethod · 0.45

Tested by

no test coverage detected