import React, { Component } from 'react';
import hocImmutable, { imShallowEqual } from '../../utils/HOC/hocImmutable';
import { DatePicker } from 'antd';

import momentUtil from './momentUtil.js';

const Picker = hocImmutable(({ format = 'YYYY-MM-DD', onChange, ...props }) => {
    momentUtil.parse(props, format);
    return <DatePicker {...props}
        format={format}
        onChange={(date, dateStr) => onChange && onChange(dateStr, date)}
    />
})

export default Picker;

export const DatePickerWithTime = ({ format = 'YYYY-MM-DD HH:mm:ss', showTime = true, ...props }) => {
    return <Picker {...props}
        showTime={showTime}
        format={format}
    />
}