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

[Improvement]: Replace usages of strftime and Carbon::formatLocalized() #14524

Open
kingjia90 opened this issue Mar 3, 2023 · 1 comment
Open
Assignees
Milestone

Comments

@kingjia90
Copy link
Contributor

Improvement description

image

src: https://www.php.net/manual/en/function.strftime.php

image

Needs to deprecate and replace the format parameters, they are not interchangeable with the replacement, for example %a cannot be just a

see also #14431 (comment)

@kingjia90
Copy link
Contributor Author

kingjia90 commented Apr 26, 2024

Needs to deprecate and replace the format parameters, they are not interchangeable with the replacement, for example %a cannot be just a

Mostly done but for data hub file export and ecommerce framework the challenge is how to tackle this without BC breaks
https://github.com/pimcore/ecommerce-framework-bundle/blob/d75b6a6e52be1d3635ef2fc435082794becc88a4/src/OrderManager/V7/OrderManager.php#L603

We could map the former formats and translate to the desired format, strftime ones are always prefixed by % and are one character BUT carbon ISO have no prefix and have a variable length making it hard to distinguish text from parameter, so we may introduce some "meta-symbols" to tag them, eg.today is *dd*.xls) and skip this "translator" when *anything* are found or do it once via a migration(?).

see
https://carbon.nesbot.com/docs/#api-localization:~:text=to%20Sa)%2C%20translatable-,ddd,-Thu
image

Alternatively, creating a new config for existing config fields and deprecate the current one, and use the new one when is set.

Another input would be introducing something more custom (instead of *dd* to *MIN_DAY_NAME_T* or *MDNT*) and properly documented, that we can limit and have more control on, because we actually don't/shouldn't support every date format parameter, eg. strftime('today is %D.xls', time()); results in a date with forward slashes (which is forbidden for filenames) as m/d/Y.

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

5 participants