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

Date: Filter am/pm data for "a" date pattern #699

Merged
merged 1 commit into from
Mar 10, 2017

Conversation

rxaviers
Copy link
Member

@rxaviers rxaviers commented Mar 2, 2017

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

@jzaefferer
Copy link
Contributor

I looked at the diff. Can't say that I understand much, but also didn't spot anything fishy. Maybe that helps?

@@ -269,6 +274,8 @@ QUnit.test( "should parse period (a)", function( assert ) {
date2 = startOf( date2, "hour" );
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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this assertion does? What's the purpose of assertParse, what are the arguments doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@rxaviers rxaviers merged commit b42fb2c into globalizejs:master Mar 10, 2017
@rxaviers rxaviers deleted the fix-509 branch March 10, 2017 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parseDate returns AM datetime in zh and zh-Hant despite Chinese PM characters
2 participants