-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: Cleanup Time Values and Time Range #1144
Conversation
spec.html
Outdated
<p>The actual range of times supported by ECMAScript Date objects is slightly smaller: exactly -100,000,000 days to 100,000,000 days measured relative to midnight at the beginning of 01 January, 1970 UTC. This gives a range of 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC.</p> | ||
<p>The exact moment of midnight at the beginning of 01 January, 1970 UTC is represented by the value *+0*.</p> | ||
<p>A Date object contains a Number representing an instant in time with millisecond precision. Such a Number is called a <dfn>time value</dfn>. A time value may also be *NaN*, indicating that the Date object does not represent a specific instant in time.</p> | ||
<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 a day contains exactly <emu-eqn>60 × 60 × 24 × 1000 = 86,400,000</emu-eqn> milliseconds.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going this deep, do we want to discuss why we don't support leap seconds? I feel like that gets asked a lot, and of course it goes back to the fact that we're fundamentally using Unix time which doesn't support them here.
Small nit - I believe we should say time calculations assume a UTC day contains exactly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should say
time calculations assume a UTC day contains exactly...
(I.e., inserting "UTC".) I think we should go in the opposite direction, removing most mentions of UTC, for the very reason that ES doesn't support leap seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maggiepint I can ask around tomorrow, but there might be some reason why Unix / POSIX can't be referenced specifically in the spec (neither are currently).
@jmdyck I'd tend to agree re: leaving UTC out when referring to the length of a day. One of the most common references for people (Wikipedia) clearly states a UTC day sometimes contains an extra second, so it would be like the spec saying "A UTC day is not a UTC day".
As for removing most mentions of UTC, the spec currently has 69 lines that mention UTC at least once. Even if removal is technically sound, careful wording would have to replace it and it's a larger proposal that would have to be discussed separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for removing most mentions of UTC, [...] it's a larger proposal that would have to be discussed separately.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose UTC isn't right.
What I'm going for is not local, because of course the spec does support
local time which, due to DST or zone splitting, has days not of that length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked @bterlson and he didn't see an issue with mentioning the alignment with the POSIX specification of a day, so see my last push for proposed wording.
@jmdyck When looking back over the POSIX spec, it appears they did exactly as you are suggesting and changed all references from "seconds since 00:00:00 UTC (Coordinated
Universal Time), January 1 1970" to "seconds since the Epoch". I'd be ok with attempting to tackle that as a subsequent PR. I'm guessing that might need to be brought up to the committee because it would likely involve defining the ES Epoch explicitly as 1970-01-01T00:00:00 TAI and adding similar implementation-defined language that POSIX resorted to:
The relationship between the actual time of day and the current value for seconds since the Epoch is unspecified.
How any changes to the value of seconds since the Epoch are made to align to a desired relationship with the current actual time is implementation-defined. As represented in seconds since the Epoch, each and every day shall be accounted for by exactly 86400 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a generally nice editorial change, add a little more background.
spec.html
Outdated
<tr> | ||
<td>+275760-09-13T00:00:00Z</td> | ||
<td>275760 A.D.</td> | ||
</tr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the addition of these extended years? It doesn't look like they are boundary cases, due to the more extremely values preceding and following them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, these are what you are separately proposing to be the new extreme permitted values, right?
@littledan I added further text clarifying Extended Years as noted and I removed the min/max safe integers from the example table since they lie outside the time value range and could be confusing. This should also take care of #1145 and allow you to approve tc39/test262#1501? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the interpretation of the previous text has been debated, and this patch is intended to nail down one possibly, I think we should consider this a normative change and get the appropriate input on it before landing. The first thing would be to mark it Normative: rather than Editorial:
0470265
to
6f52edf
Compare
@littledan I reformatted this as a single normative commit. I'll add the PR onto the agenda for May. |
For good measure, let's see if we can get in touch with implementers ahead of time to see how they would feel about making this change in their JS engines: |
spec.html
Outdated
@@ -27723,15 +27728,15 @@ <h1>Date Time String Format</h1> | |||
<!-- es6num="20.3.1.16.1" --> | |||
<emu-clause id="sec-extended-years"> | |||
<h1>Extended Years</h1> | |||
<p>ECMAScript requires the ability to specify 6 digit years (extended years); approximately 285,426 years, either forward or backward, from 01 January, 1970 UTC. To represent years before 0 or after 9999, ISO 8601 permits the expansion of the year representation, but only by prior agreement between the sender and the receiver. In the simplified ECMAScript format such an expanded year representation shall have 2 extra year digits and is always prefixed with a + or - sign. The year 0 is considered positive and hence prefixed with a + sign.</p> | |||
<p>ECMAScript requires the ability to specify 6 digit years, or <dfn>extended years</dfn>, to render the full range of a time value; -100,000,000 days to 100,000,000 days, or approximately -273,790 to 273,790 years, relative to midnight at the beginning of 01 January, 1970 UTC (<emu-xref href="#sec-time-values-and-time-range"></emu-xref>). To represent years before 0 or after 9999, ISO 8601 permits the expansion of the year representation, but only by prior agreement between the sender and the receiver. In the simplified ECMAScript format such an expanded year representation shall have 2 extra year digits and is always prefixed with a + or - sign. The year 0 is considered positive and hence prefixed with a + sign. ISO 8601 formatted strings with extended years representing points in time outside the range of a time value are not accepted.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if "ISO 8601 formatted strings with extended years representing points in time outside the range of a time value are not accepted." makes it clear that these date/time strings will result in an Invalid Date rather than being allowed to fall back to the implementation-specific parser. I think it'd be best if this behavior were explicitly described in Date.parse
. (Apologies for not mentioning this the first time around.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new text
ISO 8601 formatted strings with extended years representing points in time outside the range of a time value are represented as the Number NaN when parsed by
Date.parse()
and do not fall back to implementation-specific behavior or heuristics.
Looks great to me. Thanks for the clarification.
JSC Bug filed https://bugs.webkit.org/show_bug.cgi?id=185868 - "Date.parse() doesn't properly handle input outside of ES Spec limits" |
@littledan I believe I addressed your last concern by explicitly stating
instead of
This area of |
@littledan it seems like somehow this lost your review, could you re-ack? |
Now that ES2018 is finalized, we'll look at this in our next editor's meeting. |
Implementations are not currently consistently limiting *time values* to the spec defined ranges of both *time value* and *extended years*. This change is editorial cleanup that more clearly states the allowed *time value* range and the supported range of *extended years* that fit within the allowed *time value* range. Implementations will need to be updated to conform with the spec (SM currently adheres) and pass the accompanying test in tc39/test262#1501. Time Values and Time Range: - Language about `Number` range in hundreds-of-thousands of years plus/minus UTC epoch is not immediately relevant; move it to an `emu-note` - New `emu-note` text fixes inconsistency in spec where this section was not properly accounting for leap years when computing the approximate number of years in the maximum range but 20.3.1.15.1 *extended years* was stating it correctly - Add `emu-xref` for Number integer range - Add comment referring to POSIX day for the source of 86,400 seconds - Simplify remaining spec in section into clear, consistent language Extended Years: - Add `dfn` to *extended years* so it is linked from format section - Add `emu-xref` for *time value* range - Explicitly state *extended years* relation to *time value* range - Explicitly state ISO 8601 strings outside *time value* range are not accepted - Modify *extended years* example table to reflect the proper minimum/maximum values allowed by the *time value* range - More forceful Extended Years text: explicitly state *NaN* is returned instead of "are not accepted."
6f6d19b
to
2e2a3d4
Compare
Implementations are not currently consistently limiting time values to the spec defined ranges of both time value and extended years.
This change is editorial cleanup that more clearly states the allowed time value range and the supported range of extended years that fit within the allowed time value range.
Implementations will need to be updated to conform with the spec (SM currently adheres) and pass the accompanying test in tc39/test262#1501.
Concrete examples of what will be fixed are detailed in #1145.
Time Values and Time Range:
Number
range in hundreds-of-thousands of years plus/minus UTC epoch is not immediately relevant; move it to anemu-note
emu-note
text fixes inconsistency in spec where this section was not properly accounting for leap years when computing the approximate number of years in the maximum range but 20.3.1.15.1 extended years was stating it correctlyemu-xref
for Number integer rangeExtended Years:
dfn
to extended years so it is linked from format sectionemu-xref
for time value range