HTML5 has the
<time> element for marking up dates and times. When datetimes are annotated this way, it makes it easier to build jQuery scripts and applications that do cool things. We want to output all of our $submitted variables (and other datetimes) with this element.
<time> element has a datetime attribute which provides a machine processable version of the date. This can be given in a number of different formats. For example:
<time datetime="2011-12">Decemeber 2011</time>
<time datetime="01-01">New Years Day</time>
Create a theme_datetime function that takes:
- A 'text' variable to use between the
<time>tags. This is
check_plained by default, but a flag can be set to let it pass through in case it contains HTML.
- Either a formated date string to use for the datetime attribute, or a timestamp which is processed into the full datetime string
Patch needs review. A notable change is the introduction of new built-in datetime formats.
Original report by Everett Zufelt
Split from #1094324: Add new theme_functions for consistency - Discussion to add a theme_datetime() function.
From @Jeff Burnz in #1094324-1: Add new theme_functions for consistency - Discussion
The first one that really strikes me is our formatting of dates and times.
Our current use of times and dates is rather inconsistent in core, for example lets compare just a couple:
$variables['date'] = format_date($node->created);
Eventually this is printed in node tpl via $submitted and no markup is added anywhere - its naked and unless RDFa is enabled this carries zero semantics.
$variables['feed_age'] = t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->timestamp)));
$feed_age is printed in aggregator-summary-item.tpl.php wrapped in span's with a class: <span class="age"><?php print $feed_age; ?></span>
There are quite a few other instances of this sort of inconstancy in aggregator, and of course comment tpl does essentially the same thing as node.
I think we have a use case here for a theme_datetime() function. This would provide a simple wrapper with attributes. This will allow much easier global
override of markup for dates and times, for example if we want to use XHTML we can use a span, if we want to use HTML5 we can use time + the time attributes
such as pubdate, datetime etc.