felixakiragreen / react-kronos

A fast, intuitive, and elegant date and time picker for React.
https://felixakiragreen.github.io/react-kronos/
MIT License
90 stars 28 forks source link

Moment lang option not applied to hour dropdown #36

Closed yury-dymov closed 7 years ago

yury-dymov commented 8 years ago

Hi, first of all thank you for nice library!

Here is the issue description:

My code: <Kronos time='15:00' format='HH:mm' options={{ moment: { lang: 'ru' } }}/>

In Russian we have 24 hour format by default. Initial value rendered fine and after selecting 7:30 PM from dropdown I can see 19:30, which is also fine.

The issue is that I am expecting to see 19:30 in the dropdown instead of 7:30 PM. I reviewed the source code and it seems that moment language option is never used for dropdown population.

Kind regards, Yuri.

felixakiragreen commented 8 years ago

Thanks for reporting this. I investigated this issue, and the problem seems to be that here https://github.com/dubert/react-kronos/blob/master/src/calendar.js#L184-192 the format for the cells is forced. I should be able to update this. Look for an update in a few days!

felixakiragreen commented 8 years ago

Added the format prop to options in 1.3.0, so you can do:

<Kronos
  options={{
    format: {
      hour: 'H:mm'
    }
  }}
/>

It will be 24h

yury-dymov commented 8 years ago

First of all, thank you for quick update!

However, I assume that there can be a better solution. My project supports localization and I want that English users had 12-hour format and Russian users - 24-hour format. That means that format should be the same ('HH:mm' or 'H:mm' depends on personal preference) but rendering occurs with respect to selected locale.

felixakiragreen commented 7 years ago

Change the moment locale between 'en' and 'ru' and that should change the format.

felixakiragreen commented 7 years ago

Just released 1.6.0!

This issue should be fixed.