Add support for the zic-compiled OS-supplied time zone DB:

*  Avoids the need to download the IANA database.

*  Heavily based on contributions by Aaron Bishop.

*  Turn on with -DUSE_OS_TZDB, off by default.

*  Not supported on Windows.

*  Disables HAS_REMOTE_API.

*  get_tzdb().version only supported on Apple.  This string has
   the value "unknown" elsewhere.

*  Leap second support is missing on Apple, and may not be on your
   platform either (please report).  Leap second support is enabled,
   disabled with -DMISSING_LEAP_SECONDS.

   Without leap second support, utc_time, tai_time, and gps_time (and
   those clocks) are not available.

*  On Apple, time zone transitions are only supported in the range:

   1901-12-13 20:45:52 to 2038-01-19 03:14:07

*  On Linux, time zone transitions are only as far in the future as
   the OS-provided transitions go.  There is no support for POSIX-
   style transitions.
This commit is contained in:
Howard Hinnant
2017-06-04 14:58:57 -04:00
parent 5132385454
commit a610f087c1
4 changed files with 954 additions and 203 deletions

View File

@@ -89,12 +89,18 @@ tzmain()
using namespace std::chrono;
auto& db = get_tzdb();
std::vector<std::string> names;
#if USE_OS_TZDB
names.reserve(db.zones.size());
for (auto& zone : db.zones)
names.push_back(zone.name());
#else // !USE_OS_TZDB
names.reserve(db.zones.size() + db.links.size());
for (auto& zone : db.zones)
names.push_back(zone.name());
for (auto& link : db.links)
names.push_back(link.name());
std::sort(names.begin(), names.end());
#endif // !USE_OS_TZDB
std::cout << db.version << "\n\n";
for (auto const& name : names)
{