There's a discussion going on in the Rules module's issue queue concerning timezones and converting to UTC (http://drupal.org/node/589266#comment-2950238). A lot of problems would be solved if tokens for date/time fields included a time set in UTC, compensated for any timezones used by website/user/field -- and it is likely that other modules could have use for this as well.

Thus I hereby submit a feature request for a UTC normalized token for date/time fields!
(I wish I could code it myself, but I really can't. Sorry.)

Credit to all you gals and guys working with Date. It is an essential part of Drupal.

CommentFileSizeAuthor
#2 date-utc-token-1.patch1.38 KBitangalo

Comments

mnlund’s picture

I second this. I ran into the exact problems described in the referenced post.

itangalo’s picture

Status: Active » Needs work
StatusFileSize
new1.38 KB

Attached is a start for a patch – I had some trouble understanding all the calls made within date_token_values().
The patch currently only supports UTC/GMT by subtracting the site's default time zone – ideally it should of course adjust to whatever time zone settings are applied to the date field in question.

(It didn't seem as the field's value for timezone or timezone_db changed when I changed the settings for the field. If anyone would like to explain what's actually being stored I'd be grateful.)

My hope for this patch is (a) that it may be of use for anyone interested in using Rules Scheduler and only adjusting for default time zone; and (b) that it may be a starting point for a full patch.
I don't consider it a patch that should be included in Date.

Cheers!

letapjar’s picture

I applied this patch but the rules scheduler still seems to be using the incorrect time. Is there an easy way to check the output of this token?

itangalo’s picture

You could try configuring a rule to 'display a customizable message on the site', and just inserting the UTF token there. If it is not working properly -- could you provide details of your date configuration on the site? (Are you, for instance, date settings per user? Or how is the date field in question configured?)

Cheers!

letapjar’s picture

thanks for the feedback - I found the error - somehow the "on content has been updated" rule was firing when new nodes were created thus wiping out some time information that i was trying to use with rules.

Turns out I did not need to use the utc date format - I just set my cck date field input format to
something like 12/07/2010 7:00PM -05:00 (i.e. a formant adjusted for the site's time zone relative to UTC) - then rules scheduler does the right thing at the right time.

I would add one thing to the patch thought - you have the date-utc field - but users will also expect the date-to-utc field which will do the same conversion for the "to" part of a cck date field.

lyricnz’s picture

I think this problem would be more generally solved by exposing all currently defined date-format-types and custom-date-formats as tokens, as provided in this issue: #593840: Include tokens for custom date formats for date fields. Then you can just add whatever date format you want to your site, and it will be provided as a token.

colan’s picture

Status: Needs work » Closed (duplicate)