Converts |out_time| to a string, and returns it. |utc| determines whether the converted time will reference local time or UTC. If |out_time| is 0, the string "never" will be returned as a special case.
| 203 | // converted time will reference local time or UTC. If |out_time| is 0, the |
| 204 | // string "never" will be returned as a special case. |
| 205 | std::string TimeToString(time_t out_time, bool utc) { |
| 206 | if (out_time == 0) { |
| 207 | return std::string("never"); |
| 208 | } |
| 209 | |
| 210 | tm time_tm; |
| 211 | if (utc) { |
| 212 | PCHECK(gmtime_r(&out_time, &time_tm)); |
| 213 | } else { |
| 214 | PCHECK(localtime_r(&out_time, &time_tm)); |
| 215 | } |
| 216 | |
| 217 | char string[64]; |
| 218 | CHECK_NE( |
| 219 | strftime(string, std::size(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm), |
| 220 | 0u); |
| 221 | |
| 222 | return std::string(string); |
| 223 | } |
| 224 | |
| 225 | // Shows information about a single |report|. |space_count| is the number of |
| 226 | // spaces to print before each line that is printed. |utc| determines whether |
no test coverage detected