diff options
Diffstat (limited to 'src/TimePicker.jsx')
-rw-r--r-- | src/TimePicker.jsx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx index e9d6d15..7065333 100644 --- a/src/TimePicker.jsx +++ b/src/TimePicker.jsx | |||
@@ -43,6 +43,7 @@ const Picker = React.createClass({ | |||
43 | addon: PropTypes.func, | 43 | addon: PropTypes.func, |
44 | name: PropTypes.string, | 44 | name: PropTypes.string, |
45 | autoComplete: PropTypes.string, | 45 | autoComplete: PropTypes.string, |
46 | use12Hours: PropTypes.bool, | ||
46 | }, | 47 | }, |
47 | 48 | ||
48 | getDefaultProps() { | 49 | getDefaultProps() { |
@@ -67,6 +68,7 @@ const Picker = React.createClass({ | |||
67 | onOpen: noop, | 68 | onOpen: noop, |
68 | onClose: noop, | 69 | onClose: noop, |
69 | addon: noop, | 70 | addon: noop, |
71 | use12Hours: false, | ||
70 | }; | 72 | }; |
71 | }, | 73 | }, |
72 | 74 | ||
@@ -126,10 +128,21 @@ const Picker = React.createClass({ | |||
126 | }, | 128 | }, |
127 | 129 | ||
128 | getFormat() { | 130 | getFormat() { |
129 | const { format, showHour, showMinute, showSecond } = this.props; | 131 | const { format, showHour, showMinute, showSecond, use12Hours } = this.props; |
130 | if (format) { | 132 | if (format) { |
131 | return format; | 133 | return format; |
132 | } | 134 | } |
135 | |||
136 | if (use12Hours) { | ||
137 | const fmtString = ([ | ||
138 | showHour ? 'h' : '', | ||
139 | showMinute ? 'mm' : '', | ||
140 | showSecond ? 'ss' : '', | ||
141 | ].filter(item => !!item).join(':')); | ||
142 | |||
143 | return fmtString.concat(' a'); | ||
144 | } | ||
145 | |||
133 | return [ | 146 | return [ |
134 | showHour ? 'HH' : '', | 147 | showHour ? 'HH' : '', |
135 | showMinute ? 'mm' : '', | 148 | showMinute ? 'mm' : '', |
@@ -142,7 +155,7 @@ const Picker = React.createClass({ | |||
142 | prefixCls, placeholder, disabledHours, | 155 | prefixCls, placeholder, disabledHours, |
143 | disabledMinutes, disabledSeconds, hideDisabledOptions, | 156 | disabledMinutes, disabledSeconds, hideDisabledOptions, |
144 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, | 157 | allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, |
145 | addon, | 158 | addon, use12Hours, |
146 | } = this.props; | 159 | } = this.props; |
147 | return ( | 160 | return ( |
148 | <Panel | 161 | <Panel |
@@ -164,6 +177,7 @@ const Picker = React.createClass({ | |||
164 | disabledMinutes={disabledMinutes} | 177 | disabledMinutes={disabledMinutes} |
165 | disabledSeconds={disabledSeconds} | 178 | disabledSeconds={disabledSeconds} |
166 | hideDisabledOptions={hideDisabledOptions} | 179 | hideDisabledOptions={hideDisabledOptions} |
180 | use12Hours={use12Hours} | ||
167 | addon={addon} | 181 | addon={addon} |
168 | /> | 182 | /> |
169 | ); | 183 | ); |