-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Convert string to DateTime object for languages other than English #18083
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
Convert string to DateTime object for languages other than English #18083
Conversation
Hi @bnymn. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @bnymn. Thank you for your request. I'm working on Magento instance for you |
Hi @bnymn, here is your new Magento instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the problems and failed tests.
@@ -85,23 +85,31 @@ public function __construct( | |||
} | |||
|
|||
/** | |||
* {@inheritdoc} | |||
* Return path to default timezone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't duplicate descriptions in the implementation. They are in the interface. Please return them to {@inheritdoc}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation @slavvka . So should I just ignore these warnings then?
https://travis-ci.org/magento/magento2/jobs/429304963
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically you could ignore those since {@inheritdoc} may be used in such cases and there's a bug in our sniffer. But it would be good if you make changes according to this guide https://devdocs.magento.com/guides/v2.3/coding-standards/docblock-standard-general.html#inheritdoc. As you could see there should be enough to remove curly braces {}
* @return string | ||
* @deprecated | ||
*/ | ||
public function convertConfigTimeToUtcWithPattern($date, $format = 'Y-m-d H:i:s', $pattern = 'Y-m-d H:i:s'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a public method into interface marked as API is backward incompatible and therefore is forbidden (please look BIC guide https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/). Please reimplement it. You can use the possible approach how to do that in the mentioned guide.
@magento-engcom-team give me test instance |
* @return string | ||
*/ | ||
public function convertLocalizedDateToUtc($date); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a new line in the end
...internal/Magento/Framework/Stdlib/DateTime/Timezone/LocalizedDateToUtcConverterInterface.php
Outdated
Show resolved
Hide resolved
Hi @slavvka, thank you for the review. |
Hi @bnymn. Thank you for your contribution. |
Converting from string into PHP DateTime object is failing for locales other than en_US. This PR aims to solve this problem.
Description
DateTime class can parse a given string if it is in English, but it fails for other languages. To solve this issue, we have used IntlDateFormatter class for parsing string dates.
For cases when locale cannot be resolved, we explicitly have defined the pattern. Please refer to this line for the edge case.
https://github.com/magento/magento2/pull/18083/files#diff-9f6dc57683917f529571d34de6f14d15R335
Fixed Issues (if relevant)
Manual testing scenarios
4.1. Go to Marketing -> Newsletter Template.
4.2. Add a new template if there is not any.
Contribution checklist