Fix local timezone-dependent test.

This commit is contained in:
John Ralls 2017-01-13 14:54:12 -08:00
parent 09cbb9c12e
commit 67a0e46f18
2 changed files with 14 additions and 7 deletions

View File

@ -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"

View File

@ -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));
}
}
}
}