import React, { Component } from 'react'
import { DatePicker, Row, Col  } from 'antd';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');

class DateTime extends Component {
	render() {
		let {
			value,
            scope,
            date_type
		} = this.props

		if(scope ==="among") {
			return (
				<Row  className="u-field-search-among" gutter={0}>
					<Col span={11}>
						
                        <DatePicker 
                            value={value.start ? moment(value.start, "YYYY-MM-DD HH:mm:ss") : null} 
                            // className="rep-u-field-search-datatime"
							format={"YYYY-MM-DD HH:mm:ss"} 
							showTime
                            // format={date_type}
                            onChange={(val,datestring)=>{
                                let newValue = value;
                                newValue.start = datestring;
                                this.props.onChange(newValue)
                            }} />
					</Col>
					<Col span={1}  offset={1}>
						-
					</Col>
					<Col span={11} >
						
                        <DatePicker 
                            value={value.end ? moment(value.end, "YYYY-MM-DD HH:mm:ss") : null} 
                            // className="rep-u-field-search-datatime" 
							format={"YYYY-MM-DD HH:mm:ss"}
							showTime
                            // format={date_type}
                            onChange={(val,datestring)=>{
                                let newValue1 = value;
                                newValue1.end = datestring;
                                this.props.onChange(newValue1)
                            }} />
					</Col>
					
				</Row>
			)
		}else{
			return (
                <DatePicker
                    value={value ? moment(value, "YYYY-MM-DD HH:mm:ss") : null} 
                    // className="rep-u-field-search-datatime"
                    format={"YYYY-MM-DD HH:mm:ss"} 
                    // format={date_type}
					style={{width:"174px"}}
					showTime
                    onChange={(value,datestring)=>this.props.onChange(datestring)}
                 />
			)	
		}
        
       
	}
}

export default DateTime
