|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4211: IANA time zone database allows links to refer to links</title> |
| 6 | +<meta property="og:title" content="Issue 4211: IANA time zone database allows links to refer to links"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4211.html"> |
| 9 | +<meta property="og:type" content="website"> |
| 10 | +<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png"> |
| 11 | +<meta property="og:image:alt" content="C++ logo"> |
| 12 | +<style> |
| 13 | + p {text-align:justify} |
| 14 | + li {text-align:justify} |
| 15 | + pre code.backtick::before { content: "`" } |
| 16 | + pre code.backtick::after { content: "`" } |
| 17 | + blockquote.note |
| 18 | + { |
| 19 | + background-color:#E0E0E0; |
| 20 | + padding-left: 15px; |
| 21 | + padding-right: 15px; |
| 22 | + padding-top: 1px; |
| 23 | + padding-bottom: 1px; |
| 24 | + } |
| 25 | + ins {background-color:#A0FFA0} |
| 26 | + del {background-color:#FFA0A0} |
| 27 | + table.issues-index { border: 1px solid; border-collapse: collapse; } |
| 28 | + table.issues-index th { text-align: center; padding: 4px; border: 1px solid; } |
| 29 | + table.issues-index td { padding: 4px; border: 1px solid; } |
| 30 | + table.issues-index td:nth-child(1) { text-align: right; } |
| 31 | + table.issues-index td:nth-child(2) { text-align: left; } |
| 32 | + table.issues-index td:nth-child(3) { text-align: left; } |
| 33 | + table.issues-index td:nth-child(4) { text-align: left; } |
| 34 | + table.issues-index td:nth-child(5) { text-align: center; } |
| 35 | + table.issues-index td:nth-child(6) { text-align: center; } |
| 36 | + table.issues-index td:nth-child(7) { text-align: left; } |
| 37 | + table.issues-index td:nth-child(5) span.no-pr { color: red; } |
| 38 | + @media (prefers-color-scheme: dark) { |
| 39 | + html { |
| 40 | + color: #ddd; |
| 41 | + background-color: black; |
| 42 | + } |
| 43 | + ins { |
| 44 | + background-color: #225522 |
| 45 | + } |
| 46 | + del { |
| 47 | + background-color: #662222 |
| 48 | + } |
| 49 | + a { |
| 50 | + color: #6af |
| 51 | + } |
| 52 | + a:visited { |
| 53 | + color: #6af |
| 54 | + } |
| 55 | + blockquote.note |
| 56 | + { |
| 57 | + background-color: rgba(255, 255, 255, .10) |
| 58 | + } |
| 59 | + } |
| 60 | +</style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<hr> |
| 64 | +<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p> |
| 65 | +<h3 id="4211"><a href="lwg-active.html#4211">4211</a>. IANA time zone database allows links to refer to links</h3> |
| 66 | +<p><b>Section:</b> 30.11.2.1 <a href="https://wg21.link/time.zone.db.tzdb">[time.zone.db.tzdb]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2025-02-22 <b>Last modified:</b> 2025-02-22</p> |
| 68 | +<p><b>Priority: </b>Not Prioritized |
| 69 | +</p> |
| 70 | +<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
| 71 | +<p><b>Discussion:</b></p> |
| 72 | +<p> |
| 73 | +Since |
| 74 | +<a href="https://github.com/eggert/tz/commit/4878b644b25020568d4dda346c5cea91826c0c7c">October 2022</a> |
| 75 | +the IANA Time Zone Database's <code class='backtick'>tzfile</code> data format allows a Link to refer |
| 76 | +to another Link, instead of referring directly to a Zone. |
| 77 | +The <a href="https://man7.org/linux/man-pages/man8/zic.8.html#FILES">zic(8)</a> |
| 78 | +man page says: |
| 79 | +<blockquote> |
| 80 | +The TARGET field should appear as the NAME field in some zone line |
| 81 | +or as the LINK-NAME field in some link line. |
| 82 | +The LINK-NAME field is used as an alternative name for that zone; |
| 83 | +it has the same syntax as a zone line's NAME field. |
| 84 | +Links can chain together, although the behavior is unspecified if |
| 85 | +a chain of one or more links does not terminate in a Zone name. |
| 86 | +</blockquote> |
| 87 | +Because chains of links were introduced to <code class='backtick'>tzfile</code> after <code class='backtick'>chrono::tzdb</code> |
| 88 | +was standardized, C++ does not properly support chains of links. |
| 89 | +</p> |
| 90 | +<p> |
| 91 | +The <code class='backtick'>time_zone_link::target()</code> member function is required to return |
| 92 | +"The name of the <code class='backtick'>time_zone</code> for which this <code class='backtick'>time_zone_link</code> provides |
| 93 | +an alternative name." |
| 94 | +This doesn't allow returning the name of another <code class='backtick'>time_zone_link</code>, |
| 95 | +which implies that the implementation should flatten a series of links so |
| 96 | +that the target is a <code class='backtick'>time_zone</code>. However, this discards information which |
| 97 | +is present in the <code class='backtick'>tzdb</code>, so that the information exposed to a C++ program |
| 98 | +does not preserve the original structure of a chain of links. |
| 99 | +</p> |
| 100 | +<p> |
| 101 | +The standard could be adjusted to support chains of links by allowing |
| 102 | +<code class='backtick'>time_zone_link::target()</code> to refer to another link, and then altering the |
| 103 | +algorithm used by <code class='backtick'>tzdb::locate_zone(string_view)</code> to find a <code class='backtick'>time_zone</code> from |
| 104 | +a name that might be a zone or a link. |
| 105 | +</p> |
| 106 | + |
| 107 | + |
| 108 | +<p id="res-4211"><b>Proposed resolution:</b></p> |
| 109 | +<p> |
| 110 | +This wording is relative to <a href="https://wg21.link/N5001">N5001</a>. |
| 111 | +</p> |
| 112 | + |
| 113 | +<ol> |
| 114 | +<li> |
| 115 | +Modify 30.11.2.1 <a href="https://wg21.link/time.zone.db.tzdb">[time.zone.db.tzdb]</a> as indicated: |
| 116 | +<blockquote> |
| 117 | +<pre><code> |
| 118 | +const time_zone* locate_zone(string_view tz_name) const; |
| 119 | +</code></pre> |
| 120 | +<p> |
| 121 | +-2- <i>Returns</i>: |
| 122 | +<ol style="list-style-type:none"> |
| 123 | +<li> |
| 124 | +(2.1) — |
| 125 | +If <code class='backtick'>zones</code> contains an element <code class='backtick'>tz</code> for which <code class='backtick'>tz.name() == tz_name</code>, |
| 126 | +a pointer to <code class='backtick'>tz</code>; |
| 127 | +</li> |
| 128 | +<li> |
| 129 | +(2.2) — |
| 130 | +otherwise, if <code class='backtick'>links</code> contains an element <code class='backtick'>tz_l</code> for which |
| 131 | +<code class='backtick'>tz_l.name() == tz_name</code>, then |
| 132 | +<del>a pointer to the element <code class='backtick'>tz</code> of zones for which |
| 133 | +<code class='backtick'>tz.name() == tz_l.target()</code></del> |
| 134 | +<ins> |
| 135 | +the result of <code class='backtick'>locate_zone(tz_l.target())</code>. |
| 136 | +</ins>. |
| 137 | +</li> |
| 138 | +</ol> |
| 139 | +</p> |
| 140 | +<p> |
| 141 | +[<i>Note 1</i>: A <code class='backtick'>time_zone_link</code> specifies an alternative name for a |
| 142 | +<code class='backtick'>time_zone</code>. — <i>end note</i>] |
| 143 | +</p> |
| 144 | +<p> |
| 145 | +-3- <i>Throws</i>: |
| 146 | +If a <code class='backtick'>const time_zone*</code> cannot be found as described in the <i>Returns</i>: |
| 147 | +element, throws a <code class='backtick'>runtime_error</code>. |
| 148 | +</p> |
| 149 | +<p> |
| 150 | +[<i>Note 2</i>: On non-exceptional return, the return value is always a |
| 151 | +pointer to a valid <code class='backtick'>time_zone</code>. — <i>end note</i>] |
| 152 | +</p> |
| 153 | +<p> |
| 154 | +<ins> |
| 155 | +-?- <i>Remarks</i>: |
| 156 | +If both <code class='backtick'>zones</code> and <code class='backtick'>links</code> contain elements that match <code class='backtick'>tz_name</code> then |
| 157 | +it is unspecified whether <code>&tz</code> |
| 158 | +or <code>locate_zone(tz_l.target())</code> is returned. |
| 159 | +</ins> |
| 160 | +</p> |
| 161 | +<p><i>[Drafting note: |
| 162 | +This gives flexibility how to implement the lookup in <code class='backtick'>locate_zone</code>. |
| 163 | +]</i></p> |
| 164 | + |
| 165 | +</blockquote> |
| 166 | +</li> |
| 167 | +<li> |
| 168 | +Modify 30.11.9.1 <a href="https://wg21.link/time.zone.link.overview">[time.zone.link.overview]</a> as indicated: |
| 169 | +<blockquote> |
| 170 | +<p> |
| 171 | +-1- |
| 172 | +A <code class='backtick'>time_zone_link</code> specifies an alternative name for a <code class='backtick'>time_zone</code>. |
| 173 | +<code class='backtick'>time_zone_links</code> are constructed when the time zone database is initialized. |
| 174 | +<ins> |
| 175 | +The name of a <code class='backtick'>time_zone_link</code> can be used as an argument to |
| 176 | +<code class='backtick'>tzdb::locate_zone</code> (30.11.2.1 <a href="https://wg21.link/time.zone.db.tzdb">[time.zone.db.tzdb]</a>). |
| 177 | +A <code class='backtick'>time_zone_link</code> can refer directly to a <code class='backtick'>time_zone</code>, |
| 178 | +or to another <code class='backtick'>time_zone_link</code>, forming a chain of links. |
| 179 | +</ins> |
| 180 | +</p> |
| 181 | +</blockquote> |
| 182 | +</li> |
| 183 | +<li> |
| 184 | +Modify 30.11.9.2 <a href="https://wg21.link/time.zone.link.members">[time.zone.link.members]</a> as indicated: |
| 185 | +<blockquote> |
| 186 | +<pre><code> |
| 187 | +string_view name() const noexcept; |
| 188 | +</code></pre> |
| 189 | +-1- <i>Returns</i>: |
| 190 | +The alternative name for the time zone. |
| 191 | +<pre><code> |
| 192 | +string_view target() const noexcept; |
| 193 | +</code></pre> |
| 194 | +<p> |
| 195 | +-2- <i>Returns</i>: |
| 196 | +The name of the <code class='backtick'>time_zone</code> |
| 197 | +for which this <code class='backtick'>time_zone_link</code> provides an alternative name |
| 198 | +<ins>or the name of another <code class='backtick'>time_zone_link</code></ins>. |
| 199 | +</p> |
| 200 | +<p> |
| 201 | +<ins> |
| 202 | +[<i>Note 1</i>: |
| 203 | +<code class='backtick'>tzdb::locate_zone</code> follows a chain of links formed when |
| 204 | +a link's target is the name of a <code class='backtick'>time_zone_link</code>, |
| 205 | +throwing an exception if the |
| 206 | +chain of links does not terminate in a <code class='backtick'>time_zone</code>. |
| 207 | +— <i>end note</i>] |
| 208 | +</ins> |
| 209 | +</p> |
| 210 | +</blockquote> |
| 211 | +</li> |
| 212 | + |
| 213 | +</ol> |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | +</body> |
| 220 | +</html> |
0 commit comments