[libcxx-commits] [libcxx] [libc++] Enable experimental tzdb on Apple platforms (PR #122010)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 8 00:56:13 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:
It would be good if also linux would fall back to `leapseconds` if `leap-seconds.list` is not available (which is still the case in various distros). The files should be equivalent, so an argument could even be made to switch all platforms over to `leapseconds` - it's certainly the more common variant.
https://github.com/llvm/llvm-project/pull/122010
More information about the libcxx-commits
mailing list