Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly. #6311

Merged
merged 4 commits into from
Aug 7, 2014
Merged

Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly. #6311

merged 4 commits into from
Aug 7, 2014

Conversation

moderndeveloperllc
Copy link
Contributor

Using the $position as an indicator does not work properly as IntlDateFormatter::parse() does not return the same number as grapheme_strlen() for all locales (try ml-IN for an example). We don't need to know where it failed, just that it did fail. The parse() function returns false if it fails, so we can just check for that.

Added test for Russian, Traditional Chinese, and Malayalam.

Closes #6321

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"
Copy link
Member

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

@DASPRiD
Copy link
Member

DASPRiD commented May 21, 2014

And by the way, build fails.

@moderndeveloperllc
Copy link
Contributor Author

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.

@DASPRiD
Copy link
Member

DASPRiD commented May 21, 2014

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.

@esase
Copy link

esase commented May 22, 2014

@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

@DASPRiD
Copy link
Member

DASPRiD commented May 22, 2014

@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.
@moderndeveloperllc
Copy link
Contributor Author

@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).

@DASPRiD
Copy link
Member

DASPRiD commented May 23, 2014

@moderndeveloperllc Looks much better, now that it doesn't depend on specific ICU data anymore. Should be good to merge.

@Ocramius Ocramius added this to the 2.3.2 milestone May 23, 2014
@weierophinney weierophinney merged commit 96c96a1 into zendframework:master Aug 7, 2014
weierophinney added a commit that referenced this pull request Aug 7, 2014
…etime-validator

Fixes #6297: Fixes logic that checks if IntlDateFormatter parsed the string properly.
weierophinney added a commit that referenced this pull request Aug 7, 2014
- Import all classes used
- concatenation should add indentation when overflowing to new lines
- single quotes instead of double quotes
weierophinney added a commit that referenced this pull request Aug 7, 2014
weierophinney added a commit that referenced this pull request Aug 7, 2014
@moderndeveloperllc moderndeveloperllc deleted the hotfix/6297-i18n-datetime-validator branch August 7, 2014 17:14
weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
…perllc/hotfix/6297-i18n-datetime-validator

Fixes zendframework/zendframework#6297: Fixes logic that checks if IntlDateFormatter parsed the string properly.
weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
- Import all classes used
- concatenation should add indentation when overflowing to new lines
- single quotes instead of double quotes
weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I18n/Validator/DateTime should use mb_strlen() instead of strlen()
5 participants