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