Branch Coverage

src/panda/time/timezone.cc
Criterion Covered Total %
branch 71 122 58.2


line true false branch
22 0 38150 if (!_localzone) tzset();
0 0 if (!_localzone) tzset();
27 1 1368 if (!zonename.length()) return tzlocal();
1 0 if (!zonename.length()) return tzlocal();
28 1368 0 auto it = _tzcache.find(zonename);
29 67 1301 if (it != _tzcache.cend()) return it->second;
30 1301 0 auto strname = string(zonename);
31 1301 0 auto zone = _tzget(strname);
32 1301 0 _tzcache.emplace(strname, zone);
38 109 3 if (zn) zone = zn;
109 0 if (zn) zone = zn;
41 2 1 string_view etzname = s ? s : "";
42 2 1 if (etzname.length()) zone = tzget(etzname);
2 0 if (etzname.length()) zone = tzget(etzname);
43 1 0 else zone = _tzget("");
45 8 104 if (_localzone == zone) return;
46 79 25 if (_localzone) _localzone->is_local = false;
47 104 0 _localzone = zone;
48 104 8 _localzone->is_local = true;
52 108 3 if (zonename.length()) tzset(tzget(zonename));
108 0 if (zonename.length()) tzset(tzget(zonename));
53 3 0 else tzset();
56 1303 1 const string& tzdir () { return _tzdir ? _tzdir : tzsysdir(); }
66 1302 0 auto zonename = string(zname);
68 1302 0 auto zone = new Timezone();
1302 0 auto zone = new Timezone();
71 1 1301 if (!zonename.length()) {
72 1 0 zonename = tz_lzname();
1 0 zonename = tz_lzname();
74 0 1 assert(zonename.length());
77 0 1302 if (zonename.length() > TZNAME_MAX) {
79 0 0 _virtual_fallback(zone);
84 1302 0 if (zonename.front() == ':') {
1 1301 if (zonename.front() == ':') {
85 1 0 filename = zonename.substr(1);
1 0 filename = zonename.substr(1);
86 1 0 zone->name = zonename;
89 1301 0 string dir = tzdir();
1301 0 string dir = tzdir();
90 0 1301 if (!dir) {
91 0 0 fprintf(stderr, "ptime: tzget: this OS has no olson timezone files, you must explicitly set tzdir(DIR)\n");
92 0 0 _virtual_fallback(zone);
95 1301 0 zone->name = zonename;
96 1301 0 filename = dir + '/' + zonename;
1301 0 filename = dir + '/' + zonename;
1301 0 filename = dir + '/' + zonename;
1301 0 filename = dir + '/' + zonename;
99 1302 0 string content = readfile(filename);
101 51 1251 if (!content) { // tz rule
103 51 0 if (!_virtual_zone(zonename, zone)) {
29 22 if (!_virtual_zone(zonename, zone)) {
105 29 0 _virtual_fallback(zone);
111 1251 0 bool result = tzparse(content, zone);
112 0 1251 if (!result) {
114 0 0 _virtual_fallback(zone);
124 29 0 assert(_virtual_zone(GMT_FALLBACK, zone) == true);
0 29 assert(_virtual_zone(GMT_FALLBACK, zone) == true);
131 29 51 if (!tzparse_rule(zonename, &zone->future)) return false;
140 51 0 zone->trans = new Timezone::Transition[zone->trans_cnt];
154 26 0 }}
26 0 }}