From eb3c19e2cd2e11cec1eed9337ce44a312b3fc60b Mon Sep 17 00:00:00 2001 From: Antony Shaleynikov Date: Mon, 6 Mar 2017 12:51:39 +0300 Subject: Added support for lower/uppercase of AM/PM selectors --- examples/12hours.js | 3 ++- src/Combobox.jsx | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/12hours.js b/examples/12hours.js index 44e514a..16e428d 100644 --- a/examples/12hours.js +++ b/examples/12hours.js @@ -10,7 +10,7 @@ import moment from 'moment'; import TimePicker from 'rc-time-picker'; const showSecond = false; -const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; +const str = showSecond ? 'h:mm a' : 'h:mm a'; const now = moment().hour(0).minute(0); @@ -24,6 +24,7 @@ ReactDom.render( defaultValue={now} className="xxx" onChange={onChange} + format={str} use12Hours />, document.getElementById('__react-content') diff --git a/src/Combobox.jsx b/src/Combobox.jsx index 958e108..00f122f 100644 --- a/src/Combobox.jsx +++ b/src/Combobox.jsx @@ -145,11 +145,15 @@ const Combobox = React.createClass({ }, getAMPMSelect() { - const { prefixCls, use12Hours } = this.props; + const { prefixCls, use12Hours, format } = this.props; if (!use12Hours) { return null; } - const AMPMOptions = [{ value: 'AM' }, { value: 'PM' }]; + + const AMPMOptions = ['am', 'pm'] // If format has A char, then we should uppercase AM/PM + .map(c => format.match(/\sA/) ? c.toUpperCase() : c) + .map(c => ({ value: c })); + const selected = this.isAM() ? 0 : 1; return ( -- cgit v1.2.3