mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 00:14:07 +08:00
For USE_OS_TZDB, look for version number in the files
version and +VERSION
This commit is contained in:
parent
ba99134b8a
commit
0b72599bd4
17
src/tz.cpp
17
src/tz.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user