Date Token does not correctly reflect user input into cck date field

bomarmonk - September 26, 2008 - 04:35
Project:Date
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Moonshine
Status:patch (code needs review)
Description

I wasn't sure if this was an issue with Token or Date, so I am posting a link to the date issue here. Basically, my automatic node title uses the date entered into a CCK date field. The title's date ends up being off by a year (in my case). The date field saves the correct information, but it gets altered when translated with Token. I've tried both the development version of date and the recommended release.

See http://drupal.org/node/311303

#1

greggles - October 3, 2008 - 02:48
Project:Token» Date
Version:6.x-1.x-dev» 6.x-2.x-dev

This code is in date module now.

#2

bomarmonk - October 3, 2008 - 08:07

I am still having the same issue with the latest version of the date module...

#3

Moonshine - October 20, 2008 - 17:16
Assigned to:Anonymous» Moonshine
Status:active» patch (code needs review)

I'm posting a patch here for review. I was having trouble with Date tokens as well, and it came down to two issues. (both of which are in this patch)

1) The initial date tokens (From date) were actually getting set from "value2" (To date) rather then "value" (From date). Easy fix there :)

2) Timezone changes were getting applied when they shouldn't be IMO. For example, I have a Date field that only allows dates, like /mm/dd/yyyy. No times. Therefore timezone settings are not applicable and can't be set for the field. The system default timezone setting for the server is US Mountain Time. When token was running it would take the date and run a conversion from a default UTC timezone to US Mountain, time which brings it back to the previous day.

I think the correct behavior would be to ignore timezones if information isn't present?

There are a couple bug reports related to this issue that I'll try to mark as dups here..

Thanks!

AttachmentSize
date-token-fix.patch886 bytes

#4

jordanlewin - October 26, 2008 - 05:39

I've just applied this patch to Date module version 6.x-2.0-rc4 and it doesn't seem to have worked, it is still providing a token in my case that is a day behind what the actual date is supposed to be (as in http://drupal.org/node/311303). Is this because the patch is meant for a different version? This issue is set for 6.x-2.x-dev, but the latest release is rc4 at this point. What version is the patch meant for, and does it matter?

#5

Moonshine - October 26, 2008 - 07:20

Well it was patched against the latest dev version available when I posted, which is newer then RC4, although I don't think there were changes to the token file. (The dev releases are the releases in red on the project page http://drupal.org/project/date)

But really from the description of your problem on the other thread, I would think that this patch should work for you. :/

Did it apply cleanly? There are only two lines it changes in date/date_token.inc, so you may want to just verify them by hand.

#6

TUc - October 30, 2008 - 13:35

Patch worked for me. The easy fix from "value2" to "value" indeed did the trick.

#7

bomarmonk - November 9, 2008 - 05:16

I just patched the RC4 version of Date's date_token.inc file and things work. When I patched, it simply said "stripping trailing CRs," but the date gets translated properly into my automatic node title. Thanks for the patch. I hope this will be committed soon!

#8

jesss - November 10, 2008 - 19:47

I'm having what appears to be the same problem in Date 5.x-2.3. My automatic node titles (set to Month YYYY) are one month behind. If the patch works, can it be back-ported?

(If this should be a separate issue, let me know and I'll create it.)

#9

hamoo - November 12, 2008 - 13:26

This patch worked for me as well. I use date tokens in automatically generated URL aliases but instead of the field data the current date was used (at the time when the alias was generated). The issue was resolved by applying this patch. Thanks a lot!

#10

ramper - November 19, 2008 - 05:53

I too was having a problem with the date argument supplied to the page URL by Views - it was offsetting the date by one day for some reason. Anyway, without understanding everything that's said here, I applied the patch to the latest dev version as of today, and now the auto-generated URLs look fine now. Thanks for the patch. :)

 
 

Drupal is a registered trademark of Dries Buytaert.