function token_get_date_token_info in Token 6
Same name and namespace in other branches
- 5 token.module \token_get_date_token_info()
Build a list of common date tokens for use in hook_token_list().
Parameters
$description:
4 calls to token_get_date_token_info()
- comment_token_list in ./
token_comment.inc - Implements hook_token_list() on behalf of comment.module.
- node_token_list in ./
token_node.inc - Implements hook_token_list() on behalf of node.module.
- token_token_list in ./
token.module - Implements hook_token_list().
- user_token_list in ./
token_user.inc - Implementation of hook_token_list().
File
- ./
token.module, line 492 - The Token API module.
Code
function token_get_date_token_info($description, $token_prefix = '') {
$time = time();
$tokens[$token_prefix . 'small'] = t("!description date in 'small' format. (%date)", array(
'!description' => $description,
'%date' => format_date($time, 'small'),
));
$tokens[$token_prefix . 'yyyy'] = t("!description year (four digit)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'yy'] = t("!description year (two digit)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'month'] = t("!description month (full word)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'mon'] = t("!description month (abbreviated)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'mm'] = t("!description month (two digits with leading zeros)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'm'] = t("!description month (one or two digits without leading zeros)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'ww'] = t("!description week (two digits with leading zeros)", array(
'!description' => $description,
));
if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
$tokens[$token_prefix . 'date'] = t("!description date (numeric representation of the day of the week)", array(
'!description' => $description,
));
}
$tokens[$token_prefix . 'day'] = t("!description day (full word)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'ddd'] = t("!description day (abbreviation)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'dd'] = t("!description day (two digits with leading zeros)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'd'] = t("!description day (one or two digits without leading zeros)", array(
'!description' => $description,
));
$tokens[$token_prefix . 'raw'] = t("!description in UNIX timestamp format (%date)", array(
'!description' => $description,
'%date' => $time,
));
$tokens[$token_prefix . 'since'] = t("!description in 'time-since' format. (%date)", array(
'!description' => $description,
'%date' => format_interval($time - 360, 2),
));
return $tokens;
}