W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Historic dates in HTML5

From: Philip Taylor <excors+whatwg@gmail.com>
Date: Thu, 5 Mar 2009 12:16:07 +0000
Message-ID: <ea09c0d10903050416o5de77a74lac27f2af746b7f59@mail.gmail.com>
On Thu, Mar 5, 2009 at 11:33 AM, jim at eatyourgreens.org.uk
<jim at eatyourgreens.org.uk> wrote:
> [...]
> Bruce Lawson uses <time> to mark up the dates of blog posts in the HTML5
> version of his wordpress templates. Is this incorrect usage of HTML5? If
> not, how should HTML5 blog templates work when the blog is dated from 1665
> (http://pepysdiary.com) or 1894 (http://www.cosmicdiary1894.blogspot.com/)?

This reminds me of the issue I had with the old <img
alt="{description}"> syntax.

People write software that takes some input, and outputs some markup.
They want to guarantee that their markup will be valid and correctly
interpreted by consumers, regardless of the input. (In the <img alt>
case, the problem was when the input resulted in legitimate
alternative (non-description) alt text that started with "{" and ended
with "}", forcing the application to add complexity to make sure its
output won't be misinterpreted.)

In any situation where they use <time>, they'd probably want to write
something like:

  print "<time datetime=".$t->toISO8601Date().">".$t->toLocalisedHumanReadableDate()."</time>";

But given HTML5's restrictions against BCE years, they'd actually have
to write something more like:

  if ($t->getYear() > 0) { # (be careful not to write ">= 0" here)
    print "<time class=time
datetime=".$t->toISO8601Date().">".$t->toLocalisedHumanReadableDate()."</time>";
  } else {
    print "<span class=time>".$t->toLocalisedHumanReadableDate()."</span>";
  }

and make sure their stylesheets use the selector ".time" instead of
"time", to guarantee everything is going to work correctly even with
unexpected input values.

So the restriction adds complexity (and bugs) to code that wants to be
good and careful and generate valid markup.

-- 
Philip Taylor
excors at gmail.com
Received on Thursday, 5 March 2009 04:16:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:47:49 GMT