mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
fixed invalid date issue
This commit is contained in:
parent
6fb7df8ff6
commit
35da6e0178
@ -23,12 +23,13 @@ class DateTimePickerView extends PureComponent {
|
|||||||
date: '',
|
date: '',
|
||||||
time: '',
|
time: '',
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
_setValue = (stateName, value) => {
|
_setValue = (stateName, value) => {
|
||||||
const { onSubmit } = this.props;
|
const { onSubmit } = this.props;
|
||||||
const { date, time } = this.state;
|
const { date, time } = this.state;
|
||||||
this.setState({ [stateName]: value });
|
const _value = value === 'Invalid date' ? moment().format('HH:mm:ss') : value;
|
||||||
|
this.setState({ [stateName]: _value });
|
||||||
|
|
||||||
if (!time && !date) {
|
if (!time && !date) {
|
||||||
this.timePickerTimeout = setTimeout(() => {
|
this.timePickerTimeout = setTimeout(() => {
|
||||||
@ -38,21 +39,15 @@ class DateTimePickerView extends PureComponent {
|
|||||||
clearTimeout(this.timePickerTimeout);
|
clearTimeout(this.timePickerTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date && value) {
|
if (date && _value) {
|
||||||
const formatedDateTime = new Date(`${date} ${value}`).toISOString();
|
const formatedDateTime = new Date(`${date} ${_value}`).toISOString();
|
||||||
onSubmit(formatedDateTime);
|
onSubmit(formatedDateTime);
|
||||||
this._initState();
|
this._initState();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { type, iconName, disabled, intl } = this.props;
|
||||||
type,
|
|
||||||
iconName,
|
|
||||||
disabled,
|
|
||||||
intl,
|
|
||||||
} = this.props;
|
|
||||||
const { date } = this.state;
|
const { date } = this.state;
|
||||||
let _type;
|
let _type;
|
||||||
let _format;
|
let _format;
|
||||||
@ -84,19 +79,21 @@ class DateTimePickerView extends PureComponent {
|
|||||||
onDateChange={_datePickerValue => this._setValue(!date ? 'date' : 'time', _datePickerValue)}
|
onDateChange={_datePickerValue => this._setValue(!date ? 'date' : 'time', _datePickerValue)}
|
||||||
hideText
|
hideText
|
||||||
is24Hour
|
is24Hour
|
||||||
ref={(picker) => { this.datePicker = picker; }}
|
ref={picker => {
|
||||||
|
this.datePicker = picker;
|
||||||
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
customStyles={{
|
customStyles={{
|
||||||
...styles,
|
...styles,
|
||||||
}}
|
}}
|
||||||
iconComponent={(
|
iconComponent={
|
||||||
<Icon
|
<Icon
|
||||||
style={{ ...styles.iconButton, ...styles.scheduleIcon }}
|
style={{ ...styles.iconButton, ...styles.scheduleIcon }}
|
||||||
size={20}
|
size={20}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
name={iconName}
|
name={iconName}
|
||||||
/>
|
/>
|
||||||
)}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user