<commit_before>'use strict';

import React from 'react';
import Calendar from 'rc-calendar';
const Datepicker = Calendar.Picker;

import GregorianCalendar from 'gregorian-calendar';
import zhCn from 'gregorian-calendar/lib/locale/zh-cn';
import CalendarLocale from 'rc-calendar/lib/locale/zh-cn';
import DateTimeFormat from 'gregorian-calendar-format';

// 和顶部文案保持一致
import Locale from 'gregorian-calendar-format/lib/locale/zh-cn';
Locale.shortMonths = ['1月', '2月', '3月', '4月', '5月', '6月',
                      '7月', '8月', '9月', '10月', '11月', '12月'];

// 以下两行代码
// 给没有初始值的日期选择框提供本地化信息
let defaultCalendarValue = new GregorianCalendar(zhCn);
defaultCalendarValue.setTime(Date.now());

export default React.createClass({
  getInitialState() {
    return {
      value: ''
    };
  },
  getDefaultProps() {
    return {
      format: 'yyyy-MM-dd',
      placeholder: '请选择日期'
    };
  },
  componentDidMount() {
    let state = {};
    if (this.props.value) {
      let value = new GregorianCalendar(zhCn);
      value.setTime(new Date(this.props.value));
      state.value = value;
    }
    state.disabled = this.props.disabled || function() {};
    this.setState(state);
  },
  handleChange() {
    this.props.onSelect(new Date(this.state.value.getTime()));
  },
  render() {
    let calendar = (
      <Calendar
      disabledDate={this.state.disabled}
      locale={CalendarLocale}
      orient={['top', 'left']}
      defaultValue={defaultCalendarValue}
      showTime={this.props.showTime}
      prefixCls="ant-calendar"
      showOk={this.props.showTime}
      showClear={false} />
    );
    return (
      <Datepicker
        trigger={<span className="ant-calendar-picker-icon" />}
        calendar={calendar}
        formatter={new DateTimeFormat(this.props.format)}
        value={this.state.value}
        prefixCls="ant-calendar-picker"
        onChange={this.props.onSelect}>
        <input placeholder={this.props.placeholder} className="ant-calendar-picker-input" />
      </Datepicker>
    );
  }
});<commit_msg>fix datepicker<commit_after>'use strict';

import React from 'react';
import Calendar from 'rc-calendar';
const Datepicker = Calendar.Picker;

import GregorianCalendar from 'gregorian-calendar';
import zhCn from 'gregorian-calendar/lib/locale/zh-cn';
import CalendarLocale from 'rc-calendar/lib/locale/zh-cn';
import DateTimeFormat from 'gregorian-calendar-format';

// 和顶部文案保持一致
import Locale from 'gregorian-calendar-format/lib/locale/zh-cn';
Locale.shortMonths = ['1月', '2月', '3月', '4月', '5月', '6月',
                      '7月', '8月', '9月', '10月', '11月', '12月'];

// 以下两行代码
// 给没有初始值的日期选择框提供本地化信息
let defaultCalendarValue = new GregorianCalendar(zhCn);
defaultCalendarValue.setTime(Date.now());

export default React.createClass({
  getInitialState: function () {
    var value = new GregorianCalendar(zhCn);
    if (this.props.value) {
      value.setTime(new Date(this.props.value).valueOf());
    } else {
      value.setTime(Date.now());
    }
    return {
      value: value
    };
  },
  componentWillReceiveProps(nextProps){
    if ('value' in nextProps) {
      var value = new GregorianCalendar(zhCn);
      value.setTime(new Date(nextProps.value).valueOf());
      this.setState({
        value: value
      });
    }
  },
  getDefaultProps: function () {
    return {
      format: 'yyyy-MM-dd',
      placeholder: '请选择日期',
      onSelect: function () {
      }
    };
  },
  handleChange: function (v) {
    this.setState({
      value: v
    });
    this.props.onSelect(new Date(v.getTime()));
  },
  render: function () {
    var calendar = (
      <Calendar
        disabledDate={this.props.disabled}
        locale={CalendarLocale}
        orient={['top', 'left']}
        defaultValue={defaultCalendarValue}
        showTime={this.props.showTime}
        prefixCls="ant-calendar"
        showOk={this.props.showTime}
        showClear={false}/>
    );
    return (
      <Datepicker
        trigger={<span className="ant-calendar-picker-icon" />}
        calendar={calendar}
        formatter={new DateTimeFormat(this.props.format)}
        value={this.state.value}
        prefixCls="ant-calendar-picker"
        onChange={this.handleChange}>
        <input placeholder={this.props.placeholder} className="ant-calendar-picker-input"/>
      </Datepicker>
    );
  }
});
{'fraction_non_alphanumeric': 0.15083410565338276, 'fraction_numerical': 0.006950880444856348, 'mean_word_length': 3.038353601496726, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7126142', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1410, 'n_words': 245}