[llvm-branch-commits] [libcxx] [libc++][chrono] Loads leap-seconds.list in tzdb. (PR #82113)

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 27 09:48:01 PST 2024


================
@@ -612,6 +643,16 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {
   std::ranges::sort(__tzdb.zones);
   std::ranges::sort(__tzdb.links);
   std::ranges::sort(__rules, {}, [](const auto& p) { return p.first; });
+
+  // There are two files with the leap second information
+  // - leapseconds as specified by zic
+  // - leap-seconds.list the source data
+  // The latter is much easier to parse, it seems Howard shares that
+  // opinion.
+  chrono::__parse_leap_seconds(__tzdb.leap_seconds, ifstream{__root / "leap-seconds.list"});
+  // Note the input is sorted, but that does not seem to be are
+  // requirement, it is a requirement in the Standard.
+  std::ranges::sort(__tzdb.leap_seconds);
----------------
ldionne wrote:

```suggestion
  // The Standard requires the leap seconds to be sorted.
  // leap-seconds.list usually provides them in sorted order, but that is not
  // guaranteed so we ensure it here.
  std::ranges::sort(__tzdb.leap_seconds);
```

https://github.com/llvm/llvm-project/pull/82113


More information about the llvm-branch-commits mailing list