<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3318: Clarify whether clocks can represent time before their epoch</title>
<meta property="og:title" content="Issue 3318: Clarify whether clocks can represent time before their epoch">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3318.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#C++20">C++20</a> status.</em></p>
<h3 id="3318"><a href="lwg-defects.html#3318">3318</a>. Clarify whether clocks can represent time before their epoch</h3>
<p><b>Section:</b> 30.7.2.1 <a href="https://wg21.link/time.clock.system.overview">[time.clock.system.overview]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Great Britain <b>Opened:</b> 2019-11-05 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses <a href="https://github.com/cplusplus/nbballot/issues/331">GB 335</a></b></p>

<p>
Wording for clocks should be unified unless they are intended to behave differently
In 27.7.1.1 note 1 for <code>system_clock</code> it is stated: 
</p>
<blockquote><p>
"Objects of type <code>system_clock</code> represent wall clock time from the system-wide realtime
clock. Objects of type <code>sys_time&lt;Duration&gt;</code> measure time since (and before) 
1970-01-01 00:00:00 UTC" 
</p></blockquote>
<p>
The express statement of "since (and before)" is important given the time epoch of these clocks. 
If all the clocks support time prior to their zero-time then this should be stated explicitly. 
If not then likewise that should be noted. No change is proposed yet, clarification
required over the intended behaviour when using values prior to a given clock's epoch is
needed before the appropriate change can be suggested.
<p/>
Proposed change:
<p/>
Unify the wording.
</p>
<p>
<b>Howard Hinnant:</b>
<p/>
The clocks that are specified to have a signed <code>rep</code> imply that they will support 
negative time points, but not <i>how</i> negative. For example if <code>system_clock::duration</code> 
is <code>nanoseconds</code> represented with 64 bits, then <code>system_clock::time_point</code> 
can't possibly represent dates prior to 1677-09-21 00:12:43.145224192. This is a negative 
<code>time_point</code> since it is prior to 1970-01-01 00:00:00. But it is not very negative 
compared to (for example) <code>sys_time&lt;microseconds&gt;::min()</code>.
<p/>
Those clocks with a signed <code>rep</code> are:
</p>
<ul>
<li><p><code>system_clock</code></p></li>
<li><p><code>utc_clock</code></p></li>
<li><p><code>tai_clock</code></p></li>
<li><p><code>gps_clock</code></p></li>
<li><p><code>file_clock</code></p></li>
</ul>
<p>
Those clocks where the signed-ness of <code>rep</code> is unspecified are:
</p>
<ul>
<li><p><code>steady_clock</code></p></li>
<li><p><code>high_resolution_clock</code></p></li>
</ul>
<p>
Therefore this response emphasizes the "Unify the wording" part of this NB comment.
</p>

<p><i>[2019-11 Status to Ready during Wednesday morning issue processing in Belfast.]</i></p>



<p id="res-3318"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4835">N4835</a>.</p>

<ol>
<li><p>Modify 30.7.2.1 <a href="https://wg21.link/time.clock.system.overview">[time.clock.system.overview]</a> as indicated:</p>

<blockquote>
<p>
-1- Objects of type <code>system_clock</code> represent wall clock time from the system-wide 
realtime clock. Objects of type <code>sys_time&lt;Duration&gt;</code> measure time since 
<del>(and before)</del> 1970-01-01 00:00:00 UTC excluding leap seconds. This measure is commonly 
referred to as Unix time. This measure facilitates an efficient mapping between
<code>sys_time</code> and calendar types (30.8 <a href="https://wg21.link/time.cal">[time.cal]</a>). [<i>Example:</i>
<code>sys_seconds{sys_days{1970y/January/1}}.time_since_epoch()</code> is <code>0s</code>.
<code>sys_seconds{sys_days{2000y/January/1}}.time_since_epoch()</code> is <code>946'684'800s</code>, 
which is <code>10'957 * 86'400s</code>. &mdash; <i>end example</i>]
</p>
</blockquote>
</li>
</ol>





</body>
</html>
