forked from HowardHinnant/date
Fix rule finding logic for falling off the front of the rule list
This commit is contained in:
19
tz.cpp
19
tz.cpp
@@ -1007,6 +1007,22 @@ find_next_rule(const Rule* r, date::year y)
|
||||
return {r, y};
|
||||
}
|
||||
|
||||
static
|
||||
const Rule*
|
||||
find_first_std_rule(const std::pair<const Rule*, const Rule*>& eqr)
|
||||
{
|
||||
auto r = eqr.first;
|
||||
auto ry = r->starting_year();
|
||||
while (r->save() != std::chrono::minutes{0})
|
||||
{
|
||||
std::tie(r, ry) = find_next_rule(eqr.first, eqr.second, r, ry);
|
||||
if (r == nullptr)
|
||||
throw std::runtime_error("Could not find standard offset in rule "
|
||||
+ eqr.first->name());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static
|
||||
std::pair<const Rule*, date::year>
|
||||
find_rule_for_zone(const std::pair<const Rule*, const Rule*>& eqr,
|
||||
@@ -1218,7 +1234,10 @@ Zone::adjust_infos(const std::vector<Rule>& rules)
|
||||
}
|
||||
}
|
||||
if (z.first_rule_.first == nullptr && z.last_rule_.first != nullptr)
|
||||
{
|
||||
z.first_rule_ = std::make_pair(eqr.first, eqr.first->starting_year());
|
||||
z.initial_abbrev_ = find_first_std_rule(eqr)->abbrev();
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
Reference in New Issue
Block a user