diff -urpN cck_formatters_orig/spandate/spandate.info cck_formatters/spandate/spandate.info --- cck_formatters_orig/spandate/spandate.info 1969-12-31 16:00:00.000000000 -0800 +++ cck_formatters/spandate/spandate.info 2010-03-09 06:55:04.625032542 -0800 @@ -0,0 +1,5 @@ +name = Spanned date field +description = "[spandate] Date formatter with span tags around month, day, and year, all wrapped in div with past, current (in next 12 hours), and future." +package = "Date/Time" +core = 6.x +dependencies[] = date Binary files cck_formatters_orig/spandate/.spandate.info.swp and cck_formatters/spandate/.spandate.info.swp differ diff -urpN cck_formatters_orig/spandate/spandate.module cck_formatters/spandate/spandate.module --- cck_formatters_orig/spandate/spandate.module 1969-12-31 16:00:00.000000000 -0800 +++ cck_formatters/spandate/spandate.module 2010-03-09 08:06:32.144815802 -0800 @@ -0,0 +1,47 @@ + array('label' => t('Wrap three parts of date in spans'), + 'field types' => array('date', 'datestamp', 'datetime'), + 'multiple values' => CONTENT_HANDLE_CORE), + ); +} + +/** + * Implements hook_theme(). + */ +function spandate_theme() { + return array( + 'spandate_formatter_trispan' => array( + 'arguments' => array('element' => NULL), + 'function' => 'theme_spandate_trispan'), + ); +} + +/** + * Theme function to display dates with spans around them. + */ +function theme_spandate_trispan($element) { + $o = ''; // Output. + // Surely we could have it given to us as a UNIX time? Ah well. + $datetime = strtotime($element['#item']['value']); + $now = time(); + $relative = 'future'; + if ($datetime < $now) { + $relative = 'past'; + } + elseif ($datetime >= $now && $datetime <= $now + 12*60*60) { + $relative = 'current'; + } + $o .= '
'; + $o .= '' . date('M', $datetime) . ''; + $o .= '' . date('d', $datetime) . ''; + $o .= '' . date('Y', $datetime) . ''; + $o .= '
'; + return $o; +}