function theme_hms in HMS Field 7
Theme HMS
File
- ./
hms_field.module, line 292 - Provides an hms_field functionality.
Code
function theme_hms($variables) {
$classes = array(
'hms',
str_replace(':', '-', 'hms-format-' . $variables['format']),
);
$value = $variables['value'];
$offset = $variables['offset'];
$default_value = $variables['default_value'];
if ($variables['running_since'] !== 0) {
if (!$offset && !$default_value && $value) {
// Backwards compatible.
$offset = $value;
$default_value = $value;
$value = 0;
}
$value = $default_value;
// It is not possible to run longer then from 1970-01-01 00:00:01
$classes[] = 'hms-running';
// We also need to pass the running since value to JS.
// When format h is presented, the underlaying value can be at 3599
// The next second h needs to update.
// Be sure to pass running_since as time() (== GMT time)
if ($variables['running_since'] < 0) {
$variables['running_since'] = REQUEST_TIME;
}
$classes[] = 'hms-since-' . $variables['running_since'];
$classes[] = 'hms-offset-' . $offset;
$classes[] = 'hms-leading_zero-' . $variables['leading_zero'];
if ($offset) {
$value = REQUEST_TIME - $variables['running_since'] + $offset;
}
_hms_add_running_js();
}
$html = '<span class="' . implode(' ', $classes) . '">';
$html .= _hms_seconds_to_formatted($value, $variables['format'], $variables['leading_zero']);
$html .= '</span>';
return $html;
}