Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date_limit_format() doesn't take literals into account, leading to strange format strings #3598

Open
indigoxela opened this issue Mar 20, 2019 · 0 comments

Comments

@indigoxela
Copy link
Member

Description of the bug

function date_limit_format (file core/includes/date.inc) is used to return format strings for given granularities. As it doesn't take literals into account, this can lead to strange formats.
Sorry for the short report, I can provide more information, if requested.

This behavior can get reproduced via UI (custom date formats), but for readability I provide some code examples with their result as comment:

  $foo = date_limit_format('e Ymd H:iO', array('timezone'));// "eO"
  $foo = date_limit_format('d m Y H:i:s xxx', array('year', 'month', 'day'));// "d m Y xxx"
  $foo = date_limit_format('Ymd - H:i:00 \O', array('year'));// "Y :00 \O"

OK, the first example doesn't use literal characters, but the problem is related.
A timezone formatted with "eO" (tz name plus offset) isn't really usable.

Example 2 and 3 use literal characters and these appear in every format. That's probably not the expected output. At least I wouldn't expect it.
Literal characters should of course be part of a full formatted date, but shouldn't get added to every date part.

I'm not sure how to resolve this. For now I'd not recommend to use literal characters or more than one timezone char in custom date formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant