Date format using special character like "j•m•y ▶ G:i" get render "two times" and look like that: "26•05•12 ▶ 2:00 •• ▶"

Note than format_date using the format doesn't have this issue.

Original report by [gagarine]

With a date field that does *not* collect end date.
I try to render the field using a custom format like "d-m h:m ". I select the format in the node type field display settings (but the same occur in view...)
The result is going to be "29-10 12:34- :". The "- :" at the end make me think Date module try to render an empty date.

Comments

gagarine’s picture

Title: Render a an end date even it's a date than do not collecting end date » Date prints an empty "end date" on date field that does not collect end date

rewrite the title... was late..

gagarine’s picture

Title: Date prints an empty "end date" on date field that does not collect end date » Date format with special caracteres are printed two times

In the description I said it was "d-m h:m" thinking it will be simpler to get the issue. But in fact my format is "j•m•y ▶ G:i" and like scotself pointed me on IRC *this* is the problem.

gagarine’s picture

Issue summary: View changes

the issues was about special characters

gagarine’s picture

The problem is in the date_limit_format() when called by date_format_date() function.

We have regex like that

$regex[] = '([\-/\.,:]?\s?(?<!\\\\)[Yy])';

Than only remove \-/\.,: characters...

gagarine’s picture

What we can perhaps do is
- first find first all charter than are not part of date format http://www.php.net/manual/en/function.date.php (careful with escaped one...).
- use those caracter in the regex

$regex[] = '([' . $special_char . ']?\s?(?<!\\\\)[Yy])';

Or give an option to avoid date_limit_format for custom format. Because you can create format than match your date granularity.

gagarine’s picture

gagarine’s picture

Issue summary: View changes

format_date is ok