MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / FormatEpochTimeInMillisAsIso8601

Function FormatEpochTimeInMillisAsIso8601

test/common/gtest/gtest.cpp:5014–5025  ·  view source on GitHub ↗

Converts the given epoch time in milliseconds to a date string in the ISO 8601 format, without the timezone information.

Source from the content-addressed store, hash-verified

5012// Converts the given epoch time in milliseconds to a date string in the ISO
5013// 8601 format, without the timezone information.
5014std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {
5015 struct tm time_struct;
5016 if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
5017 return "";
5018 // YYYY-MM-DDThh:mm:ss
5019 return StreamableToString(time_struct.tm_year + 1900) + "-" +
5020 String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
5021 String::FormatIntWidth2(time_struct.tm_mday) + "T" +
5022 String::FormatIntWidth2(time_struct.tm_hour) + ":" +
5023 String::FormatIntWidth2(time_struct.tm_min) + ":" +
5024 String::FormatIntWidth2(time_struct.tm_sec);
5025}
5026
5027// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
5028void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,

Callers 1

PrintXmlUnitTestMethod · 0.85

Calls 2

PortableLocaltimeFunction · 0.85
StreamableToStringFunction · 0.85

Tested by

no test coverage detected