| 180 | } |
| 181 | |
| 182 | inline bool getDateTimeStr(int64_t unix_timestamp, std::string& date_time_str) { |
| 183 | if (unix_timestamp > (std::numeric_limits<time_t>::max)() || unix_timestamp < (std::numeric_limits<time_t>::lowest)()) { |
| 184 | return false; |
| 185 | } |
| 186 | time_t time = static_cast<time_t>(unix_timestamp); |
| 187 | struct tm* gmt = gmtime(&time); // NOLINT |
| 188 | if (gmt == nullptr) { |
| 189 | return false; |
| 190 | } |
| 191 | std::array<char, 64U> buf; |
| 192 | if (strftime(buf.data(), buf.size(), "%Y-%m-%dT%H:%M:%SZ", gmt) == 0U) { |
| 193 | return false; |
| 194 | } |
| 195 | |
| 196 | date_time_str = buf.data(); |
| 197 | return true; |
| 198 | } |
| 199 | |
| 200 | } /* namespace timeutils */ |
| 201 | } /* namespace utils */ |
no test coverage detected