I created a custom token of type 'date-field-value', which does show up nicely in the token browser with all options ('long', 'short', 'raw', etc.) - yet when I generated a token replacement for the end date (for example, ..:to-date:long) there is never a replacement coming through:

$replacements += date_tokens('date-field-value', $date_tokens, $date_data, $options);

All options are setup correctly with valid data for that end date. Same code works fine for a ..:date:long replacement.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

silberling’s picture

There seems to be a mismatch in date.tokens.inc, where on line 25 it defines the token for the end date as "to-date":

  $info['tokens']['date-field-value']['to-date'] = array(

whereas in function date_tokens, it expects the token to be "end-date" on line 58

    if (($date_tokens = token_find_with_prefix($tokens, 'end-date')) && !empty($item['value2'])) {

Once I replaced the "end-date" with "to-date" I get the expected result. Patch attached.

Alan D.’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, Token for end date not replaced-1517216-1.patch, failed testing.