function _date_token_values in Date 5
Same name and namespace in other branches
- 5.2 date/date_token.inc \_date_token_values()
1 call to _date_token_values()
- date.module in ./
date.module - Defines a date/time field type.
File
- ./
date_token.inc, line 33 - Token module integration.
Code
function _date_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
include_once drupal_get_path('module', 'date') . '/date.inc';
$item = $object[0];
$item['value'] = trim($item['value']);
$item_format = is_numeric($item['value']) ? DATE_UNIX : DATE_ISO;
$date = date_make_date($item['value'], 'none', 'local', $item_format);
$tokens['value'] = $item['value'];
$tokens['view'] = $item['view'];
$tokens['timestamp'] = $date->local->timestamp;
$tokens['yyyy'] = date_show_date($date, 'Y');
$tokens['yy'] = date_show_date($date, 'y');
$tokens['month'] = date_show_date($date, 'F');
$tokens['mon'] = date_show_date($date, 'M');
$tokens['mm'] = date_show_date($date, 'm');
$tokens['m'] = date_show_date($date, 'n');
$tokens['ww'] = date_show_date($date, 'W');
$tokens['date'] = date_show_date($date, 'N');
$tokens['day'] = date_show_date($date, 'l');
$tokens['ddd'] = date_show_date($date, 'D');
$tokens['dd'] = date_show_date($date, 'd');
$tokens['d'] = date_show_date($date, 'j');
if (!empty($item['value2'])) {
$item['value2'] = trim($item['value2']);
$item_format = is_numeric($item['value2']) ? DATE_UNIX : DATE_ISO;
$date = date_make_date($item['value2'], 'none', 'local', $item_format);
$tokens['to-value'] = $item['value2'];
$tokens['to-view'] = $item['view2'];
$tokens['to-timestamp'] = $date->local->timestamp;
$tokens['to-yyyy'] = date_show_date($date, 'Y');
$tokens['to-yy'] = date_show_date($date, 'y');
$tokens['to-month'] = date_show_date($date, 'F');
$tokens['to-mon'] = date_show_date($date, 'M');
$tokens['to-mm'] = date_show_date($date, 'm');
$tokens['to-m'] = date_show_date($date, 'n');
$tokens['to-ww'] = date_show_date($date, 'W');
$tokens['to-date'] = date_show_date($date, 'N');
$tokens['to-day'] = date_show_date($date, 'l');
$tokens['to-ddd'] = date_show_date($date, 'D');
$tokens['to-dd'] = date_show_date($date, 'd');
$tokens['to-d'] = date_show_date($date, 'j');
}
return $tokens;
}
}