I tried to create a localized list of registered users and was surprized as all birthdays were displayed without localization.

Short investigation revealed the problem in file profile/views_handler_field_profile_date.inc.
Function render($value) utilizes it's own date formatting engine and don't support any localization.

That's pretty strange why Drupal API function format_date(...) wasn't used.

I tried to comment out everything below line 45:

    $date = gmmktime(0, 0, 0, $value['month'], $value['day'], 1970);

until

    return strtr($format, $replace);

then change the return to:

    return format_date($date, 'custom', $format);

This solution works perfectly for me, so I think the function must be rewritten to utilize format_date(...) for localization support.

CommentFileSizeAuthor
#4 960392-time.patch874 bytesiamjon

Comments

dawehner’s picture

Good idea

    $date = gmmktime(0, 0, 0, $value['month'], $value['day'], 1970);

has to be changed to

    $date = gmmktime(0, 0, 0, $value['month'], $value['day'], $value['year']);

then it should work better.

Can you make a patch?

merlinofchaos’s picture

    // Note: Avoid PHP's date() because it does not handle dates before
    // 1970 on Windows. This would make the date field useless for e.g.
    // birthdays.

There's a comment right in the code that says why we don't use format_date(). Did you not read that comment? :(

That said, changing the various date() calls to format_date() might handle the localization.

iamjon’s picture

Version: 6.x-2.11 » 6.x-3.x-dev
Assigned: Unassigned » iamjon

Assigning this to myself to try write up a patch

iamjon’s picture

Category: feature » bug
Status: Active » Needs review
StatusFileSize
new874 bytes

patch attached.
merlinofchaos, i couldn't find any date() calls am I missing something?

tomgf’s picture

Subscribe

dawehner’s picture

Status: Needs review » Fixed

This got already committed to 7.x-3.x and 6.x-3.x

Thanks iamjon for the work on that.

Status: Fixed » Closed (fixed)

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