gnucash master: Use the right value to determine if the zone has a daylight time.

John Ralls jralls at code.gnucash.org
Sun Jul 10 21:28:59 EDT 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/c11185e9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/43a7cd09 (commit)



commit c11185e929bb920107daf6bb7daa1c62b53dcd4a
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Jul 11 01:26:01 2016 +0000

    Use the right value to determine if the zone has a daylight time.
    
    It's not Daylight offset.
    Also catch the now much less likely exception.

diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp
index 6946c98..18b981a 100644
--- a/src/libqof/qof/gnc-timezone.cpp
+++ b/src/libqof/qof/gnc-timezone.cpp
@@ -25,7 +25,7 @@
 
 #include <string>
 #include <cstdint>
-#include <istream>
+#include <iostream>
 #include <algorithm>
 #include <boost/date_time/gregorian/gregorian.hpp>
 #if PLATFORM(WINDOWS)
@@ -161,13 +161,25 @@ zone_from_regtzi (const RegTZI& regtzi, time_zone_names names)
     auto std_week_num = make_week_num(regtzi.StandardDate.wDay);
     auto dlt_week_num = make_week_num(regtzi.DaylightDate.wDay);
     calc_rule_ptr dates;
-    if (regtzi.DaylightBias != 0)
+    if (regtzi.StandardDate.wMonth != 0)
     {
-	ndate start (std_week_num, regtzi.StandardDate.wDayOfWeek,
-		     regtzi.StandardDate.wMonth);
-	ndate end(dlt_week_num, regtzi.DaylightDate.wDayOfWeek,
-		  regtzi.DaylightDate.wMonth);
-	dates.reset(new nth_day_rule (start, end));
+	try
+	{
+	    ndate start (std_week_num, regtzi.StandardDate.wDayOfWeek,
+			 regtzi.StandardDate.wMonth);
+	    ndate end(dlt_week_num, regtzi.DaylightDate.wDayOfWeek,
+		      regtzi.DaylightDate.wMonth);
+	    dates.reset(new nth_day_rule (start, end));
+	}
+	catch (boost::gregorian::bad_month& err)
+	{
+	    std::stringstream str;
+	    str << "Caught Bad Month Exception. Daylight Bias: " <<
+		regtzi.DaylightBias << " Standard Month : " <<
+		regtzi.StandardDate.wMonth << " Daylight Month: " <<
+		regtzi.DaylightDate.wMonth << "\n";
+	    PWARN(str.str().c_str());
+	}
     }
     return TZ_Ptr(new time_zone(names, std_off, offsets, dates));
 }



Summary of changes:
 src/libqof/qof/gnc-timezone.cpp | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list