MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / FormatEpochTimeInMillisAsRFC3339

Function FormatEpochTimeInMillisAsRFC3339

tests/gtest/gtest-all.cc:5549–5560  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

5547// Converts the given epoch time in milliseconds to a date string in the
5548// RFC3339 format, without the timezone information.
5549static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) {
5550 struct tm time_struct;
5551 if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
5552 return "";
5553 // YYYY-MM-DDThh:mm:ss
5554 return StreamableToString(time_struct.tm_year + 1900) + "-" +
5555 String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
5556 String::FormatIntWidth2(time_struct.tm_mday) + "T" +
5557 String::FormatIntWidth2(time_struct.tm_hour) + ":" +
5558 String::FormatIntWidth2(time_struct.tm_min) + ":" +
5559 String::FormatIntWidth2(time_struct.tm_sec) + "Z";
5560}
5561
5562static inline std::string Indent(size_t width) {
5563 return std::string(width, ' ');

Callers 1

PrintJsonUnitTestMethod · 0.85

Calls 2

PortableLocaltimeFunction · 0.85
StreamableToStringFunction · 0.85

Tested by

no test coverage detected