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

Method load_data

src/tz.cpp:2186–2222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2184
2185template <class TimeType>
2186void
2187time_zone::load_data(std::istream& inf,
2188 std::int32_t tzh_leapcnt, std::int32_t tzh_timecnt,
2189 std::int32_t tzh_typecnt, std::int32_t tzh_charcnt)
2190{
2191 using namespace std::chrono;
2192 transitions_ = load_transitions<TimeType>(inf, tzh_timecnt);
2193 auto indices = load_indices(inf, tzh_timecnt);
2194 auto infos = load_ttinfo(inf, tzh_typecnt);
2195 auto abbrev = load_abbreviations(inf, tzh_charcnt);
2196#if !MISSING_LEAP_SECONDS
2197 auto& leap_seconds = get_tzdb_list().front().leap_seconds;
2198 if (leap_seconds.empty() && tzh_leapcnt > 0)
2199 leap_seconds = load_leaps<TimeType>(inf, tzh_leapcnt);
2200#endif
2201 ttinfos_.reserve(infos.size());
2202 for (auto& info : infos)
2203 {
2204 ttinfos_.push_back({seconds{info.tt_gmtoff},
2205 abbrev.c_str() + info.tt_abbrind,
2206 info.tt_isdst != 0});
2207 }
2208 auto i = 0u;
2209 if (transitions_.empty() || transitions_.front().timepoint != min_seconds)
2210 {
2211 transitions_.emplace(transitions_.begin(), min_seconds);
2212 auto tf = std::find_if(ttinfos_.begin(), ttinfos_.end(),
2213 [](const expanded_ttinfo& ti)
2214 {return ti.is_dst == 0;});
2215 if (tf == ttinfos_.end())
2216 tf = ttinfos_.begin();
2217 transitions_[i].info = &*tf;
2218 ++i;
2219 }
2220 for (auto j = 0u; i < transitions_.size(); ++i, ++j)
2221 transitions_[i].info = ttinfos_.data() + indices[j];
2222}
2223
2224void
2225time_zone::init_impl()

Callers

nothing calls this directly

Calls 4

load_indicesFunction · 0.85
load_ttinfoFunction · 0.85
load_abbreviationsFunction · 0.85
dataMethod · 0.80

Tested by

no test coverage detected