|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4285: time_get::do_get_date is problematic even after LWG 461</title> |
| 6 | +<meta property="og:title" content="Issue 4285: time_get::do_get_date is problematic even after LWG 461"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4285.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="4285"><a href="lwg-active.html#4285">4285</a>. <code class='backtick'>time_get::do_get_date</code> is problematic even after LWG 461</h3> |
| 66 | +<p><b>Section:</b> 28.3.4.6.2.2 <a href="https://wg21.link/locale.time.get.members">[locale.time.get.members]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> S. B. Tam <b>Opened:</b> 2025-06-27 <b>Last modified:</b> 2025-06-28</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 | +Background: <a href="https://github.com/cplusplus/draft/pull/8009">https://github.com/cplusplus/draft/pull/8009</a> |
| 74 | +<p/> |
| 75 | +LWG <a href="lwg-defects.html#461" title="time_get hard or impossible to implement (Status: CD1)">461</a><sup><a href="https://cplusplus.github.io/LWG/issue461" title="Latest snapshot">(i)</a></sup> changed <code class='backtick'>time_get::do_get_date</code> to parse a set of fixed formats. For example, if |
| 76 | +<code class='backtick'>time_get::date_order()</code> is <code class='backtick'>no_order</code> or <code class='backtick'>mdy</code>, the format parsed by <code class='backtick'>do_get_date</code> is <code class='backtick'>%m/%d/%y</code>. |
| 77 | +<p/> |
| 78 | +This has several problems: |
| 79 | +</p> |
| 80 | +<ol> |
| 81 | +<li><p>When the resolution of LWG <a href="lwg-defects.html#461" title="time_get hard or impossible to implement (Status: CD1)">461</a><sup><a href="https://cplusplus.github.io/LWG/issue461" title="Latest snapshot">(i)</a></sup> was applied to the draft standard, the slashes were lost. |
| 82 | +This could mislead people into implementing <code class='backtick'>do_get_date</code> using the incorrect formats. Fortunately, none |
| 83 | +of the standard library implementations are affected by this mistake.</p></li> |
| 84 | +<li><p>Only 2-digit years are accepted due to the use of <code class='backtick'>%y</code>. This could lead to incorrect parse if |
| 85 | +<code class='backtick'>strftime</code> uses <code class='backtick'>%Y</code> for the locale's date format.</p></li> |
| 86 | +<li><p><code class='backtick'>date_order()</code> might need additional locale facets to find out the date order, but it doesn't have an |
| 87 | +<code>ios_base&</code> argument from which to get the locale.</p></li> |
| 88 | +<li><p>Many locales do not use any of the specified formats. For example, <code class='backtick'>de_DE</code> uses <code class='backtick'>%d.%m.%Y</code>, <code class='backtick'>zh_CN</code> |
| 89 | +uses <code class='backtick'>%Y?%m?%d?</code>. Although 28.3.4.6.2.3 <a href="https://wg21.link/locale.time.get.virtuals">[locale.time.get.virtuals]</a>/5 gives an implementation the latitude |
| 90 | +to accept additional formats, ambiguity could arise if the locale's format disagrees with <code class='backtick'>date_order()</code>.</p></li> |
| 91 | +</ol> |
| 92 | +<p> |
| 93 | +On POSIX systems, it is possible to query the locale's date format using <code class='backtick'>nl_langinfo(D_FMT)</code>. |
| 94 | +Maybe an implementation should be allowed to use that format <b>instead</b> of the one indicated by <code class='backtick'>date_order()</code>. |
| 95 | +</p> |
| 96 | + |
| 97 | + |
| 98 | +<p id="res-4285"><b>Proposed resolution:</b></p> |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +</body> |
| 105 | +</html> |
0 commit comments