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

Example page #51

Closed anvk closed 7 years ago

anvk commented 7 years ago

First of all thanks a lot for this great component.

It would be so amazing if you would expand on your example page showing different possible options and features of your component with some code examples. Per say I'm struggling right now to make Kronos to show only time and then to show a dropdown with 24hr format time instead of am/pm one and not sure how to do that.

felixakiragreen commented 7 years ago

You're right. I should do that.

But for your case just do...

<Kronos time={this.state.time} format={'H:mm'} />
anvk commented 7 years ago

Amazing thanks a lot !

anvk commented 7 years ago

Sorry about that, but I just got my hands on the example and tried both:

<Kronos time={new Date()} format={'HH:mm'} /> and <Kronos time={new Date()} format={'H:mm'} />

Both of those options will generate am/pm dropdown menu

Nantris commented 7 years ago

Both formats @anvk gets am/pm in the dropdown for give me 24 hour. I also tried hh:mm, hh:mm a, setting my moment locale to 'en' before creating moment objects, and more.

@dubert Is there any solution to this? I'm using 1.5.3.

Thanks very much for any advice you can give me.

felixakiragreen commented 7 years ago

@anvk @Slapbox

To format the input box use: format={'H:mm'} To format the dropdown use: options={ { format: { hour: 'H:mm' } } }

Please let me know if those don't work. I just tested them myself and they appear to behave correctly.

Nantris commented 7 years ago

For me this is what worked (passed into options on the Kronos component):

let kronosOptions = {
        format: {
          minute: 'hh:mm a'
        },
        moment: moment.localeData('en-us')
      };

Should I have had to pass this into minutes? Passing it into hours had some effect, but it was buggy/not the desired behavior.

Nantris commented 7 years ago

Hey @dubert, I didn't see your last response.

options={ { format: { hour: 'hh:mm a' } } } does not work on the dropdown list options={ { format: { minute: 'hh:mm a' } } } does work on the dropdown list

felixakiragreen commented 7 years ago

Just released 1.6.0!

This issue should be fixed. Using options={ { format: { hour: 'hh:mm a' } } is working correctly for me.