]> git.immae.eu Git - github/fretlink/time-picker.git/blobdiff - src/module/Combobox.jsx
use another method to change time and fix the bug about value.getTime()
[github/fretlink/time-picker.git] / src / module / Combobox.jsx
index e6fe5edffa03baf0880b7276e9ddd7e138f57ccd..afce675c6a5270892b1fa3284bf45a6110611a34 100644 (file)
@@ -23,13 +23,13 @@ const Combobox = React.createClass({
 
   onItemChange(type, itemValue) {
     const { value, onChange } = this.props;
-    let index = 4;
-    if (type === 'minute') {
-      index = 5;
-    } else if (type === 'second') {
-      index = 6;
+    if (type === 'hour') {
+      value.setHourOfDay(itemValue);
+    } else if (type === 'minute') {
+      value.setMinutes(itemValue);
+    } else {
+      value.setSeconds(itemValue);
     }
-    value.fields[index] = itemValue;
     onChange(value);
   },
 
@@ -80,13 +80,12 @@ const Combobox = React.createClass({
 
   render() {
     const { prefixCls, value } = this.props;
-    const timeFields = value.fields;
 
     return (
       <div className={`${prefixCls}-combobox`}>
-        {this.getHourSelect(timeFields[4])}
-        {this.getMinuteSelect(timeFields[5])}
-        {this.getSectionSelect(timeFields[6])}
+        {this.getHourSelect(value.getHourOfDay())}
+        {this.getMinuteSelect(value.getMinutes())}
+        {this.getSectionSelect(value.getSeconds())}
       </div>
     );
   },