[libcxx-commits] [libcxx] [libc++] Enable experimental tzdb on Apple platforms (PR #122010)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 8 07:01:35 PST 2025
================
@@ -664,11 +764,21 @@ static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, istream&&
// The database should contain the number of seconds inserted by a leap
// second (1 or -1). So the difference between the two elements is stored.
// std::ranges::views::adjacent has not been implemented yet.
+ vector<leap_second> __result;
(void)ranges::adjacent_find(__entries, [&](const __entry& __first, const __entry& __second) {
- __leap_seconds.emplace_back(
- std::__private_constructor_tag{}, __second.__timestamp, __second.__value - __first.__value);
+ __result.emplace_back(std::__private_constructor_tag{}, __second.__timestamp, __second.__value - __first.__value);
return false;
});
+ return __result;
+}
+
+// Parse leap seconds from the appropriate location based on the platform.
+static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, filesystem::path const& __tzdb_directory) {
+#if defined(__APPLE__)
+ __leap_seconds.append_range(chrono::__parse_leap_seconds_binary(ifstream{__tzdb_directory / "leapseconds"}));
+#else
+ __leap_seconds.append_range(chrono::__parse_leap_seconds_list(ifstream{__tzdb_directory / "leap-seconds.list"}));
+#endif
}
----------------
h-vetinari wrote:
> Could we unconditionally parse `leapseconds` instead?
My impression is yes. For example the installation of `tzdata` (if one does it by hand) needs to explicitly opt-in to installing `leap-seconds.list`, whereas `leapseconds` is there [by default](https://github.com/eggert/tz/blob/edbabecc14655636fd12126af7554f2a0ce311d9/Makefile#L174).
https://github.com/llvm/llvm-project/pull/122010
More information about the libcxx-commits
mailing list