diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp index 7cc3b56687..b244b91d58 100644 --- a/src/libqof/qof/gnc-timezone.cpp +++ b/src/libqof/qof/gnc-timezone.cpp @@ -562,33 +562,40 @@ TimeZoneProvider::TimeZoneProvider(const std::string& tzname) : zone_vector {} auto this_time = ptime(date(1970, 1, 1), time_duration(txi->timestamp / 3600, 0, txi->timestamp % 3600)); - auto this_year = this_time.date().year(); - //Initial case - if (last_time.is_not_a_date_time()) - zone_vector.push_back(zone_no_dst(this_year - 1, last_info)); - //gap in transitions > 1 year, non-dst zone - //change. In the last case the exact date of the change will be - //wrong because boost::local_date::timezone isn't able to - //represent it. For GnuCash's purposes this isn't likely to be - //important as the last time this sort of transition happened - //was 1946, but we have to handle the case in order to parse - //the tz file. - else if (this_year - last_time.date().year() > 1 || - last_info->info.isdst == this_info->info.isdst) + try { - zone_vector.push_back(zone_no_dst(this_year, last_info)); - } - - else - { - DSTRule::DSTRule new_rule(last_info, this_info, - last_time, this_time); - if (new_rule != last_rule) + auto this_year = this_time.date().year(); + //Initial case + if (last_time.is_not_a_date_time()) + zone_vector.push_back(zone_no_dst(this_year - 1, last_info)); + //gap in transitions > 1 year, non-dst zone + //change. In the last case the exact date of the change will be + //wrong because boost::local_date::timezone isn't able to + //represent it. For GnuCash's purposes this isn't likely to be + //important as the last time this sort of transition happened + //was 1946, but we have to handle the case in order to parse + //the tz file. + else if (this_year - last_time.date().year() > 1 || + last_info->info.isdst == this_info->info.isdst) { - last_rule = new_rule; - zone_vector.push_back(zone_from_rule (this_time.date().year(), - new_rule)); + zone_vector.push_back(zone_no_dst(this_year, last_info)); } + + else + { + DSTRule::DSTRule new_rule(last_info, this_info, + last_time, this_time); + if (new_rule != last_rule) + { + last_rule = new_rule; + zone_vector.push_back(zone_from_rule (this_time.date().year(), + new_rule)); + } + } + } + catch(boost::gregorian::bad_year err) + { + continue; } last_time = this_time; last_info = this_info;