MCPcopy Create free account
hub / github.com/USBGuard/usbguard / stringToDaytime

Method stringToDaytime

src/Library/LocaltimeCondition.cpp:113–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 std::time_t LocaltimeCondition::stringToDaytime(const std::string& string)
114 {
115 USBGUARD_LOG(Trace) << "string=" << string;
116 struct ::tm tm = { };
117
118 if (::strptime(string.c_str(), "%H:%M:%s", &tm) == nullptr) {
119 if (::strptime(string.c_str(), "%H:%M", &tm) == nullptr) {
120 throw Exception("LocaltimeCondition", "Invalid time or range format", string);
121 }
122 }
123
124 USBGUARD_LOG(Trace) << "tm=" << tmToString(&tm);
125 return tm.tm_sec + 60*tm.tm_min + 60*60*tm.tm_hour;
126 }
127} /* namespace usbguard */
128
129/* vim: set ts=2 sw=2 et */

Callers

nothing calls this directly

Calls 1

ExceptionFunction · 0.85

Tested by

no test coverage detected