From 67a0e46f18164e5689216d130f94d3d0344dc98d Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 13 Jan 2017 14:54:12 -0800 Subject: [PATCH] Fix local timezone-dependent test. --- .travis.yml | 1 - src/libqof/qof/gnc-timezone.cpp | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1cdd17c58d..8bdfe89ce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,4 +19,3 @@ install: - sudo apt-get --reinstall install -qq language-pack-en language-pack-fr - git clone https://github.com/google/googletest ~/gtest && cd ~/gtest && git checkout release-1.8.0 && cd - script: ./autogen.sh && ./configure GTEST_ROOT=~/gtest/googletest GMOCK_ROOT=~/gtest/googlemock && make && TZ="America/Los_Angeles" make check -after_failure: "cat src/libqof/qof/test/test-gnc-timezone.log" \ No newline at end of file diff --git a/src/libqof/qof/gnc-timezone.cpp b/src/libqof/qof/gnc-timezone.cpp index f2e8538286..3a8e14bed8 100644 --- a/src/libqof/qof/gnc-timezone.cpp +++ b/src/libqof/qof/gnc-timezone.cpp @@ -681,16 +681,24 @@ TimeZoneProvider::TimeZoneProvider(const std::string& tzname) : zone_vector {} } catch(const std::exception& err) { - std::cerr << "Unable to use either provided tzname or TZ environment variable. Resorting to /etc/localtime.\n"; try { - parse_file("/etc/localtime"); + parse_file(getenv("TZ")); } - catch(const std::invalid_argument& env) + catch(const std::exception& err) { - std::cerr << "/etc/localtime invalid, resorting to GMT."; - TZ_Ptr zone(new PTZ("UTC0")); - zone_vector.push_back(std::make_pair(max_year, zone)); + + std::cerr << "Unable to use either provided tzname or TZ environment variable. Resorting to /etc/localtime.\n"; + try + { + parse_file("/etc/localtime"); + } + catch(const std::invalid_argument& env) + { + std::cerr << "/etc/localtime invalid, resorting to GMT."; + TZ_Ptr zone(new PTZ("UTC0")); + zone_vector.push_back(std::make_pair(max_year, zone)); + } } } }