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

[Feature] 12 Hour AM/PM Support? #44

Open
eastcoastcoder opened this issue Jul 9, 2019 · 2 comments
Open

[Feature] 12 Hour AM/PM Support? #44

eastcoastcoder opened this issue Jul 9, 2019 · 2 comments

Comments

@eastcoastcoder
Copy link

This library is awesome except for one flaw. There doesn't seem to be a way to set 12 hour time. rmc-date-picker supports this but has a lack of themes and the time doesn't seem to roll over continuously like this library. I was wondering if there is already support for this I'm just overlooking?

@lanjingling0510
Copy link
Owner

@ethanx94 you can customize the format of the hour display content.

such as

const formatAMPM = (date) => {
    let hours = date.getHours();
    let ampm = hours >= 12 ? 'pm' : 'am';;
    hours = hours % 12;
    hours = hours ? hours : 12; // the hour '0' should be '12'
    return hours + ampm;
}

// ....

render() {
    return (
        <DatePicker
        dateConfig={{
            'hour': {
                format: value => this.formatAMPM(value),
                caption: '时',
                step: 1,
            },
        }} />
    );
}

@embargiel
Copy link

@lanjingling0510 Nice example, but the question is if it is possible to have AM/PM as a third element with possibility to scroll in the same way as minutes or hours

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

No branches or pull requests

3 participants