+ attribute is present, then use the rules to parse a date or
+ time string with the flag in attribute from the value
+ of that attribute, and let the result be result.
-
If result is empty (because the parsing
failed), then the date is
@@ -12546,10 +12360,10 @@ this specification: the <abbr>WHATWG</abbr> and the
timezone can only be present if both a date and a time are also
present.)
-
The date DOM attribute
- must return null if the date is
- unknown, and otherwise must return the time corresponding to
- midnight UTC (i.e. the first second) of the given date.
+
The date DOM
+ attribute must return null if the date is unknown, and otherwise must
+ return the time corresponding to midnight UTC (i.e. the first
+ second) of the given date.
The time DOM attribute
must return null if the time is
diff --git a/source b/source
index 5f169726b82..ca79cc40900 100644
--- a/source
+++ b/source
@@ -2577,6 +2577,42 @@
If position is beyond the end of input, then fail.
+
Parse a timezone component to obtain timezonehours and timezoneminutes. If this returns
+ nothing, then fail.
+
+
If position is not beyond the
+ end of input, then fail.
+
+
Let time be the moment in time at year
+ year, month month, day day, hours hour, minute minute, second second,
+ subtracting timezonehours
+ hours and timezoneminutes
+ minutes. That moment in time is a moment in the UTC
+ timezone.
+
+
Let timezone be timezonehours hours and timezoneminutes minutes from
+ UTC.
+
+
Return time and timezone.
+
+
+
+
The rules to parse a timezone component, given an input string and a position, are
+ as follows. This will either return timezone hours and timezone
+ minutes, or nothing. If at any point the algorithm says that it
+ "fails", this means that it is aborted at that point and returns
+ nothing.
+
+
+
If the character at position is a U+005A
@@ -2649,25 +2685,9 @@
-
If position is not beyond the
- end of input, then fail.
-
-
Let time be the moment in time at year
- year, month month, day day, hours hour, minute minute, second second,
- subtracting timezonehours
- hours and timezoneminutes
- minutes. That moment in time is a moment in the UTC
- timezone.
-
-
Let timezone be timezonehours hours and timezoneminutes minutes from
- UTC.
-
-
Return time and timezone.
+
Return timezonehours
+ and timezoneminutes.
@@ -2785,27 +2805,41 @@
Vaguer moments in time
-
This section defines date or
- time strings. There are two kinds, date or time strings in content, and date or time strings in
- attributes. The only difference is in the handling of
- whitespace characters.
+
A date or time string consists of either a date, a time, or a global date and time.
-
To parse a date or time string, user agents must use
- the following algorithm. A date or time string is a
- valid date or time string if the following algorithm, when
- run on the string, doesn't say the string is invalid.
-
+
A string is a valid date or time string if it is also
+ one of the following:
-
The algorithm may return nothing (in which case the string will
- be invalid), or it may return a date, a time, a date and a time, or
- a date and a time and a timezone. Even if the algorithm returns
- one or more values, the string can still be invalid.
+
+
+
A valid date string.
+
+
A valid time string.
+
+
A valid global date and time string.
+
+
+
+
A string is a valid date or time string in content if
+ it consists of zero or more White_Space characters,
+ followed by a valid date or time string, followed by
+ zero or more further White_Space characters.
+
+
The rules to parse a date or time string are as
+ follows. The algorithm is invoked with a flag indicating if the
+ in attribute variant or the in content variant is to
+ be used. The algorithm will either return a date, a time, a global date and time, or nothing. If
+ at any point the algorithm says that it "fails", this means that it
+ is aborted at that point and returns nothing.
-
Let input be the string being
parsed.
@@ -2813,326 +2847,97 @@
title="">input, initially pointing at the start of the
string.
-
Let results be the collection of results
- that are to be returned (one or more of a date, a time, and a
- timezone), initially empty. If the algorithm aborts at any point,
- then whatever is currently in results must be
- returned as the result of the algorithm.
-
-
-
For the "in content" variant: skip White_Space
- characters; for the "in attributes" variant: skip
- whitespace.
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is empty, then the string is invalid; abort these
- steps.
-
-
Let the sequence of characters collected in the last step be
- s.
-
-
If position is past the end of input, the string is invalid; abort these
- steps.
-
-
If the character at position is
- not a U+003A COLON character, then:
-
-
-
-
-
If the character at position is not a
- U+002D HYPHEN-MINUS ("-") character either, then the string is
- invalid, abort these steps.
-
-
-
If the sequence s is not exactly four
- digits long, then the string is invalid. (This does not stop the
- algorithm, however.)
-
-
Interpret the sequence of characters collected in step 5 as
- a base-ten integer, and let that number be year.
-
-
Advance position past the U+002D
- HYPHEN-MINUS ("-") character.
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is empty, then the string is invalid; abort these
- steps.
-
-
If the sequence collected in the last step is not exactly
- two digits long, then the string is invalid.
-
-
Interpret the sequence of characters collected two steps ago
- as a base-ten integer, and let that number be month.
-
-
If month is not a number in the range
- 1 ≤ month ≤ 12, then
- the string is invalid, abort these steps.
-
-
Let maxday be the number of days
- in month month of year year.
-
-
If position is past the end of input, or if the character at position is not a U+002D HYPHEN-MINUS ("-")
- character, then the string is invalid, abort these
- steps. Otherwise, advance position to the next
- character.
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is empty, then the string is invalid; abort these
- steps.
-
-
If the sequence collected in the last step is not exactly
- two digits long, then the string is invalid.
-
-
Interpret the sequence of characters collected two steps
- ago as a base-ten integer, and let that number be day.
-
-
If day is not a number in the range
- 1 ≤ day ≤ maxday, then the string is invalid, abort these
- steps.
-
-
Add the date represented by year, month, and day to the results.
-
-
-
-
-
For the "in content" variant: skip White_Space
- characters; for the "in attributes" variant: skip
- whitespace.
-
-
If the character at position is a U+0054
- LATIN CAPITAL LETTER T, then move position
- forwards one character.
-
-
For the "in content" variant: skip White_Space
- characters; for the "in attributes" variant: skip
- whitespace.
-
-
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is empty, then the string is invalid; abort these
- steps.
-
-
Let s be the sequence of characters
- collected in the last step.
-
-
-
-
-
-
-
-
If s is not exactly two digits long,
- then the string is invalid.
-
-
Interpret the sequence of characters collected two steps
- ago as a base-ten integer, and let that number be hour.
-
-
If hour is not a number in the range
- 0 ≤ hour ≤ 23, then
- the string is invalid, abort these steps.
-
-
If position is past the end of input, or if the character at position is not a U+003A COLON character,
- then the string is invalid, abort these steps. Otherwise, advance
- position to the next character.
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is empty, then the string is invalid; abort these
- steps.
-
-
If the sequence collected in the last step is not exactly
- two digits long, then the string is invalid.
-
-
Interpret the sequence of characters collected two steps
- ago as a base-ten integer, and let that number be minute.
-
-
If minute is not a number in the range
- 0 ≤ minute ≤ 59, then
- the string is invalid, abort these steps.
-
-
-
Let second be 0. It might be changed to
- another value in the next step.
+
For the in content variant: skip White_Space
+ characters.
-
If position is not past the end of input and the character at position is a U+003A COLON character, then:
+
Set start position to the same position
+ as position.
-
+
Set the date present and time present flags to true.
-
Collect a sequence of characters that are
- either characters in the range U+0030 DIGIT ZERO (0) to U+0039
- DIGIT NINE (9) or are U+002E FULL STOP. If the collected sequence
- is empty, or contains more than one U+002E FULL STOP character,
- then the string is invalid; abort these steps.
+
Parse a date component to obtain year, month, and day. If this fails, then set the date
+ present flag to false.
-
If the first character in the sequence collected in the
- last step is not in the range U+0030 DIGIT ZERO (0) to U+0039
- DIGIT NINE (9), then the string is invalid.
+
-
Interpret the sequence of characters collected two steps
- ago as a base-ten number (possibly with a fractional part), and
- let that number be second.
+
If date present is true, and position is not beyond the end of input, and the character at position is a U+0054 LATIN CAPITAL LETTER T
+ character, then advance position to the next
+ character in input.
-
If second is not a number in the range
- 0 ≤ minute < 60,
- then the string is invalid, abort these steps.
+
Otherwise, if date present is true, and
+ either position is beyond the end of input or the character at position is not a U+0054 LATIN CAPITAL LETTER T
+ character, then set time present to false.
-
+
Otherwise, if date present is false, set
+ position back to the same position as start position.
-
Add the time represented by hour, minute, and second to the results.
-
-
-
-
If results has both a date and a time,
- then:
-
-
-
-
For the "in content" variant: skip White_Space
- characters; for the "in attributes" variant: skip
- whitespace.
-
-
If position is past the end of input, then skip to the next step in the overall
- set of steps.
-
-
-
Otherwise, if the character at position is a U+005A LATIN CAPITAL LETTER Z,
- then:
-
-
-
-
Add the timezone corresponding to UTC (zero offset) to
- the results.
-
-
Advance position to the next character
- in input.
-
-
Skip to the next step in the overall set of
- steps.
-
-
-
-
+
If the time present flag is true, then
+ parse a time component to obtain hour, minute, and second. If this returns nothing, then set the time present flag to false.
-
-
Otherwise, if the character at position is either a U+002B PLUS SIGN ("+") or a
- U+002D HYPHEN-MINUS ("-"), then:
+
If both the date present and time present flags are false, then fail.
-
+
If the time present flag is true, but
+ position is beyond the end of input, then fail.
-
-
If the character at position is a
- U+002B PLUS SIGN ("+"), let sign be
- "positive". Otherwise, it's a U+002D HYPHEN-MINUS ("-"); let
- sign be "negative".
-
-
-
Advance position to the next
- character in input.
-
-
Collect a sequence of characters in the
- range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the
- collected sequence is not exactly two characters long, then
- the string is invalid.
-
-
Interpret the sequence collected in the last step as a
- base-ten number, and let that number be timezonehours.
-
-
If timezonehours is not a
- number in the range 0 ≤ timezonehours ≤ 23, then
- the string is invalid; abort these steps.
-
-
If sign is "negative", then negate timezonehours.
-
-
If position is beyond the end of
- input or if the character at position is not a U+003A COLON character, then
- the string is invalid; abort these steps. Otherwise, move position forwards one character.
-
-
-
Collect a sequence of characters in the range
- U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
- sequence is not exactly two characters long, then the string is invalid.
-
-
Interpret the sequence collected in the last step as a
- base-ten number, and let that number be timezoneminutes.
-
-
If timezoneminutes is not a
- number in the range 0 ≤ timezoneminutes ≤ 59,
- then the string is invalid; abort these steps.
-
-
Add the timezone corresponding to an offset of timezonehours hours and timezoneminutes minutes to the results.
-
-
Skip to the next step in the overall set of
- steps.
+
If the date present and time present flags are both true, parse a
+ timezone component to obtain timezonehours and timezoneminutes. If this returns nothing, then
+ fail.
-
+
For the in content variant: skip White_Space
+ characters.
-
+
If position is not beyond the
+ end of input, then fail.
-
Otherwise, the string is invalid; abort these
- steps.
+
-
+
If the date present flag is true and the
+ time present flag is false, then let date be the date with year year, month month, and day day, and return date.
+
+
Otherwise, if the time present flag is true
+ and the date present flag is false, then let
+ time be the time with hour hour, minute minute, and second
+ second, and return time.
+
+
Otherwise, let time be the moment in time
+ at year year, month month,
+ day day, hours hour,
+ minute minute, second second, subtracting timezonehours hours and timezoneminutes minutes, that moment in time being a
+ moment in the UTC timezone; let timezone be
+ timezonehours hours and
+ timezoneminutes minutes
+ from UTC; and return time and timezone.
-
For the "in content" variant: skip White_Space
- characters; for the "in attributes" variant: skip
- whitespace.
-
-
If position is not past the end
- of input, then the string is invalid.
-
-
Abort these steps (the string is parsed).
-
@@ -13313,15 +13118,14 @@ this specification: the <abbr>WHATWG</abbr> and the
The time element represents a date and/or a time.
The datetime
- attribute, if present, must contain a date or time
+ attribute, if present, must contain a valid date or time
string that identifies the date or time being specified.
-
If the datetime attribute is
- not present, then the date or time must be specified in the content
- of the element, such that parsing the element's
- textContent according to the rules for parsing date or time strings in
- content successfully extracts a date or time.
+
If the datetime attribute
+ is not present, then the date or time must be specified in the
+ content of the element, such that the element's
+ textContent is a valid date or time string in
+ content.
The dateTime DOM
attribute must reflect the WHATWG</abbr> and the
If the datetime
- attribute is present, then parse it according to the rules for
- parsing date or
- time strings in attributes, and let the result be parse a date or
+ time string with the flag in attribute from the value
+ of that attribute, and let the result be result.
-
Otherwise, parse the element's textContent
- according to the rules for parsing date or time strings in content, and let the
- result be result.
+
Otherwise, use the rules to parse a date or time
+ string with the flag in content from the element's
+ textContent, and let the result be result.
If result is empty (because the parsing
failed), then the date is
@@ -13363,10 +13167,11 @@ this specification: the <abbr>WHATWG</abbr> and the
-
The date DOM attribute
- must return null if the date is
- unknown, and otherwise must return the time corresponding to
- midnight UTC (i.e. the first second) of the given The date DOM
+ attribute must return null if the date is unknown, and otherwise must
+ return the time corresponding to midnight UTC (i.e. the first
+ second) of the given date.