Date: Filter am/pm data for "a" date pattern#699
Merged
Conversation
Contributor
|
I looked at the diff. Can't say that I understand much, but also didn't spot anything fishy. Maybe that helps? |
jzaefferer
reviewed
Mar 7, 2017
| assertParse( assert, "5 AM", "h a", cldr, date1 ); | ||
| assertParse( assert, "5 PM", "h a", cldr, date2 ); | ||
| assertParse( assert, "上午5", "ah", zh, date1 ); | ||
| assertParse( assert, "下午5", "ah", zh, date2 ); |
Contributor
There was a problem hiding this comment.
Can you explain what this assertion does? What's the purpose of assertParse, what are the arguments doing?
Member
Author
There was a problem hiding this comment.
I wish this was something like expect( parse( "下午5", "ah", zh ) ).to.equalTime( date2 ). Back to our existing code, assertParse is a utility function defined in this same file. It asserts that parsing "下午" string in the "ah" raw-pattern using the zh (Chinese) data equals date2.
CLDR introduced additional dayPeriods (e.g., morning1, afternoon1, evening1, etc) along with am and pm. The new dayPeriods should be handle by "b" and "B" date patterns, while the "a" pattern should still handle am/pm. For Chinese, the corresponding value for either pm or afternoon1 is exactly the same, therefore it causes problem on the reverse lookup when parsing. This change fixes the above parsing issue by filtering am/pm only in the parser properties. It also filters it out on formatting as a simple optimization (to avoid unnecessary properties). Fixes globalizejs#509 Closes globalizejs#508
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLDR introduced additional dayPeriods (e.g., morning1, afternoon1,
evening1, etc) along with am and pm. The new dayPeriods should be handle
by "b" and "B" date patterns, while the "a" pattern should still handle
am/pm.
For Chinese, the corresponding value for either pm or afternoon1 is
exactly the same, therefore it causes problem on the reverse lookup when
parsing.
This change fixes the above parsing issue by filtering am/pm only in the
parser properties. It also filters it out on formatting as a simple
optimization (to avoid unnecessary properties).
Fixes #509
Closes #508