diff options
-rw-r--r-- | examples/12hours.js | 3 | ||||
-rw-r--r-- | 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'; | |||
10 | import TimePicker from 'rc-time-picker'; | 10 | import TimePicker from 'rc-time-picker'; |
11 | 11 | ||
12 | const showSecond = false; | 12 | const showSecond = false; |
13 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | 13 | const str = showSecond ? 'h:mm a' : 'h:mm a'; |
14 | 14 | ||
15 | const now = moment().hour(0).minute(0); | 15 | const now = moment().hour(0).minute(0); |
16 | 16 | ||
@@ -24,6 +24,7 @@ ReactDom.render( | |||
24 | defaultValue={now} | 24 | defaultValue={now} |
25 | className="xxx" | 25 | className="xxx" |
26 | onChange={onChange} | 26 | onChange={onChange} |
27 | format={str} | ||
27 | use12Hours | 28 | use12Hours |
28 | />, | 29 | />, |
29 | document.getElementById('__react-content') | 30 | 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({ | |||
145 | }, | 145 | }, |
146 | 146 | ||
147 | getAMPMSelect() { | 147 | getAMPMSelect() { |
148 | const { prefixCls, use12Hours } = this.props; | 148 | const { prefixCls, use12Hours, format } = this.props; |
149 | if (!use12Hours) { | 149 | if (!use12Hours) { |
150 | return null; | 150 | return null; |
151 | } | 151 | } |
152 | const AMPMOptions = [{ value: 'AM' }, { value: 'PM' }]; | 152 | |
153 | const AMPMOptions = ['am', 'pm'] // If format has A char, then we should uppercase AM/PM | ||
154 | .map(c => format.match(/\sA/) ? c.toUpperCase() : c) | ||
155 | .map(c => ({ value: c })); | ||
156 | |||
153 | const selected = this.isAM() ? 0 : 1; | 157 | const selected = this.isAM() ? 0 : 1; |
154 | 158 | ||
155 | return ( | 159 | return ( |