From 0b55c746c866f21a324c2667d008914c075707ac Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 4 May 2015 15:52:35 -0700 Subject: [PATCH 1/2] Link libgtest to test-kvp-value on Fedora. --- src/libqof/qof/test/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libqof/qof/test/Makefile.am b/src/libqof/qof/test/Makefile.am index f81ddc08af..6d179539a0 100644 --- a/src/libqof/qof/test/Makefile.am +++ b/src/libqof/qof/test/Makefile.am @@ -40,7 +40,8 @@ test_kvp_value_SOURCES = \ test-kvp-frame.cpp test_kvp_value_LDADD = \ $(top_builddir)/$(MODULEPATH)/libgnc-qof.la \ - $(GLIB_LIBS) \ + $(GLIB_LIBS) \ + $(GTEST_LIBS) \ $(BOOST_LDFLAGS) if !GOOGLE_TEST_LIBS @@ -50,7 +51,7 @@ test_kvp_value_LDADD += $(top_builddir)/src/test-core/libgtest.a endif test_kvp_value_CPPFLAGS = \ - -I$(GTEST_HEADERS) \ + $(GTEST_HEADERS) \ -I$(top_srcdir)/$(MODULEPATH) \ $(GLIB_CFLAGS) \ $(BOOST_CPPFLAGS) @@ -62,8 +63,7 @@ test_gnc_int128_SOURCES = \ gtest-gnc-int128.cpp test_gnc_int128_CPPFLAGS = -I${GTEST_HEADERS} - -test_gnc_int128_LDADD = $(GTEST_LIBS) +test_gnc_int128_LDADD = ${GTEST_LIBS} if !GOOGLE_TEST_LIBS nodist_test_gnc_int128_SOURCES = \ ${GTEST_SRC}/src/gtest_main.cc From 577aa3fe02acb982c9e3063b096219107097dc5b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 4 May 2015 15:53:23 -0700 Subject: [PATCH 2/2] Catch out-of-range exception at beginning and end of TZFile on Fedora. --- src/libqof/qof/gnc-timezone.cpp | 55 +++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 24 deletions(-) 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;