| 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 | |
| 30 | namespace NLoggingImpl { |
no test coverage detected