From 37c36c09e0a4d693a2ec5623ff2ebc8d9ee16a06 Mon Sep 17 00:00:00 2001
From: afc163 <afc163@gmail.com>
Date: Fri, 11 Nov 2016 13:55:55 +0800
Subject: Add showMinute

---
 src/TimePicker.jsx | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

(limited to 'src/TimePicker.jsx')

diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 99d1008..e9f18a9 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -29,6 +29,7 @@ const Picker = React.createClass({
     placeholder: PropTypes.string,
     format: PropTypes.string,
     showHour: PropTypes.bool,
+    showMinute: PropTypes.bool,
     showSecond: PropTypes.bool,
     style: PropTypes.object,
     className: PropTypes.string,
@@ -53,6 +54,7 @@ const Picker = React.createClass({
       defaultOpenValue: moment(),
       allowEmpty: true,
       showHour: true,
+      showMinute: true,
       showSecond: true,
       disabledHours: noop,
       disabledMinutes: noop,
@@ -121,24 +123,22 @@ const Picker = React.createClass({
   },
 
   getFormat() {
-    const format = this.props.format;
+    const { format, showHour, showMinute, showSecond } = this.props;
     if (format) {
       return format;
     }
-    if (!this.props.showSecond) {
-      return 'HH:mm';
-    }
-    if (!this.props.showHour) {
-      return 'mm:ss';
-    }
-    return 'HH:mm:ss';
+    return [
+      showHour ? 'HH' : '',
+      showMinute ? 'mm' : '',
+      showSecond ? 'ss' : '',
+    ].filter(item => !!item).join(':');
   },
 
   getPanelElement() {
     const {
       prefixCls, placeholder, disabledHours,
       disabledMinutes, disabledSeconds, hideDisabledOptions,
-      allowEmpty, showHour, showSecond, defaultOpenValue, clearText,
+      allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
       addon,
     } = this.props;
     return (
@@ -151,6 +151,7 @@ const Picker = React.createClass({
         onClear={this.onPanelClear}
         defaultOpenValue={defaultOpenValue}
         showHour={showHour}
+        showMinute={showMinute}
         showSecond={showSecond}
         onEsc={this.onEsc}
         allowEmpty={allowEmpty}
-- 
cgit v1.2.3

