From bc3e56ab5cfff73715838f78c82cef3c98a69236 Mon Sep 17 00:00:00 2001 From: Jesse Beach Date: Sun, 6 Nov 2011 21:20:52 -0500 Subject: [PATCH] Issue #1183250 by jessebeach, linclark, ericduran, Everett Zufelt, sun, aspilicious, scor: Introduced theme_datetime Signed-off-by: Jesse Beach --- core/includes/common.inc | 3 + core/includes/theme.inc | 65 ++++++++++++++++++++++++++++++ core/modules/simpletest/tests/theme.test | 52 ++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 0 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index 4229d52..283f75f 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -6564,6 +6564,9 @@ function drupal_common_theme() { 'render element' => 'elements', 'template' => 'region', ), + 'datetime' => array( + 'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array(), 'html' => FALSE), + ), 'status_messages' => array( 'variables' => array('display' => NULL), ), diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1e45b2a..a0f38b9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1460,6 +1460,71 @@ function theme_disable($theme_list) { */ /** + * Preprocess variables for theme_datetime(). + */ +function template_preprocess_datetime(&$variables) { + // Use the datetime attribute if provided. + if (empty($variables['attributes']['datetime'])) { + // If the datetime attribute was not provided, attempt to use the timestamp + // value as the datetime attribute. + if (!empty($variables['timestamp'])) { + // Format the timestamp with gmdate to produce a valid date/time format. + // See http://www.w3.org/TR/html5/common-microsyntaxes.html#valid-date-string-with-optional-time + $variables['attributes']['datetime'] = gmdate('Y-m-d\TH:i:s\Z', $variables['timestamp']); + // If no text for the