MCPcopy Create free account
hub / github.com/Icinga/icinga2 / make_tm

Function make_tm

test/utils.cpp:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <boost/test/unit_test.hpp>
12
13tm make_tm(std::string s)
14{
15 int dst = -1;
16 size_t l = strlen("YYYY-MM-DD HH:MM:SS");
17 if (s.size() > l) {
18 std::string zone = s.substr(l);
19 if (zone == " PST") {
20 dst = 0;
21 } else if (zone == " PDT") {
22 dst = 1;
23 } else {
24 // tests should only use PST/PDT (for now)
25 BOOST_CHECK_MESSAGE(false, "invalid or unknown time time: " << zone);
26 }
27 }
28
29 std::tm t = {};
30 std::istringstream stream(s);
31 stream >> std::get_time(&t, "%Y-%m-%d %H:%M:%S");
32 t.tm_isdst = dst;
33
34 return t;
35}
36
37#ifndef _WIN32
38const char *GlobalTimezoneFixture::TestTimezoneWithDST = "America/Los_Angeles";

Callers 3

make_time_tFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected