MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / Iso8601ToUnix

Function Iso8601ToUnix

src/platform/linux/http_util.cpp:54–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54int64_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
68std::string UnixToIso8601(int64_t ts) {
69 time_t t = (time_t)ts;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected