Skip to content

Commit

Permalink
Editorial: Dedicate a subsection to time value range and define TimeC…
Browse files Browse the repository at this point in the history
…lip immediately after it
  • Loading branch information
gibson042 committed Sep 4, 2019
1 parent 96d51c8 commit d6b339c
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -26901,16 +26901,35 @@ <h1>Overview of Date Objects and Definitions of Abstract Operations</h1>
<p>The following functions are abstract operations that operate on time values (defined in <emu-xref href="#sec-time-values-and-time-range"></emu-xref>). Note that, in every case, if any argument to one of these functions is *NaN*, the result will be *NaN*.</p>

<emu-clause id="sec-time-values-and-time-range">
<h1>Time Values and Time Range</h1>
<h1>Time Values</h1>
<p>An ECMAScript <dfn>time value</dfn> is a Number, either a finite integer representing an instant in time to millisecond precision or *NaN* representing no specific instant.
<p>Time is measured in ECMAScript as milliseconds since midnight at the beginning of 01 January, 1970 UTC. Time in ECMAScript does not observe leap seconds; they are ignored. Time calculations assume each and every day contains exactly <emu-eqn id="eqn-msPerDay" aoid="msPerDay">msPerDay = 60 &times; 60 &times; 24 &times; 1000 = 86,400,000</emu-eqn> milliseconds, to align with the POSIX specification of each and every day containing exactly 86,400 seconds.</p>
<p>A Number can exactly represent all integers from -9,007,199,254,740,992 to 9,007,199,254,740,992 (<emu-xref href="#sec-number.min_safe_integer"></emu-xref> and <emu-xref href="#sec-number.max_safe_integer"></emu-xref>). A time value used for the [[DateValue]] internal slot of a Date instance supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds (exactly -100,000,000 days to 100,000,000 days relative to midnight at the beginning of 01 January, 1970 UTC).</p>
<p>The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the time value *+0*.</p>
<emu-note>
<p>The 400 year cycle of the Gregorian calendar contains 97 leap years. This yields an average of 365.2425 days per year, or an average of 31,556,952,000 milliseconds per year under the Gregorian calendar. ECMAScript applies a proleptic Gregorian calendar for all time computations.</p>
<p>As specified by this section, the maximum year range a Number can represent exactly with millisecond precision is approximately -285,426 to 285,426 years relative to midnight at the beginning of 01 January, 1970 UTC.</p>
<p>As specified by this section, the maximum year range a [[DateValue]] can represent is approximately -273,790 to 273,790 years relative to midnight at the beginning of 01 January, 1970 UTC.</p>
</emu-note>

<emu-clause id="sec-time-value-range">
<h1>Time Value Range</h1>
<p>Arithmetic on time values is exact within the safe integer range of -9,007,199,254,740,991 to 9,007,199,254,740,991 (<emu-xref href="#sec-number.min_safe_integer"></emu-xref> and <emu-xref href="#sec-number.max_safe_integer"></emu-xref>). To minimize the number of situations that must step outside these bounds (even when calculating leap years, daylight saving transitions, or UTC offset conversion), a time value used for the [[DateValue]] internal slot of a Date instance supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds (exactly -100,000,000 days to 100,000,000 days relative to midnight at the beginning of 01 January, 1970 UTC).</p>
<emu-note>
<p>The 400 year cycle of the Gregorian calendar contains 97 leap years. This yields an average of 365.2425 days per year, or an average of 31,556,952,000 milliseconds per year under the Gregorian calendar. ECMAScript applies a proleptic Gregorian calendar for all time computations.</p>
<p>As specified by this section, the maximum year range a Number can represent exactly with millisecond precision is approximately -285,426 to 285,426 years relative to midnight at the beginning of 01 January, 1970 UTC.</p>
<p>As specified by this section, the maximum year range a [[DateValue]] can represent is approximately -273,790 to 273,790 years relative to midnight at the beginning of 01 January, 1970 UTC.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-timeclip" aoid="TimeClip">
<h1>TimeClip ( _time_ )</h1>
<p>The abstract operation TimeClip calculates a [[DateValue]]-supported time value from its argument, which must be an ECMAScript Number value. It performs the following steps:</p>
<emu-alg>
1. If _time_ is not finite, return *NaN*.
1. If abs(_time_) &gt; 8.64 &times; 10<sup>15</sup>, return *NaN*.
1. Let _clippedTime_ be ! ToInteger(_time_).
1. If _clippedTime_ is *-0*, set _clippedTime_ to *+0*.
1. Return _clippedTime_.
</emu-alg>
<emu-note>
<p>The point of step 4 is that an implementation is permitted a choice of internal representations of time values, for example as a 64-bit signed integer or as a 64-bit floating-point value. Depending on the implementation, this internal representation may or may not distinguish *-0* and *+0*.</p>
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sec-day-number-and-time-within-day">
Expand Down Expand Up @@ -27078,21 +27097,6 @@ <h1>MakeDate ( _day_, _time_ )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-timeclip" aoid="TimeClip">
<h1>TimeClip ( _time_ )</h1>
<p>The abstract operation TimeClip calculates a number of milliseconds from its argument, which must be an ECMAScript Number value. It performs the following steps:</p>
<emu-alg>
1. If _time_ is not finite, return *NaN*.
1. If abs(_time_) &gt; 8.64 &times; 10<sup>15</sup>, return *NaN*.
1. Let _clippedTime_ be ! ToInteger(_time_).
1. If _clippedTime_ is *-0*, set _clippedTime_ to *+0*.
1. Return _clippedTime_.
</emu-alg>
<emu-note>
<p>The point of step 4 is that an implementation is permitted a choice of internal representations of time values, for example as a 64-bit signed integer or as a 64-bit floating-point value. Depending on the implementation, this internal representation may or may not distinguish *-0* and *+0*.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-date-time-string-format">
<h1>Date Time String Format</h1>
<p>ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 calendar date extended format. The format is as follows: `YYYY-MM-DDTHH:mm:ss.sssZ`</p>
Expand Down

0 comments on commit d6b339c

Please sign in to comment.