The Date, String, and Number types:

http://drupal.org/node/298633

should have better token replacement support.

  • Arguments with Date type should have the following replacement options: (my argument is called "date_sent")
    [date_sent:date]	       The unmodified date value
    [date_sent:date-yyyy]   The year (four digit)
    [date_sent:date-yy]     The year (two digit)
    [date_sent:date-month]  The month (full word)
    [date_sent:date-mon]    The month (abbreviated)
    [date_sent:date-mm]     The month (two digit, zero padded)
    [date_sent:date-m]      The month (one or two digit)
    [date_sent:date-ww]     The week (two digit)
    [date_sent:date-date]   The date (day of month)
    [date_sent:date-day]    The day (full word)
    [date_sent:date-ddd]    The day of week (abbreviation)
    [date_sent:date-dd]     The day (two digit, zero-padded)
    [date_sent:date-d]      The day (one or two digit)
    

  • Arguments with Number type should have the following replacement options: (my argument is called "amount")
    [amount:number]         The numeric value
    

  • Arguments with String type should have the following replacement options: (my argument is called "name")
    [name:string]           The string value
    

I'm asking here first, but I suspect this a problem with the token module, not rules.

Comments

mitchell’s picture

Version: 6.x-1.2 » 7.x-2.0-alpha1
Component: Rules Core » Rules Engine
Category: feature » support
Status: Active » Postponed (maintainer needs more info)

In 7.x, there is a whole new token structure. Please check how this issue may apply to 7.x and report back. New changes are going into that branch anyway.

Changing to support request for now until verifying changes are necessary.

klausi’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Category: support » bug
Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closed since no further information has been provided. Reopen if still an issue.

bomarmonk’s picture

Component: Rules Engine » Rules Core
Status: Closed (cannot reproduce) » Active

I'm reopening this, since I can't get my single date field (for a year) to show up formatted as a year (rules renders the date-entity and date_field token as an entire date string with a month, day and time, even though the field only collects the year).

Any way to have rules use the date field's proper format and content?

David Stosik’s picture

Category: bug » feature
Priority: Critical » Normal

Hi bomarmonk,

Can you please have a look to this patch? #1898828: Add actions to format dates and durations
By adding an action "convert data", if you try to convert a date to a string, then you will get formatting options, and then will be able to use the provided variable in following actions.

David

TR’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

All the date tokens are available if you use the contributed Token module, which enhances core Drupal's support for token:

Custom format	[site:current-date:custom:?]	A date in a custom format. See the PHP documentation for details.
Long format	[site:current-date:long]	A date in 'long' format. (Thursday, January 3, 2019 - 23:43)
Medium format	[site:current-date:medium]	A date in 'medium' format. (Thu, 01/03/2019 - 23:43)
Raw timestamp	[site:current-date:raw]	A date in UNIX timestamp format (1546587809)
Short format	[site:current-date:short]	A date in 'short' format. (01/03/2019 - 23:43)
Time-since	[site:current-date:since]	A date in 'time-since' format. (49 years 2 weeks)

Note there will be a separate token for each date format that you have configured at /admin/config/regional/date-time. Short/medium/long are built-in to Drupal. You have the choice of either defining a new format and using the token for that format, or using the "Custom" token and explicitly.

So I don't see a need to add additional tokens just for use within Rules - all the Token module tokens are available for any date you have in Rules.