[whatwg] Re: datetime input

Sander wrote:
> .. So in the absence of "y",
> we'd have to define that the useragent should assume the current year (?)

   I don't think the user agent should assume any specific year or other 
missing value; the date should be just sent in the appropriate 
representation that indicates the missing and implied fields, and allow 
the server to determine them if required, or return an error to the user 
to indicate which fields are missing.

> (Does that ISO spec specify a way to write down weekday? [Sorry,
> not online while writing this, or I'd look it up to do this right.])

   Yes, it does.  It uses a single digit from 1 to 7, where days are 
numbered from Monday (1) to Sunday (7).  It must be a single digit to 
avoid ambiguity. (see truncated and reduced precision below)
eg.
YYYY-MM-DD (Year-Month-DayOfMonth) (DD has values 00 to 31
YYYY-Www-D (Year-Week-DayOfWeek) (D has values 1 to 7)
YYYY-DDD (Year-DayOfYear) (DDD has values 001 to 365 or 366 in a leap year)

Each of those can be truncated, or written with reduced precision, where 
truncated values are represented by a hyphen (-).  Dates with reduced 
precision simply omit the value, with no place holder.

?YYYY-MM (Year-Month with no DayOfMonth specified, ? is optional)
?YYYY (Year with no Month, Week or Day specified, ? is optional)
-MM-DD (Month and DayofMonth in the implied Year)
-MM (Month in the implied year with no DayOfMonth specified)
--DD (DayOfMonth in the implied month and Year)
-Www-D (Week and DayOfWeek in the implied Year)
-Www (Week in the implied Year with no DayOfWeek specified)
--D (DayOfWeek in the implied Week and Year)
     (Must be single digit to avoid confusion with DayOfMonth or DayOfYear)
--DDD or -DDD (DayOfYear in the implied Year)

   Similarly, times hh:mm:ssZ or hh:mm:ss?HH:MM can be truncated or 
shown with reduced precision.  Also, times allow a decimal fraction of 
the hour, minute or second to be indicated like this:
hh:mm:ss,s
hh:mm,m
hh,h

Where the comma (,) may be replaced by a dot (.) instead, however the 
ISO 8601 spec states that the comma is preferred (but I don't know why).

   In both the date and time representations, the seperators (- and :) 
may also be omitted, however you should be aware that representations 
without the seperators may become ambiguous.
eg. hhmmss may be interpreted as YYYYMM
The time 12:30:10 represented as 123010 may be interpreted as the year 
1230 and the 10 month (October).  This can be solved by appending the 
letter "T" to the begining of the time (T123010).

-- 
Lachlan Hunt

lachlan.hunt at lachy.id.au
http://www.lachy.id.au/

Received on Wednesday, 30 June 2004 22:20:53 UTC