-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly. #6311
Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly. #6311
Conversation
…string properly.
self::INVALID => "Invalid type given. String expected", | ||
self::INVALID_DATETIME => "The input does not appear to be a valid datetime", | ||
self::INVALID => "Invalid type given. String expected", | ||
self::INVALID_DATETIME => "The input does not appear to be a valid datetime" |
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.
Don't remove trailing comma
And by the way, build fails. |
Build fail is odd. I'm running the ICU 51.2 (PHP 5.5.12) library and it adds that period at the end when I format that in Russian. It looks like the original reporter doesn't include the period, so I'll change the test and remove the period. It still passes for my version without the period. |
The format in the ICU libraries actually always change frm time to time. That's why I'd suggest to generated the "expect output" directly with INTL date formatter. All we really expect is that the DateFormat helper outputs the same as what we'd generate manually with the IntlDateFormatter. |
@moderndeveloperllc the old ICU4.8 had a wrong date format (MEDIUM) for Russian. Now I use the ICU 51 with a right date format. You should suggest to your customers use the newest version of ICU |
@moderndeveloperllc Generated the rexpected output for the test at runtime. This makes sure that our tests don't break when the ICU library changes something. |
… overcome issues with different ICU library versions.
@DASPRiD I'm now programmatically generating the "true" tests for several locales. They should cover most of the major script types - Latin, Han, Japanese, Arabic, Cyrillic, and a couple of South Asian scripts that have given me issues in the past (Sinhala, Malayalam, and Devanagari). |
@moderndeveloperllc Looks much better, now that it doesn't depend on specific ICU data anymore. Should be good to merge. |
…etime-validator Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly.
- Import all classes used - concatenation should add indentation when overflowing to new lines - single quotes instead of double quotes
…perllc/hotfix/6297-i18n-datetime-validator Fixes zendframework/zendframework#6297: Fixes logic that checks if IntlDateFormatter parsed the string properly.
- Import all classes used - concatenation should add indentation when overflowing to new lines - single quotes instead of double quotes
Using the
$position
as an indicator does not work properly asIntlDateFormatter::parse()
does not return the same number asgrapheme_strlen()
for all locales (try ml-IN for an example). We don't need to know where it failed, just that it did fail. Theparse()
function returnsfalse
if it fails, so we can just check for that.Added test for Russian, Traditional Chinese, and Malayalam.
Closes #6321