From 11b97949da16fc090400a753189baf10f29c111f Mon Sep 17 00:00:00 2001 From: MG12 Date: Thu, 19 Nov 2015 15:15:03 +0800 Subject: use another method to change time and fix the bug about value.getTime() --- src/module/Combobox.jsx | 19 +++++++++---------- src/module/Header.jsx | 12 ++++++------ 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src') 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({ 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 (
- {this.getHourSelect(timeFields[4])} - {this.getMinuteSelect(timeFields[5])} - {this.getSectionSelect(timeFields[6])} + {this.getHourSelect(value.getHourOfDay())} + {this.getMinuteSelect(value.getMinutes())} + {this.getSectionSelect(value.getSeconds())}
); }, 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({ if (value) { if ( - hourOptions.indexOf(value.fields[4]) < 0 || - minuteOptions.indexOf(value.fields[5]) < 0 || - secondOptions.indexOf(value.fields[6]) < 0 + hourOptions.indexOf(value.getHourOfDay()) < 0 || + minuteOptions.indexOf(value.getMinutes()) < 0 || + secondOptions.indexOf(value.getSeconds()) < 0 ) { this.setState({ invalid: true, @@ -69,9 +69,9 @@ const Header = React.createClass({ if (originalValue && value) { if ( - originalValue.fields[4] !== value.fields[4] || - originalValue.fields[5] !== value.fields[5] || - originalValue.fields[6] !== value.fields[6] + originalValue.getHourOfDay() !== value.getHourOfDay() || + originalValue.getMinutes() !== value.getMinutes() || + originalValue.getSeconds() !== value.getSeconds() ) { onChange(value); } -- cgit v1.2.3