In D7, we have the token API in core, and core also provides a 'date' token type. All you need to do is to provide a raw-timestamp and and core allows users to use a 'custom' token like [node:field-date:custom:Y]. The current token implementation looks like its the D6 version so may cause problems. I'll look into getting this up to shape for Date's D7 version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

That would be great! I haven't had time to look at what has changed in Token.

scotwith1t’s picture

+1 for token support. seems token has started to stabilize quite a bit. thanks dave and karen, you guys are amazing drupal rockstars. i promise one day soon i am going to learn to code and start helping you guys out some!

rosborn’s picture

I don't want to seem like I'm pressurizing because I know how hard everyone is working, but is this likely to make it into the module by the time Drupal 7 is released? Thanks for getting the Date Module working so well. I couldn't develop my site in Drupal 7 without it.

KarenS’s picture

It will not make it in unless someone makes a patch. If this is important to you, make a patch. If you don't know how to do it, find someone who does.

andypost’s picture

What kind of integration should be minimal enough to be implemented? I can make it but see no idea hot tokens should operate

LSU_JBob’s picture

subscribed. I really need this so I will try and look into the code and get a patch going.

dboulet’s picture

Has anybody here done enough work on this to post a patch?

dboulet’s picture

Wondering: would this feature depend on the field tokens provided by Token module? See: #691078: Field tokens.

kbond’s picture

Subscribe

bfroehle’s picture

~

bfroehle’s picture

Status: Active » Needs review
FileSize
10.61 KB

As a start, we'll need to put the token code in date.tokens.inc to conform with the autoload functionality of system_hook_info().

As @Dave Reid said, we'll want to take advantage of the existing 'date' token type in core (in system.tokens.inc). This means that we should completely remove date_token.inc and create a new date.tokens.inc.

I've attached a patch which provides date tokens for all date fields. The patch requires the most recent field tokens patch in #691078-92: Field tokens. Additionally, it will require a fix to #1067886: DateObject cannot handle UTC timezone with Unix datestamp before it will work for datestamp fields.

Example replacement token codes are

[node:field-xxx:date:medium]
[node:field-yyy:to-date:raw]
[node:field-zzz:values:0:date:short]
[node:field-www:values:0:to-date:since]
[node:field-uuu:values:1:date:custom:Y-M-d]
rhlowe’s picture

Subscribing

KarenS’s picture

Status: Needs review » Fixed

Committed this much. You can provide another patch if you have more to add.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mrfree’s picture

Status: Closed (fixed) » Needs work

the committed patch doesn't work here... reading the code I noticed that the suggested [node:field-xxx:date:medium] syntax causes the variable $type = 'node' so the if condition
if (($type == 'date-field-value') && !empty($data['item'])) is always false and however the array $data doesn't contain any 'item' key but only a 'node' key.

Can you please explain the code meaning? :)

bfroehle’s picture

The patch requires the most recent field tokens patch in #691078-92: Field tokens.

Are you sure you have that installed?

mrfree’s picture

Yup, I've already applied the patch and a lot of new field related tokens are available now but using [node:field-xxx:date:medium] results in $type=node in your function so all your code is simply skipped... or I simply haven't understand how it works yet :)

hefox’s picture

The token support was temporarily removed in #1103032: Document how to use date tokens.

Note that I only figured this out after 3? 4? hours of trying to get token support to work after seeing this issue that seemed to indicate that it was partially working. Then I looked at the first patch, realized it didn't match the code, and went to repository viewer and saw about that issue.

mrfree’s picture

s**t!
many thanks hefox, reverting the patch http://drupal.org/files/issues/date-1103032-29.patch do the trick now the bfroehle's patch works

bfroehle’s picture

Status: Needs work » Closed (fixed)

Okay, so this is fixed then.