<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3091: subsecond-precision time_of_day and durations that seconds cannot convert to</title>
<meta property="og:title" content="Issue 3091: subsecond-precision time_of_day and durations that seconds cannot convert to">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3091.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#Resolved">Resolved</a> status.</em></p>
<h3 id="3091"><a href="lwg-defects.html#3091">3091</a>. subsecond-precision <code>time_of_day</code> and durations that <code>seconds</code> cannot convert to</h3>
<p><b>Section:</b> 30.9 <a href="https://wg21.link/time.hms">[time.hms]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Richard Smith <b>Opened:</b> 2018-03-24 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
What should happen here:
</p>
<blockquote>
<pre>
const int bpm = 100;
using beats = duration&lt;int, ratio&lt;60, 100&gt;&gt;;
auto v = time_of_day&lt;beats&gt;(beats{2}).subseconds();
</pre>
</blockquote>
<p>
? 2 beats at 100bpm is <code>1.2</code> seconds. The <code>time_of_day</code> constructor specification says:
</p>
<blockquote><p>
<code>seconds()</code> returns the integral number of seconds <code>since_midnight</code> is after <code>(00:00:00 + hours() + minutes())</code>.
<code>subseconds()</code> returns the integral number of fractional precision seconds <code>since_midnight</code> is after
<code>(00:00:00 + hours() + minutes() + seconds())</code>.
</p></blockquote>
<p>
But that's impossible. If <code>seconds()</code> returns 1, we need to return a <code>subseconds()</code> value representing <code>0.2s</code>
of type <code>precision</code>, but type <code>precision</code> can only represent multiples of <code>0.6s</code>.
<p/>
Should this <code>time_of_day</code> specialization only be available for the case where <code>seconds</code> is convertible to
<code>precision</code>? Or should the <code>precision</code> type used by this specialization be
<code>common_type_t&lt;seconds, duration&lt;Rep, Period&gt;&gt;</code> rather than merely <code>duration&lt;Rep, Period&gt;</code>?
<p/>
Either way I think we need a wording update to specify one of those two behaviors.
</p>

<p><i>[2018-04-09 Priority set to 2 after discussion on the reflector.]</i></p>



<p><i>[2019 Cologne Wednesday night]</i></p>

<p>Status to Resolved (group voted on NAD, but Marshall changed it to Resolved)</p>
<p>Resolved by the adoption of P1466 in Cologne.</p>
<p><code>hh_mm_ss</code> is now specified such that subseconds must be a
non-positive power of 10 (e.g. 1/10s, 1/100s, milliseconds, etc.).   In
this example 60/100 simplifies to 3/5, which can be exactly represented
with 1 fractional decimal digit.  So in this example <code>subseconds()</code> has
the value of <code>2ds</code> (2 deciseconds).</p>


<p id="res-3091"><b>Proposed resolution:</b></p>





</body>
</html>
