MCPcopy Create free account
hub / github.com/HowardHinnant/date / tzmain

Function tzmain

test/tz_test/validate.cpp:85–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85void
86tzmain()
87{
88 using namespace date;
89 using namespace std::chrono;
90 auto& db = get_tzdb();
91 std::vector<std::string> names;
92#if USE_OS_TZDB
93 names.reserve(db.zones.size());
94 for (auto& zone : db.zones)
95 names.push_back(zone.name());
96#else // !USE_OS_TZDB
97 names.reserve(db.zones.size() + db.links.size());
98 for (auto& zone : db.zones)
99 names.push_back(zone.name());
100 for (auto& link : db.links)
101 names.push_back(link.name());
102 std::sort(names.begin(), names.end());
103#endif // !USE_OS_TZDB
104 std::cout << db.version << "\n\n";
105 for (auto const& name : names)
106 {
107 std::cout << name << '\n';
108 auto z = locate_zone(name);
109 auto begin = sys_days(jan/1/date::year::min()) + seconds{0};
110 auto end = sys_days(jan/1/2035) + seconds{0};
111 auto info = z->get_info(begin);
112 std::cout << "Initially: ";
113 if (info.offset >= seconds{0})
114 std::cout << '+';
115 std::cout << make_time(info.offset);
116 if (info.save == minutes{0})
117 std::cout << " standard ";
118 else
119 std::cout << " daylight ";
120 std::cout << info.abbrev << '\n';
121 test_info(z, info);
122 auto prev_offset = info.offset;
123 auto prev_abbrev = info.abbrev;
124 auto prev_save = info.save;
125 for (begin = info.end; begin < end; begin = info.end)
126 {
127 info = z->get_info(begin);
128 test_info(z, info);
129 if (info.offset == prev_offset && info.abbrev == prev_abbrev &&
130 info.save == prev_save)
131 continue;
132 auto dp = floor<days>(begin);
133 auto ymd = date::year_month_day(dp);
134 auto time = make_time(begin - dp);
135 std::cout << ymd << ' ' << time << "Z ";
136 if (info.offset >= seconds{0})
137 std::cout << '+';
138 std::cout << make_time(info.offset);
139 if (info.save == minutes{0})
140 std::cout << " standard ";
141 else
142 std::cout << " daylight ";

Callers 1

mainFunction · 0.85

Calls 5

locate_zoneFunction · 0.85
test_infoFunction · 0.85
nameMethod · 0.80
year_month_dayClass · 0.50
get_infoMethod · 0.45

Tested by

no test coverage detected