| 52 | } |
| 53 | |
| 54 | int64_t Iso8601ToUnix(const std::string& iso) { |
| 55 | struct tm t{}; |
| 56 | if (sscanf(iso.c_str(), "%d-%d-%dT%d:%d:%d", |
| 57 | &t.tm_year, &t.tm_mon, &t.tm_mday, |
| 58 | &t.tm_hour, &t.tm_min, &t.tm_sec) < 6) { |
| 59 | return 0; |
| 60 | } |
| 61 | t.tm_year -= 1900; |
| 62 | t.tm_mon -= 1; |
| 63 | time_t raw = timegm(&t); |
| 64 | if (raw == static_cast<time_t>(-1)) return 0; |
| 65 | return static_cast<int64_t>(raw); |
| 66 | } |
| 67 | |
| 68 | std::string UnixToIso8601(int64_t ts) { |
| 69 | time_t t = (time_t)ts; |
nothing calls this directly
no outgoing calls
no test coverage detected