[whatwg] Expanding datetime

Ernest Cline ernestcline at mindspring.com
Wed Apr 23 17:57:18 PDT 2008

The range of valid datetime strings is a subset of those specified by ISO 8601.  Most of the unused formats have been rejected on the grounds of simplicity of parsing, but a format (I think added in ISO 8601:2004, but it may have been earlier) offers a gain in utility that would not be unduly complicated to implement. Datetime is current limited to years in the range of 0000 - 9999.  Additional digits could be added to the year and still keep the string a valid ISO 8601 string, provided that the number to be added is agreed to and the added digits are always preceded by either a + or -.  For example, if one digit is added, then the day before 0000-01-01 could be represented as -00001-12-31.  From a practical viewpoint, being able to specify dates before January 1, 1 BC (Gregorian) would allow for historical dates not currently available to be specified in markup of documents concerning history.  The Y10K problem can also be pushed back by this, but is of only theoretical importance.

That said, a decision would be need to be made as to the number of extra digits.  ISO 8601 requires an implementation to specify a fixed number of added digits, because otherwise a value such as +00019 would be ambiguous in a implementation that used the full set of ISO 8601 formats. (+00019 could be the year 19 AD or the 19th century AD, depending upon whether one or three digits was added.)  That datetime doesn't use lone centuries doesn't matter.

Since the DOM assumes that time values will be stored as per ECMAScript type floats, for me the question of how many digits to add boils down to a simple one.  Is it preferable for all dates specified by datetime strings to be valid values to store in a Date object in ECMAScript, or would it be better for all values in a Date object to have a valid datetime string?  Currently the specification for datetime, because of its limit to four digits years goes along with the former not the latter.  We could add one digit and increase the range of allowable years from 100,001 BC to 99,999 AD and stay with in the range of a Date object.  Adding two digits, would allow all Date objects to have a representation as a datetime string.  (Adding zero digits and just adding the ability to add a sign is also an option, but would in my opinion be lesser than either of the other two options.)

More information about the whatwg mailing list