For USE_OS_TZDB, look for version number in the files

version and +VERSION
This commit is contained in:
Howard Hinnant 2020-09-11 16:00:18 -04:00
parent ba99134b8a
commit 0b72599bd4

View File

@ -2631,7 +2631,6 @@ operator<<(std::ostream& os, const leap_second& x)
#if USE_OS_TZDB #if USE_OS_TZDB
# ifdef __APPLE__
static static
std::string std::string
get_version() get_version()
@ -2640,12 +2639,20 @@ get_version()
auto path = get_tz_dir() + string("/+VERSION"); auto path = get_tz_dir() + string("/+VERSION");
ifstream in{path}; ifstream in{path};
string version; string version;
if (in)
{
in >> version; in >> version;
if (in.fail()) return version;
throw std::runtime_error("Unable to get Timezone database version from " + path); }
in.clear();
in.open(get_tz_dir() + std::string(1, folder_delimiter) + "version");
if (in)
{
in >> version;
return version;
}
return version; return version;
} }
# endif
static static
std::vector<leap_second> std::vector<leap_second>
@ -2781,9 +2788,7 @@ init_tzdb()
db->zones.shrink_to_fit(); db->zones.shrink_to_fit();
std::sort(db->zones.begin(), db->zones.end()); std::sort(db->zones.begin(), db->zones.end());
db->leap_seconds = find_read_and_leap_seconds(); db->leap_seconds = find_read_and_leap_seconds();
# ifdef __APPLE__
db->version = get_version(); db->version = get_version();
# endif
return db; return db;
} }