For some reason the week number ("W" in the php date format) gets printed twice sometimes when it's rendered.
The date string displays well in the date format list, but the week gets repeated in both CCK node display and Views lists.

Strings I've tried so far are:
* "W"
* "W."
* " W"
* "W "

Surprisingly, the string "l v\e\ck\a W" renders well, but the following gets the week rendered twice:
* "v\e\ck\a W"
* "v\e\ck\a W (Y)" <-- rendering to "vecka 12 (2010) vecka 12"!

I have no idea what's going on here, but I thought I should report a bug.

My system:
Pressflow/Drupal 6.16
Date 6.x-2.4
CCK 6.x-2.6
Views 6.x-2.8

Tried on Garland and a customized version of Zen 6.x-1.1.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Itangalo’s picture

Some more information about the system:

* Apache
* PHP: 5.2.4-2ubuntu5.10
* MySQL database: 5.0.51a

Dennis Söderström’s picture

Same here.

Drupal: 6.1.7
Views: 6.x-2.11

petermilad’s picture

+1
Same here too

Tino’s picture

Same here! Very strange. A little frustrating... :-(

AdamEvertsson’s picture

Dito. Quite irritating....

Drupal 6.19
Views 6.x-2.11

ollu’s picture

I would like to use the week format for a client and have scanned the internet for a solution with no luck. So if someone has come up with a solution I'm eager to find out.

spacer’s picture

Same problem. I've also found that the PHP date 'z' option for the day of year (0-365) is also repeated twice and can't be used in views lists - which is a shame as it would be useful for displaying/sorting events that occur days apart over the course of a year.

JockeL’s picture

Same problem. Anyone found a solution or workaround for this?

Itangalo’s picture

@JockeL: Haven't found any solution, and I've been talking to at least one colleague who also haven't found any solution (or understood where this bug comes from). :-(

fonant’s picture

+1 Most odd! I get this too. Very annoying...

OK, found the problem.

In the date_limit_format() function the system tries to remove everything that isn't a timezone specifier, for formatting the timezone string. But the "W" for week number and some other day-related date() codes aren't removed. So the week number is formatted as the timezone string, and so is printed out twice: once as the formatted date, and once as the timezone string.

I've fixed the problem by changing the regexp for case 'day': in date_limit_format(), around line 1658 from this:

$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[l|D|d|dS|j|jS]{1,2})';

to this, which includes the other day-related date() codes including the one for "week number":

$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[l|D|d|dS|j|jS|N|w|W|z]{1,2})';

This removes those characters from the timezone format string as well.

fonant’s picture

Status: Active » Needs review
FileSize
513 bytes

Here's a patch for it.

Itangalo’s picture

@Fonant: Impressive bug hunting! Patch is much appreciated -- looking forward to testing it.

sokru’s picture

testaed patch #11 and worked fine. Thanks!

tanc’s picture

Patch at #11 works nicely. Thanks!

Itangalo’s picture

Status: Needs review » Reviewed & tested by the community
arlinsandbulte’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Status: Reviewed & tested by the community » Fixed

The code was the same in 7.x-2.x-dev, so I applied the same change there too.

D6 Commit:
http://drupalcode.org/project/date.git/commit/b1cef68

D7 Commit:
http://drupalcode.org/project/date.git/commit/3c8b372

Thanks

Status: Fixed » Closed (fixed)

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