|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4285" status="New"> |
| 5 | +<title>`time_get::do_get_date` is problematic even after LWG 461</title> |
| 6 | +<section> |
| 7 | +<sref ref="[locale.time.get.members]"/> |
| 8 | +</section> |
| 9 | +<submitter>S. B. Tam</submitter> |
| 10 | +<date>27 Jun 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +Background: <a href="https://github.com/cplusplus/draft/pull/8009">https://github.com/cplusplus/draft/pull/8009</a> |
| 16 | +<p/> |
| 17 | +LWG <iref ref="461"/> changed `time_get::do_get_date` to parse a set of fixed formats. For example, if |
| 18 | +`time_get::date_order()` is `no_order` or `mdy`, the format parsed by `do_get_date` is `%m/%d/%y`. |
| 19 | +<p/> |
| 20 | +This has several problems: |
| 21 | +</p> |
| 22 | +<ol> |
| 23 | +<li><p>When the resolution of LWG <iref ref="461"/> was applied to the draft standard, the slashes were lost. |
| 24 | +This could mislead people into implementing `do_get_date` using the incorrect formats. Fortunately, none |
| 25 | +of the standard library implementations are affected by this mistake.</p></li> |
| 26 | +<li><p>Only 2-digit years are accepted due to the use of `%y`. This could lead to incorrect parse if |
| 27 | +`strftime` uses `%Y` for the locale's date format.</p></li> |
| 28 | +<li><p>`date_order()` might need additional locale facets to find out the date order, but it doesn't have an |
| 29 | +<tt>ios_base&</tt> argument from which to get the locale.</p></li> |
| 30 | +<li><p>Many locales do not use any of the specified formats. For example, `de_DE` uses `%d.%m.%Y`, `zh_CN` |
| 31 | +uses `%Y?%m?%d?`. Although <sref ref="[locale.time.get.virtuals]"/>/5 gives an implementation the latitude |
| 32 | +to accept additional formats, ambiguity could arise if the locale's format disagrees with `date_order()`.</p></li> |
| 33 | +</ol> |
| 34 | +<p> |
| 35 | +On POSIX systems, it is possible to query the locale's date format using `nl_langinfo(D_FMT)`. |
| 36 | +Maybe an implementation should be allowed to use that format <b>instead</b> of the one indicated by `date_order()`. |
| 37 | +</p> |
| 38 | +</discussion> |
| 39 | + |
| 40 | +<resolution> |
| 41 | +</resolution> |
| 42 | + |
| 43 | +</issue> |
0 commit comments