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

Fix meridiem time for zh_cn locale #486

Merged
merged 4 commits into from
May 19, 2017
Merged

Conversation

fnlctrl
Copy link
Contributor

@fnlctrl fnlctrl commented May 11, 2017

Under no circumstances should am/pm be shown on zh_cn(Chinese) interfaces, so meridiemUppercase and meridiemLowercase should be translated into ['上午', '下午'] too. There's no difference of upper/lower case in Chinese.

Previous behavior:
hh:mm a => 12:30 am
hh:mm A => 12:30 AM
hh:mm aa => 12:30 上午

Corrected behavoir:
hh:mm a => 12:30 上午
hh:mm A => 12:30 上午
hh:mm aa => 12:30 上午

Under no circumstances should `am/pm` be shown on `zh_cn`(Chinese) interfaces, so `meridiemUppercase` and `meridiemLowercase` should be translated into `['上午', '下午']` too.  There's no difference of upper/lower case in Chinese.

Previous behavior:
`hh:mm a` => `12:30 am`
`hh:mm A` => `12:30 AM`
`hh:mm aa` => `12:30 上午`

Corrected behavoir: 
`hh:mm a` => `12:30 上午`
`hh:mm A` => `12:30 上午`
`hh:mm aa` => `12:30 上午`
Copy link
Member

@leshakoss leshakoss left a comment

Choose a reason for hiding this comment

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

var meridiemUppercase = ['AM', 'PM']
var meridiemLowercase = ['am', 'pm']
var meridiemUppercase = ['上午', '下午']
var meridiemLowercase = ['上午', '下午']
var meridiemFull = ['上午', '下午']
Copy link
Member

Choose a reason for hiding this comment

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

I think it should be single variable, like var meridiem = ['上午', '下午']. And later:

    // AM, PM
    'A': function (date) {
      return (date.getUTCHours() / 12) >= 1 ? meridiemUppercase[1] : meridiemUppercase[0]
    }
  }

  formatters.a = formatters.A
  formatters.aa = formatters.A

@@ -38,12 +36,12 @@ function buildFormatLocale () {

// AM, PM
'A': function (date) {
Copy link

@KingMario KingMario May 14, 2017

Choose a reason for hiding this comment

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

@fnlctrl

Just omit these tow functions and add formatters.A = formatters.a = formatters.aa after the declaration of formatters.

And there are 8 relative failures in the test. You should also modify the test spec so that all tests pass.

@fnlctrl
Copy link
Contributor Author

fnlctrl commented May 19, 2017

Sorry for the delay and it's all fixed now 😄

Copy link
Member

@leshakoss leshakoss left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@leshakoss leshakoss merged commit 9e8e225 into date-fns:master May 19, 2017
@leshakoss
Copy link
Member

leshakoss commented May 19, 2017

@fnlctrl thank you for your contribution! ⭐️ Your fix were released as v1.28.5 (diff: v1.28.4...v1.28.5)

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.

None yet

3 participants