Short URL: http://html5.org/r/2381
| SVN | Bug | Comment | Time (UTC) |
|---|---|---|---|
| 2381 | Redefine datetimes to be stricter. Merge the two definitions of timezoned datetimes. | 2008-10-30 00:21 |
Index: source
===================================================================
--- source (revision 2380)
+++ source (revision 2381)
@@ -1953,58 +1953,150 @@
href="#refsGREGORIAN">[GREGORIAN]</a></p>
- <h5>Specific moments in time</h5>
+ <h5>Global dates and times</h5>
- <p class="XXX">This syntax is going to be tightened up and
- made almost exactly the same as the <span>valid UTC date and time
- string</span> syntax, with the exception of allowing time zones. In
- fact what we might do is allow time zones in general, use the same
- parser, etc, but require that UAs always use the UTC time zone when
- synthesizing datetimes for form submission.</p>
+ <p>A <dfn title="concept-datetime">global date and time</dfn>
+ consists of a specific Gregorian date, consisting of a year, a
+ month, a day, an hour, a minute, a second, and a fraction of a
+ second, expressed with a time zone, consisting of a number of hours
+ and minutes. <a href="#refsGREGORIAN">[GREGORIAN]</a></p>
- <p>A string is a <dfn>valid datetime</dfn> if it has four digits
- (representing the year), a literal hyphen, two digits (representing
- the month), a literal hyphen, two digits (representing the day),
- optionally some spaces, either a literal T or a space, optionally
- some more spaces, two digits (for the hour), a colon, two digits
- (the minutes), optionally the seconds (which, if included, must
- consist of another colon, two digits (the integer part of the
- seconds), and optionally a decimal point followed by one or more
- digits (for the fractional part of the seconds)), optionally some
- spaces, and finally either a literal Z (indicating the time zone is
- UTC), or, a plus sign or a minus sign followed by two digits, a
- colon, and two digits (for the sign, the hours and minutes of the
- timezone offset respectively); with the month-day combination being
- a valid date in the given year according to the Gregorian calendar,
- the hour values (<var title="">h</var>) being in the range
- 0 ≤ <var title="">h</var> ≤ 23, the minute
- values (<var title="">m</var>) in the range 0 ≤ <var
- title="">m</var> ≤ 59, and the second value (<var
- title="">s</var>) being in the range 0 ≤ <var
- title="">h</var> < 60. <a
- href="#refsGREGORIAN">[GREGORIAN]</a></p>
-
<!--XXX [GREGORIAN] should point to
<dd id="refsGREGORIAN">[GREGORIAN]</dd>
<dd>(Non-normative) <cite>Inter Gravissimas</cite>, A. Lilius, C. Clavius. Gregory XIII Papal Bulls, February 1582.</dd>
-->
- <p>The digits must be characters in the range U+0030 DIGIT ZERO (0)
- to U+0039 DIGIT NINE (9), the hyphens must be a U+002D HYPHEN-MINUS
- characters, the T must be a U+0054 LATIN CAPITAL LETTER T, the
- colons must be U+003A COLON characters, the decimal point must be a
- U+002E FULL STOP, the Z must be a U+005A LATIN CAPITAL LETTER Z, the
- plus sign must be a U+002B PLUS SIGN, and the minus U+002D (same as
- the hyphen).</p>
+ <p>A string is a <dfn>valid global date and time string</dfn> if it
+ has the components in the following list, in the given order, and if
+ the components in the list follow the constraints given after the
+ list:</p>
+ <ol>
+
+ <li>Four or more digits (representing the year)</li>
+
+ <li>A U+002D HYPHEN-MINUS character (-).</li>
+
+ <li>Two digits (representing the month)</li>
+
+ <li>A U+002D HYPHEN-MINUS character (-).</li>
+
+ <li>Two digits (representing the day)</li>
+
+ <li>A U+0054 LATIN CAPITAL LETTER T character.</li>
+
+ <li>Two digits (representing the hour)</li>
+
+ <li>A U+003A COLON character (:).</li>
+
+ <li>Two digits (representing the minutes)</li>
+
+ <li>Optionally:
+
+ <ol>
+
+ <li>A U+003A COLON character (:).</li>
+
+ <li>Two digits (representing the integer part of the seconds)</li>
+
+ <li>Optionally:
+
+ <ol>
+
+ <li>A 002E FULL STOP character (.)</li>
+
+ <li>One or more digits (representing the fractional part of the seconds)</li>
+
+ </ol>
+
+ </li>
+
+ </ol>
+
+ </li>
+
+ <li>Either:
+
+ <ul>
+
+ <li>A U+005A LATIN CAPITAL LETTER Z character (indicating the
+ time zone is UTC)</li>
+
+ <li>Or:
+
+ <ol>
+
+ <li>Either a U+002B PLUS SIGN character (+) or a U+002D
+ HYPHEN-MINUS (-) character (the sign of the timezone
+ offset)</li>
+
+ <li>Two digits (representing the hours component of the timezone offset)</li>
+
+ <li>A U+003A COLON character (:).</li>
+
+ <li>Two digits (representing the minutes component of the timezone offset)</li>
+
+ </ol>
+
+ </li>
+
+ </ul>
+
+ </li>
+
+ </ol>
+
+ <p>The aforementioned constraints are:</p>
+
+ <ul>
+
+ <li>The month <var title="">m</var> must be in the range
+ 0 ≤ <var title="">m</var> ≤ 12.</li>
+
+ <li>The day <var title="">d</var> must be in the range
+ 0 ≤ <var title="">d</var> ≤ <var
+ title="">D</var> where <var title="">D</var> is the <span
+ title="number of days in month month of year year">number of days
+ in the given month and year</span>.</li>
+
+ <li>The hour <var title="">h</var> must be in the range
+ 0 ≤ <var title="">h</var> ≤ 23.</li>
+
+ <li>The minute <var title="">m</var> must be in the range
+ 0 ≤ <var title="">m</var> ≤ 59.</li>
+
+ <li>If present, the second <var title="">s</var> (consisting of the
+ integer part and its fractional part) must be in the range
+ 0 ≤ <var title="">s</var> < 60. (The
+ values 60 and 61 are not allowed: leap seconds cannot be
+ represented by datetime values.)</li>
+
+ <li>If present, the time zone hour <var title="">h</var> must be in
+ the range 0 ≤ <var
+ title="">h</var> ≤ 23. (However, in practice, time
+ zones do not currently ever have an hour component greater than
+ 14.)</li>
+
+ <li>If present, the time zone minute <var title="">m</var> must be
+ in the range 0 ≤ <var
+ title="">m</var> ≤ 59. (However, in practice, time
+ zones do not currently ever have a minute component other than 0, 30,
+ or 45.)</li>
+
+ </ul>
+
+ <p>The digits must be characters in the range U+0030 DIGIT ZERO to
+ U+0039 DIGIT NINE, used to express numbers in base ten.</p>
+
<div class="example">
<p>The following are some examples of dates written as <span
- title="valid datetime">valid datetimes</span>.</p>
+ title="valid global date and time string">valid global date and
+ time strings</span>.</p>
<dl>
- <dt>"<code>0037-12-13 00:00 Z</code>"</dt>
+ <dt>"<code>0037-12-13T00:00Z</code>"</dt>
<dd>Midnight UTC on the birthday of Nero (the Roman Emperor).</dd>
@@ -2014,11 +2106,12 @@
zone in use on the east coast of North America during daylight
saving time.</dd>
- <dt>"<code>8592-01-01 T 02:09 +02:09</code>"</dt>
+ <dt>"<code>8592-01-01T02:09+02:09</code>"</dt>
<dd>Midnight UTC on the 1st of January, 8592. The time zone
associated with that time is two hours and nine minutes ahead of
- UTC.</dd>
+ UTC, which is not a real time zone currently, but is nonetheless
+ allowed.</dd>
</dl>
@@ -2042,8 +2135,8 @@
<li>The time and timezone components are not optional.</li>
- <li>Dates before the year 0 or after the year 9999 can't be
- represented as a datetime in this version of HTML.</li>
+ <li>Dates before the year zero can't be represented as a datetime
+ in this version of HTML.</li>
<li>Time zones differ based on daylight savings time.</li>
@@ -2051,16 +2144,11 @@
</div>
- <p class="note">Conformance checkers can use the algorithm below to
- determine if a datetime is a valid datetime or not.</p>
-
- <p>To <dfn id="datetime-parser">parse a string as a datetime
- value</dfn>, a user agent must apply the following algorithm to the
- string. This will either return a time in UTC, with associated
+ <p>The rules to <dfn>parse a global date and time string</dfn> are
+ as follows. This will either return a time in UTC, with associated
timezone information for round tripping or display purposes, or
- nothing, indicating the value is not a <span>valid
- datetime</span>. If at any point the algorithm says that it "fails",
- this means that it returns nothing.</p>
+ nothing. If at any point the algorithm says that it "fails", this
+ means that it is aborted at that point and returns nothing.</p>
<ol>
@@ -2073,9 +2161,9 @@
<li><p><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is not exactly four characters long, then fail. Otherwise,
- interpret the resulting sequence as a base-ten integer. Let that
- number be the <var title="">year</var>.</p></li>
+ sequence is not at least four characters long, then
+ fail. Otherwise, interpret the resulting sequence as a base-ten
+ integer. Let that number be the <var title="">year</var>.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var
title="">input</var> or if the character at <var
@@ -2090,7 +2178,8 @@
number be the <var title="">month</var>.</p></li>
<li>If <var title="">month</var> is not a number in the range
- 1 ≤ <var title="">month</var> ≤ 12, then fail.</li>
+ 1 ≤ <var title="">month</var> ≤ 12, then
+ fail.</li>
<li><p>Let <var title="">maxday</var> be the <span>number of days
in month <var title="">month</var> of year <var
@@ -2112,11 +2201,11 @@
1 ≤ <var title="">month</var> ≤ <var
title="">maxday</var>, then fail.</li>
- <li><p><span>Collect a sequence of characters</span> that are
- either U+0054 LATIN CAPITAL LETTER T characters or <span
- title="space character">space characters</span>. If the collected
- sequence is zero characters long, or if it contains more than one
- U+0054 LATIN CAPITAL LETTER T character, then fail.</p></li>
+ <li><p>If <var title="">position</var> is beyond the end of <var
+ title="">input</var> or if the character at <var
+ title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
+ character then fail. Otherwise, move <var title="">position</var>
+ forwards one character.</p></li>
<li><p><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
@@ -2125,13 +2214,14 @@
number be the <var title="">hour</var>.</p></li>
<li>If <var title="">hour</var> is not a number in the range
- 0 ≤ <var title="">hour</var> ≤ 23, then fail.</li>
+ 0 ≤ <var title="">hour</var> ≤ 23, then
+ fail.</li>
<li><p>If <var title="">position</var> is beyond the end of <var
title="">input</var> or if the character at <var
- title="">position</var> is not a U+003A COLON character,
- then fail. Otherwise, move <var title="">position</var> forwards
- one character.</p></li>
+ title="">position</var> is not a U+003A COLON character, then
+ fail. Otherwise, move <var title="">position</var> forwards one
+ character.</p></li>
<li><p><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
@@ -2140,7 +2230,8 @@
number be the <var title="">minute</var>.</p></li>
<li>If <var title="">minute</var> is not a number in the range
- 0 ≤ <var title="">minute</var> ≤ 59, then fail.</li>
+ 0 ≤ <var title="">minute</var> ≤ 59, then
+ fail.</li>
<li><p>Let <var title="">second</var> be a string with the value
"0".</p></li>
@@ -2148,9 +2239,11 @@
<li><p>If <var title="">position</var> is beyond the end of <var
title="">input</var>, then fail.</p></li>
- <li><p>If the character at <var title="">position</var> is a U+003A
- COLON, then:</p>
+ <li>
+ <p>If the character at <var title="">position</var> is a U+003A
+ COLON, then run these substeps:</p>
+
<ol>
<li><p>Advance <var title="">position</var> to the next character
@@ -2177,41 +2270,38 @@
</li>
<li><p>Interpret <var title="">second</var> as a base-ten number
- (possibly with a fractional part). Let that number be <var
- title="">second</var> instead of the string version.</p></li>
+ (possibly with a fractional part). Let <var title="">second</var>
+ be that number instead of the string version.</p></li>
<li>If <var title="">second</var> is not a number in the range
0 ≤ <var title="">second</var> < 60, then
- fail. (The values 60 and 61 are not allowed: leap seconds cannot be
- represented by datetime values.)</li>
+ fail.</li>
<li><p>If <var title="">position</var> is beyond the end of <var
title="">input</var>, then fail.</p></li>
- <li><p><span>Skip whitespace</span>.</p></li>
+ <li>
- <li><p>If the character at <var title="">position</var> is a
- U+005A LATIN CAPITAL LETTER Z, then:</p>
+ <p>If the character at <var title="">position</var> is a U+005A
+ LATIN CAPITAL LETTER Z, then:</p>
<ol>
- <li><p>Let <var title="">timezone<sub title="">hours</sub></var> be
- 0.</p></li>
+ <li><p>Let <var title="">timezone<sub title="">hours</sub></var>
+ be 0.</p></li>
- <li><p>Let <var title="">timezone<sub title="">minutes</sub></var> be
- 0.</p></li>
+ <li><p>Let <var title="">timezone<sub
+ title="">minutes</sub></var> be 0.</p></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
</ol>
- </li>
+ <p>Otherwise, if the character at <var title="">position</var> is
+ either a U+002B PLUS SIGN ("+") or a U+002D HYPHEN-MINUS ("-"),
+ then:</p>
- <li><p>Otherwise, if the character at <var title="">position</var>
- is either a U+002B PLUS SIGN ("+") or a U+002D HYPHEN-MINUS ("-"),
- then:</p>
-
<ol>
<li><p>If the character at <var title="">position</var> is a
@@ -2226,13 +2316,13 @@
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
- integer. Let that number be the <var
- title="">timezone<sub title="">hours</sub></var>.</p></li>
+ integer. Let that number be the <var title="">timezone<sub
+ title="">hours</sub></var>.</p></li>
- <li>If <var title="">timezone<sub title="">hours</sub></var> is not a
- number in the range 0 ≤ <var
- title="">timezone<sub title="">hours</sub></var> ≤ 23, then
- fail.</li>
+ <li>If <var title="">timezone<sub title="">hours</sub></var> is
+ not a number in the range 0 ≤ <var
+ title="">timezone<sub
+ title="">hours</sub></var> ≤ 23, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var
title="">timezone<sub title="">hours</sub></var>.</li>
@@ -2247,13 +2337,13 @@
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
- integer. Let that number be the <var
- title="">timezone<sub title="">minutes</sub></var>.</p></li>
+ integer. Let that number be the <var title="">timezone<sub
+ title="">minutes</sub></var>.</p></li>
- <li>If <var title="">timezone<sub title="">minutes</sub></var> is not a
- number in the range 0 ≤ <var
- title="">timezone<sub title="">minutes</sub></var> ≤ 59, then
- fail.</li>
+ <li>If <var title="">timezone<sub title="">minutes</sub></var> is
+ not a number in the range 0 ≤ <var
+ title="">timezone<sub
+ title="">minutes</sub></var> ≤ 59, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var
title="">timezone<sub title="">minutes</sub></var>.</li>
@@ -2285,20 +2375,6 @@
</ol>
- <h5>UTC dates and times</h5>
-
- <p>A <dfn title="concept-datetime">UTC date and time</dfn> consists
- of a specific Gregorian date expressed relative to the UTC timezone,
- consisting of a year, a month, a day, an hour, a minute, a second,
- and a fraction of a second. <a
- href="#refsGREGORIAN">[GREGORIAN]</a></p>
-
- <p class="XXX">... <dfn>valid UTC date and time string</dfn></p>
-
- <p class="XXX">... rules to <dfn>parse a UTC date and time
- string</dfn></p>
-
-
<h5>Local dates and times</h5>
<p>A <dfn title="concept-datetime-local">local date and time</dfn>
@@ -14411,17 +14487,18 @@
attribute may be used to specify the time and date of the change.</p>
<p>If present, the <code title="attr-mod-datetime">datetime</code>
- attribute must be a <span>valid datetime</span> value.</p>
+ attribute must be a <span>valid global date and time string</span>
+ value.</p>
<p>User agents must parse the <code
title="attr-mod-datetime">datetime</code> attribute according to the
- <span>parse a string as a datetime value</span> algorithm. If that
+ <span>parse a global date and time string</span> algorithm. If that
doesn't return a time, then the modification has no associated
timestamp (the value is non-conforming; it is not a <span>valid
- datetime</span>). Otherwise, the modification is marked as having
- been made at the given datetime. User agents should use the
- associated timezone information to determine which timezone to
- present the given datetime in.</p>
+ global date and time string</span>). Otherwise, the modification is
+ marked as having been made at the given datetime. User agents should
+ use the associated timezone information to determine which timezone
+ to present the given datetime in.</p>
<p>The <code>ins</code> and <code>del</code> elements must implement
the <code>HTMLModElement</code> interface:</p>
@@ -27032,40 +27109,46 @@
<p>The <code>input</code> element represents a control for setting
the element's <span title="concept-fe-value">value</span> to a
- string representing a specific <span title="concept-datetime">UTC
+ string representing a specific <span title="concept-datetime">global
date and time</span>. User agents may display the date and time in
whatever timezone is appropriate for the user.</p>
<p>If the element is <i title="concept-input-mutable">mutable</i>,
the user agent should allow the user to change the <span
- title="concept-datetime">UTC date and time</span> represented by its
- <span title="concept-fe-value">value</span>, as obtained by <span
- title="parse a UTC date and time string">parsing a UTC date and
- time</span> from it. User agents must not allow the user to set the
- <span title="concept-fe-value">value</span> to a string that is not
- a <span>valid UTC date and time string</span>. If the user agent
- provides a user interface for selecting a <span
- title="concept-datetime">UTC date and time</span>, then the <span
+ title="concept-datetime">global date and time</span> represented by
+ its <span title="concept-fe-value">value</span>, as obtained by
+ <span title="parse a global date and time string">parsing a global
+ date and time</span> from it. User agents must not allow the user to
+ set the <span title="concept-fe-value">value</span> to a string that
+ is not a <span>valid global date and time string</span> expressed in
+ UTC, though user agents may allow the user to set and view the time
+ in another timezone and silently translate the time to and from the
+ UTC timezone in the <span title="concept-fe-value">value</span>. If
+ the user agent provides a user interface for selecting a <span
+ title="concept-datetime">global date and time</span>, then the <span
title="concept-fe-value">value</span> must be set to a <span>valid
- UTC date and time string</span> representing the user's
- selection. User agents should allow the user to set the <span
+ global date and time string</span> expressed in UTC representing the
+ user's selection. User agents should allow the user to set the <span
title="concept-fe-value">value</span> to the empty string.</p>
<p>The <code title="attr-input-value">value</code> attribute, if
- specified, must have a value that is a <span>valid UTC date and time
- string</span>.</p> <!-- ok to set out-of-range value, we never know
- when we might have to represent bogus input -->
+ specified, must have a value that is a <span>valid global date and
+ time string</span>.</p> <!-- ok to set out-of-range value, we never
+ know when we might have to represent bogus input -->
<p><strong>The <span>value sanitization algorithm</span> is as
follows:</strong> If the <span title="concept-fe-value">value</span>
- of the element is not a <span>valid UTC date and time string</span>,
- then set it to the empty string instead.</p>
+ of the element is a <span>valid global date and time string</span>,
+ then adjust the time so that the <span
+ title="concept-fe-value">value</span> represents the same point in
+ time but expressed in the UTC timezone, otherwise, set it to the
+ empty string instead.</p>
<p>The <code title="attr-input-min">min</code> attribute, if
- specified, must have a value that is a <span>valid UTC date and time
- string</span>. The <code title="attr-input-max">max</code>
- attribute, if specified, must have a value that is a <span>valid UTC
- date and time string</span>.</p>
+ specified, must have a value that is a <span>valid global date and
+ time string</span>. The <code title="attr-input-max">max</code>
+ attribute, if specified, must have a value that is a <span>valid
+ global date and time string</span>.</p>
<p>The <code title="attr-input-step">step</code> attribute is
expressed in seconds. The <span
@@ -27077,28 +27160,28 @@
<p>When the element is <span>suffering from a step mismatch</span>,
the user agent may round the element's <span
title="concept-fe-value">value</span> to the nearest <span
- title="concept-datetime">UTC date and time</span> for which the
+ title="concept-datetime">global date and time</span> for which the
element would not <span title="suffering from a step
mismatch">suffer from a step mismatch</span>.</p>
<p><strong>The <span
title="concept-input-value-string-number">algorithm to convert a
string to a number</span>, given a string <var title="">input</var>,
- is as follows:</strong> If <span title="parse a UTC date and time
- string">parsing a UTC date and time</span> from <var
+ is as follows:</strong> If <span title="parse a global date and time
+ string">parsing a global date and time</span> from <var
title="">input</var> results in an error, then return an error;
otherwise, return the number of milliseconds elapsed from midnight
UTC on the morning of 1970-01-01 (the time represented by the value
"<code title="">1970-01-01T00:00:00.0Z</code>") to the parsed <span
- title="concept-datetime">UTC date and time</span>, ignoring leap
+ title="concept-datetime">global date and time</span>, ignoring leap
seconds.</p>
<p><strong>The <span
title="concept-input-value-number-string">algorithm to convert a
number to a string</span>, given a number <var title="">input</var>,
- is as follows:</strong> Return a <span>valid UTC date and time
- string</span> that represents the <span
- title="concept-datetime">date and time in UTC</span> that is <var
+ is as follows:</strong> Return a <span>valid global date and time
+ string</span> expressed in UTC that represents the <span
+ title="concept-datetime">global date and time</span> that is <var
title="">input</var> milliseconds after midnight UTC on the morning
of 1970-01-01 (the time represented by the value "<code
title="">1970-01-01T00:00:00.0Z</code>").</p>
@@ -27107,18 +27190,19 @@
title="concept-input-value-string-date">algorithm to convert a
string to a <code>Date</code> object</span>, given a string <var
title="">input</var>, is as follows:</strong> If <span title="parse
- a UTC date and time string">parsing a UTC date and time</span> from
- <var title="">input</var> results in an error, then return an error;
- otherwise, return a <code>Date</code> object representing the parsed
- <span title="concept-datetime">UTC date and time</span>.</p>
+ a global date and time string">parsing a global date and time</span>
+ from <var title="">input</var> results in an error, then return an
+ error; otherwise, return a <code>Date</code> object representing the
+ parsed <span title="concept-datetime">global date and time</span>,
+ expressed in UTC.</p>
<p><strong>The <span
title="concept-input-value-date-string">algorithm to convert a
<code>Date</code> object to a string</span>, given a
<code>Date</code> object <var title="">input</var>, is as
- follows:</strong> Return a <span>valid UTC date and time
- string</span> that represents the <span
- title="concept-datetime">date and time in UTC</span> that is
+ follows:</strong> Return a <span>valid global date and time
+ string</span> expressed in UTC that represents the <span
+ title="concept-datetime">global date and time</span> that is
represented by <var title="">input</var>.</p>
<div class="bookkeeping">