<commit_before>import React, { PropTypes, Component } from 'react';
import DateTimePicker from 'react-datetime';
// import moment from 'moment';

class DateTime extends Component {
  
  constructor(props) {
    super(props);
    
    this.updateDate = this.updateDate.bind(this);
  }

  // when the datetime picker has mounted, SmartForm will catch the date value (no formsy mixin in this component)
  componentDidMount() {
    this.updateDate(this.props.value || new Date());
  }

  updateDate(date) {
    this.context.updateCurrentValues({[this.props.name]: date});
  }

  render() {
    return (
      <div className="form-group row">
        <label className="control-label col-sm-3">{this.props.label}</label>
        <div className="col-sm-9">
          <DateTimePicker
            value={this.props.value || new Date()}
            // newDate argument is a Moment object given by react-datetime
            onChange={newDate => this.updateDate(newDate._d)}
            format={"x"}
            inputProps={{name: this.props.name}}
          />
        </div>
      </div>
    );
  }
}

DateTime.propTypes = {
  control: React.PropTypes.any,
  datatype: React.PropTypes.any,
  group: React.PropTypes.any,
  label: React.PropTypes.string,
  name: React.PropTypes.string,
  value: React.PropTypes.any,
};

DateTime.contextTypes = {
  addToAutofilledValues: React.PropTypes.func,
  updateCurrentValues: React.PropTypes.func,
};

export default DateTime;
<commit_msg>Convert date fields to actual dates<commit_after>import React, { PropTypes, Component } from 'react';
import DateTimePicker from 'react-datetime';
// import moment from 'moment';

class DateTime extends Component {
  
  constructor(props) {
    super(props);
    
    this.updateDate = this.updateDate.bind(this);
  }

  // when the datetime picker has mounted, SmartForm will catch the date value (no formsy mixin in this component)
  componentDidMount() {
    this.updateDate(this.props.value || new Date());
  }

  updateDate(date) {
    this.context.updateCurrentValues({[this.props.name]: date});
  }

  render() {

    const date = typeof this.props.value === 'string' ? new Date(this.props.value) : this.props.value;
    
    return (
      <div className="form-group row">
        <label className="control-label col-sm-3">{this.props.label}</label>
        <div className="col-sm-9">
          <DateTimePicker
            value={date || new Date()}
            // newDate argument is a Moment object given by react-datetime
            onChange={newDate => this.updateDate(newDate._d)}
            format={"x"}
            inputProps={{name: this.props.name}}
          />
        </div>
      </div>
    );
  }
}

DateTime.propTypes = {
  control: React.PropTypes.any,
  datatype: React.PropTypes.any,
  group: React.PropTypes.any,
  label: React.PropTypes.string,
  name: React.PropTypes.string,
  value: React.PropTypes.any,
};

DateTime.contextTypes = {
  addToAutofilledValues: React.PropTypes.func,
  updateCurrentValues: React.PropTypes.func,
};

export default DateTime;

{'fraction_non_alphanumeric': 0.12986588158325155, 'fraction_numerical': 0.0013084723585214263, 'mean_word_length': 2.9714285714285715, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '4875055', 'n_tokens_mistral': 915, 'n_tokens_neox': 913, 'n_words': 209}