diff options
author | MG12 <wuzhao.mail@gmail.com> | 2015-11-19 15:15:03 +0800 |
---|---|---|
committer | MG12 <wuzhao.mail@gmail.com> | 2015-11-19 15:15:03 +0800 |
commit | 11b97949da16fc090400a753189baf10f29c111f (patch) | |
tree | aee755ef1eced68f70cca5d0427c75ab76ac7b36 /src | |
parent | e75ed0c6b89282cf475e94d6d5ad0fb35803f974 (diff) | |
download | time-picker-11b97949da16fc090400a753189baf10f29c111f.tar.gz time-picker-11b97949da16fc090400a753189baf10f29c111f.tar.zst time-picker-11b97949da16fc090400a753189baf10f29c111f.zip |
use another method to change time and fix the bug about value.getTime()
Diffstat (limited to 'src')
-rw-r--r-- | src/module/Combobox.jsx | 19 | ||||
-rw-r--r-- | src/module/Header.jsx | 12 |
2 files changed, 15 insertions, 16 deletions
diff --git a/src/module/Combobox.jsx b/src/module/Combobox.jsx index e6fe5ed..afce675 100644 --- a/src/module/Combobox.jsx +++ b/src/module/Combobox.jsx | |||
@@ -23,13 +23,13 @@ const Combobox = React.createClass({ | |||
23 | 23 | ||
24 | onItemChange(type, itemValue) { | 24 | onItemChange(type, itemValue) { |
25 | const { value, onChange } = this.props; | 25 | const { value, onChange } = this.props; |
26 | let index = 4; | 26 | if (type === 'hour') { |
27 | if (type === 'minute') { | 27 | value.setHourOfDay(itemValue); |
28 | index = 5; | 28 | } else if (type === 'minute') { |
29 | } else if (type === 'second') { | 29 | value.setMinutes(itemValue); |
30 | index = 6; | 30 | } else { |
31 | value.setSeconds(itemValue); | ||
31 | } | 32 | } |
32 | value.fields[index] = itemValue; | ||
33 | onChange(value); | 33 | onChange(value); |
34 | }, | 34 | }, |
35 | 35 | ||
@@ -80,13 +80,12 @@ const Combobox = React.createClass({ | |||
80 | 80 | ||
81 | render() { | 81 | render() { |
82 | const { prefixCls, value } = this.props; | 82 | const { prefixCls, value } = this.props; |
83 | const timeFields = value.fields; | ||
84 | 83 | ||
85 | return ( | 84 | return ( |
86 | <div className={`${prefixCls}-combobox`}> | 85 | <div className={`${prefixCls}-combobox`}> |
87 | {this.getHourSelect(timeFields[4])} | 86 | {this.getHourSelect(value.getHourOfDay())} |
88 | {this.getMinuteSelect(timeFields[5])} | 87 | {this.getMinuteSelect(value.getMinutes())} |
89 | {this.getSectionSelect(timeFields[6])} | 88 | {this.getSectionSelect(value.getSeconds())} |
90 | </div> | 89 | </div> |
91 | ); | 90 | ); |
92 | }, | 91 | }, |
diff --git a/src/module/Header.jsx b/src/module/Header.jsx index 92a0089..b65fd25 100644 --- a/src/module/Header.jsx +++ b/src/module/Header.jsx | |||
@@ -57,9 +57,9 @@ const Header = React.createClass({ | |||
57 | 57 | ||
58 | if (value) { | 58 | if (value) { |
59 | if ( | 59 | if ( |
60 | hourOptions.indexOf(value.fields[4]) < 0 || | 60 | hourOptions.indexOf(value.getHourOfDay()) < 0 || |
61 | minuteOptions.indexOf(value.fields[5]) < 0 || | 61 | minuteOptions.indexOf(value.getMinutes()) < 0 || |
62 | secondOptions.indexOf(value.fields[6]) < 0 | 62 | secondOptions.indexOf(value.getSeconds()) < 0 |
63 | ) { | 63 | ) { |
64 | this.setState({ | 64 | this.setState({ |
65 | invalid: true, | 65 | invalid: true, |
@@ -69,9 +69,9 @@ const Header = React.createClass({ | |||
69 | 69 | ||
70 | if (originalValue && value) { | 70 | if (originalValue && value) { |
71 | if ( | 71 | if ( |
72 | originalValue.fields[4] !== value.fields[4] || | 72 | originalValue.getHourOfDay() !== value.getHourOfDay() || |
73 | originalValue.fields[5] !== value.fields[5] || | 73 | originalValue.getMinutes() !== value.getMinutes() || |
74 | originalValue.fields[6] !== value.fields[6] | 74 | originalValue.getSeconds() !== value.getSeconds() |
75 | ) { | 75 | ) { |
76 | onChange(value); | 76 | onChange(value); |
77 | } | 77 | } |