Skip to content

Commit 14d244f

Browse files
committed
New issue from Jonathan: IANA time zone database allows links to refer to links
1 parent ef28b6b commit 14d244f

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed

xml/issue4211.xml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4211" status="New">
5+
<title>IANA time zone database allows links to refer to links</title>
6+
<section>
7+
<sref ref="[time.zone.db.tzdb]"/>
8+
</section>
9+
<submitter>Jonathan Wakely</submitter>
10+
<date>22 Feb 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
Since
16+
<a href="https://github.com/eggert/tz/commit/4878b644b25020568d4dda346c5cea91826c0c7c">October 2022</a>
17+
the IANA Time Zone Database's `tzfile` data format allows a Link to refer
18+
to another Link, instead of referring directly to a Zone.
19+
The <a href="https://man7.org/linux/man-pages/man8/zic.8.html#FILES">zic(8)</a>
20+
man page says:
21+
<blockquote>
22+
The TARGET field should appear as the NAME field in some zone line
23+
or as the LINK-NAME field in some link line.
24+
The LINK-NAME field is used as an alternative name for that zone;
25+
it has the same syntax as a zone line's NAME field.
26+
Links can chain together, although the behavior is unspecified if
27+
a chain of one or more links does not terminate in a Zone name.
28+
</blockquote>
29+
Because chains of links were introduced to `tzfile` after `chrono::tzdb`
30+
was standardized, C++ does not properly support chains of links.
31+
</p>
32+
<p>
33+
The `time_zone_link::target()` member function is required to return
34+
"The name of the `time_zone` for which this `time_zone_link` provides
35+
an alternative name."
36+
This doesn't allow returning the name of another `time_zone_link`,
37+
which implies that the implementation should flatten a series of links so
38+
that the target is a `time_zone`. However, this discards information which
39+
is present in the `tzdb`, so that the information exposed to a C++ program
40+
does not preserve the original structure of a chain of links.
41+
</p>
42+
<p>
43+
The standard could be adjusted to support chains of links by allowing
44+
`time_zone_link::target()` to refer to another link, and then altering the
45+
algorithm used by `tzdb::locate_zone(string_view)` to find a `time_zone` from
46+
a name that might be a zone or a link.
47+
</p>
48+
</discussion>
49+
50+
<resolution>
51+
<p>
52+
This wording is relative to <paper num="N5001"/>.
53+
</p>
54+
55+
<ol>
56+
<li>
57+
Modify <sref ref="[time.zone.db.tzdb]"/> as indicated:
58+
<blockquote>
59+
<pre><code>
60+
const time_zone* locate_zone(string_view tz_name) const;
61+
</code></pre>
62+
<p>
63+
-2- <i>Returns</i>:
64+
<ol style="list-style-type:none">
65+
<li>
66+
(2.1) &mdash;
67+
If `zones` contains an element `tz` for which `tz.name() == tz_name`,
68+
a pointer to `tz`;
69+
</li>
70+
<li>
71+
(2.2) &mdash;
72+
otherwise, if `links` contains an element `tz_l` for which
73+
`tz_l.name() == tz_name`, then
74+
<del>a pointer to the element `tz` of zones for which
75+
`tz.name() == tz_l.target()`</del>
76+
<ins>
77+
the result of `locate_zone(tz_l.target())`.
78+
</ins>.
79+
</li>
80+
</ol>
81+
</p>
82+
<p>
83+
[<i>Note 1</i>: A `time_zone_link` specifies an alternative name for a
84+
`time_zone`. &mdash; <i>end note</i>]
85+
</p>
86+
<p>
87+
-3- <i>Throws</i>:
88+
If a `const time_zone*` cannot be found as described in the <i>Returns</i>:
89+
element, throws a `runtime_error`.
90+
</p>
91+
<p>
92+
[<i>Note 2</i>: On non-exceptional return, the return value is always a
93+
pointer to a valid `time_zone`. &mdash; <i>end note</i>]
94+
</p>
95+
<p>
96+
<ins>
97+
-?- <i>Remarks</i>:
98+
If both `zones` and `links` contain elements that match `tz_name` then
99+
it is unspecified whether <code>&amp;tz</code>
100+
or <code>locate_zone(tz_l.target())</code> is returned.
101+
</ins>
102+
</p>
103+
<note>Drafting note:
104+
This gives flexibility how to implement the lookup in `locate_zone`.
105+
</note>
106+
</blockquote>
107+
</li>
108+
<li>
109+
Modify <sref ref="[time.zone.link.overview]"/> as indicated:
110+
<blockquote>
111+
<p>
112+
-1-
113+
A `time_zone_link` specifies an alternative name for a `time_zone`.
114+
`time_zone_links` are constructed when the time zone database is initialized.
115+
<ins>
116+
The name of a `time_zone_link` can be used as an argument to
117+
`tzdb::locate_zone` (<sref ref="[time.zone.db.tzdb]"/>).
118+
A `time_zone_link` can refer directly to a `time_zone`,
119+
or to another `time_zone_link`, forming a chain of links.
120+
</ins>
121+
</p>
122+
</blockquote>
123+
</li>
124+
<li>
125+
Modify <sref ref="[time.zone.link.members]"/> as indicated:
126+
<blockquote>
127+
<pre><code>
128+
string_view name() const noexcept;
129+
</code></pre>
130+
-1- <i>Returns</i>:
131+
The alternative name for the time zone.
132+
<pre><code>
133+
string_view target() const noexcept;
134+
</code></pre>
135+
<p>
136+
-2- <i>Returns</i>:
137+
The name of the `time_zone`
138+
for which this `time_zone_link` provides an alternative name
139+
<ins>or the name of another `time_zone_link`</ins>.
140+
</p>
141+
<p>
142+
<ins>
143+
[<i>Note 1</i>:
144+
`tzdb::locate_zone` follows a chain of links formed when
145+
a link's target is the name of a `time_zone_link`,
146+
throwing an exception if the
147+
chain of links does not terminate in a `time_zone`.
148+
&mdash; <i>end note</i>]
149+
</ins>
150+
</p>
151+
</blockquote>
152+
</li>
153+
154+
</ol>
155+
</resolution>
156+
157+
</issue>

0 commit comments

Comments
 (0)