<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4022: Ambiguity in the formatting of negative years with format specifier %C</title>
<meta property="og:title" content="Issue 4022: Ambiguity in the formatting of negative years with format specifier %C">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4022.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<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>
<h3 id="4022"><a href="lwg-active.html#4022">4022</a>. Ambiguity in the formatting of negative years with format specifier <code>%C</code></h3>
<p><b>Section:</b> 30.12 <a href="https://wg21.link/time.format">[time.format]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2023-12-08 <b>Last modified:</b> 2023-12-09</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#time.format">active issues</a> in [time.format].</p>
<p><b>View all other</b> <a href="lwg-index.html#time.format">issues</a> in [time.format].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Table 101, [tab:time.format.spec] reads:
</p>
<table border="1">
<caption>Table 101 &mdash; Meaning of conversion specifiers  [tab:time.format.spec]</caption>
<tr style="text-align:center">
<th>Specifier</th>
<th>Replacement</th>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
<tr>
<td><code>%C</code></td>
<td>The year divided by <code>100</code> using floored division. If the result is a single decimal digit, it<br/>
is prefixed with <code>0</code>. The modified command <code>%EC</code> produces the locale's alternative<br/>
representation of the century.</td>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
</table>

<p>
When the year is in range <code>[-99, -10]</code>, it is unclear whether the result (in range <code>[-9, -1]</code>) 
is considered as a single decimal digit, and there is implementation divergence 
(<a href="https://github.com/llvm/llvm-project/issues/74727">llvm/llvm-project#74727</a>).
<p/>
<b>Daniel:</b>
<p/>
This issue is somewhat related to LWG <a href="lwg-active.html#3831" title="Two-digit formatting of negative year is ambiguous (Status: New)">3831</a><sup><a href="https://cplusplus.github.io/LWG/issue3831" title="Latest snapshot">(i)</a></sup>.
</p>


<p id="res-4022"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4964" title=" Working Draft, Programming Languages — C++">N4964</a>.
</p>

<blockquote class="note">
<p>
[<i>Drafting Note:</i> Two mutually exclusive options are prepared, depicted below by <b>Option A</b> and 
<b>Option B</b>, respectively.] 
</p>
</blockquote>

<p>
<b>Option A:</b>
</p>

<ol>

<li><p>Modify 30.12 <a href="https://wg21.link/time.format">[time.format]</a>, Table 101 [tab:time.format.spec], as indicated:</p>

<blockquote>
<table border="1">
<caption>Table 101 &mdash; Meaning of conversion specifiers  [tab:time.format.spec]</caption>
<tr style="text-align:center">
<th>Specifier</th>
<th>Replacement</th>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
<tr>
<td><code>%C</code></td>
<td>The year divided by <code>100</code> using floored division. If the result is <del>a single decimal digit</del><ins>in range <code>[0, 9]</code></ins>, it<br/>
is prefixed with <code>0</code>. The modified command <code>%EC</code> produces the locale's alternative<br/>
representation of the century.</td>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
</table>
</blockquote>
</li>
</ol>

<p>
<b>Option B:</b>
</p>

<ol>

<li><p>Modify 30.12 <a href="https://wg21.link/time.format">[time.format]</a>, Table 101 [tab:time.format.spec], as indicated:</p>

<blockquote>
<table border="1">
<caption>Table 101 &mdash; Meaning of conversion specifiers  [tab:time.format.spec]</caption>
<tr style="text-align:center">
<th>Specifier</th>
<th>Replacement</th>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
<tr>
<td><code>%C</code></td>
<td>The year divided by <code>100</code> using floored division. If the result is <del>a single decimal digit</del><ins>in range <code>[-9, 9]</code></ins>, it<br/>
is prefixed with <code>0</code>. The modified command <code>%EC</code> produces the locale's alternative<br/>
representation of the century.</td>
</tr>
<tr>
<td colspan="2" align="center">
<code>[&hellip;]</code>
</td>
</tr>
</table>
</blockquote>
</li>
</ol>





</body>
</html>
