Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
gagarine CreditAttribution: gagarine commentedrewrite the title... was late..
Comment #2
gagarine CreditAttribution: gagarine commentedIn 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.
Comment #2.0
gagarine CreditAttribution: gagarine commentedthe issues was about special characters
Comment #3
gagarine CreditAttribution: gagarine commentedThe problem is in the date_limit_format() when called by date_format_date() function.
We have regex like that
Than only remove \-/\.,: characters...
Comment #4
gagarine CreditAttribution: gagarine commentedWhat 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
Or give an option to avoid date_limit_format for custom format. Because you can create format than match your date granularity.
Comment #5
gagarine CreditAttribution: gagarine commentedSimilar issue #1538420: Custom characters intended as separators within custom formatted date/time are not displayed in the correct location.
Comment #5.0
gagarine CreditAttribution: gagarine commentedformat_date is ok