function date_token_values in Date 6
Same name and namespace in other branches
- 6.2 date/date_token.inc \date_token_values()
- 7 date_token.inc \date_token_values()
File
- date/
date_token.inc, line 33 - Token module integration.
Code
function date_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
$item = $object[0];
$item['value'] = trim($item['value']);
$item_type = is_numeric($item['value']) ? DATE_UNIX : DATE_ISO;
$timezone = !empty($item['timezone']) ? $item['timezone'] : date_default_timezone_name();
$date = date_make_date($item['value'], $timezone, $item_type);
$tokens['value'] = $item['value'];
$tokens['view'] = $item['view'];
$tokens['timestamp'] = date_format_date($date, 'custom', 'U');
$tokens['yyyy'] = date_format_date($date, 'custom', 'Y');
$tokens['yy'] = date_format_date($date, 'custom', 'y');
$tokens['month'] = date_format_date($date, 'custom', 'F');
$tokens['mon'] = date_format_date($date, 'custom', 'M');
$tokens['mm'] = date_format_date($date, 'custom', 'm');
$tokens['m'] = date_format_date($date, 'custom', 'n');
$tokens['ww'] = date_format_date($date, 'custom', 'W');
$tokens['date'] = date_format_date($date, 'custom', 'N');
$tokens['day'] = date_format_date($date, 'custom', 'l');
$tokens['ddd'] = date_format_date($date, 'custom', 'D');
$tokens['dd'] = date_format_date($date, 'custom', 'd');
$tokens['d'] = date_format_date($date, 'custom', 'j');
if (!empty($item['value2'])) {
$item['value2'] = trim($item['value2']);
$item_type = is_numeric($item['value2']) ? DATE_UNIX : DATE_ISO;
$date = date_make_date($item['value2'], $timezone, $item_type);
$tokens['to-value'] = $item['value2'];
$tokens['to-view'] = $item['view2'];
$tokens['to-timestamp'] = date_format_date($date, 'custom', 'U');
$tokens['to-yyyy'] = date_format_date($date, 'custom', 'Y');
$tokens['to-yy'] = date_format_date($date, 'custom', 'y');
$tokens['to-month'] = date_format_date($date, 'custom', 'F');
$tokens['to-mon'] = date_format_date($date, 'custom', 'M');
$tokens['to-mm'] = date_format_date($date, 'custom', 'm');
$tokens['to-m'] = date_format_date($date, 'custom', 'n');
$tokens['to-ww'] = date_format_date($date, 'custom', 'W');
$tokens['to-date'] = date_format_date($date, 'custom', 'N');
$tokens['to-day'] = date_format_date($date, 'custom', 'l');
$tokens['to-ddd'] = date_format_date($date, 'custom', 'D');
$tokens['to-dd'] = date_format_date($date, 'custom', 'd');
$tokens['to-d'] = date_format_date($date, 'custom', 'j');
}
return $tokens;
}
}