<commit_before>import React, { Component, PropTypes } from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import TransitionGroup from 'react-addons-transition-group';
import classnames from 'classnames';

import { ESC } from '../constants/keyCodes';
import { DateTimeFormat, getTimeString } from '../utils';
import Dialog from '../Dialogs';
import FontIcon from '../FontIcons';
import Height from '../Transitions';
import TextField from '../TextFields';
import TimePicker from './TimePicker';

export default class TimePickerContainer extends Component {
  constructor(props) {
    super(props);

    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);

    const date = props.defaultValue ? new Date(props.defaultValue) : new Date();

    this.state = {
      ...this.getTimeParts(date, props),
      value: props.defaultValue,
      isOpen: props.initiallyOpen,
      time: date,
      timeMode: props.initialTimeMode,
      tempTime: date,
    };
  }

  static propTypes = {
    className: PropTypes.string,
    icon: PropTypes.node,
    defaultValue: PropTypes.instanceOf(Date),
    value: PropTypes.instanceOf(Date),
    initiallyOpen: PropTypes.bool,
    label: PropTypes.string,
    onChange: PropTypes.func,
    floatingLabel: PropTypes.bool,
    DateTimeFormat: PropTypes.func.isRequired,
    locales: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.arrayOf(PropTypes.string),
    ]).isRequired,
    okLabel: PropTypes.string.isRequired,
    okPrimary: PropTypes.bool,
    cancelLabel: PropTypes.string.isRequired,
    cancelPrimary: PropTypes.bool,
    initialTimeMode: PropTypes.oneOf(['hour', 'minute']),
    inline: PropTypes.bool,
    displayMode: PropTypes.oneOf(['landscape', 'portrait']),
  };

  static defaultProps = {
    initiallyOpen: false,
    initialTimeMode: 'hour',
    icon: <FontIcon>access_time</FontIcon>,
    DateTimeFormat: DateTimeFormat,
    locales: navigator.language,
    okLabel: 'Ok',
    okPrimary: true,
    cancelLabel: 'Cancel',
    cancelPrimary: true,
  };

  componentWillUpdate(nextProps, nextState) {
    if(this.getValue() !== this.getValue(nextProps, nextState)) {
      this.setState(this.getTimeParts(this.getValue(nextProps, nextState), nextProps));<commit_msg>Updated TimePicker locales default to include userLanguage<commit_after>import React, { Component, PropTypes } from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import TransitionGroup from 'react-addons-transition-group';
import classnames from 'classnames';

import { ESC } from '../constants/keyCodes';
import { DateTimeFormat, getTimeString } from '../utils';
import Dialog from '../Dialogs';
import FontIcon from '../FontIcons';
import Height from '../Transitions';
import TextField from '../TextFields';
import TimePicker from './TimePicker';

export default class TimePickerContainer extends Component {
  constructor(props) {
    super(props);

    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);

    const date = props.defaultValue ? new Date(props.defaultValue) : new Date();

    this.state = {
      ...this.getTimeParts(date, props),
      value: props.defaultValue,
      isOpen: props.initiallyOpen,
      time: date,
      timeMode: props.initialTimeMode,
      tempTime: date,
    };
  }

  static propTypes = {
    className: PropTypes.string,
    icon: PropTypes.node,
    defaultValue: PropTypes.instanceOf(Date),
    value: PropTypes.instanceOf(Date),
    initiallyOpen: PropTypes.bool,
    label: PropTypes.string,
    onChange: PropTypes.func,
    floatingLabel: PropTypes.bool,
    DateTimeFormat: PropTypes.func.isRequired,
    locales: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.arrayOf(PropTypes.string),
    ]).isRequired,
    okLabel: PropTypes.string.isRequired,
    okPrimary: PropTypes.bool,
    cancelLabel: PropTypes.string.isRequired,
    cancelPrimary: PropTypes.bool,
    initialTimeMode: PropTypes.oneOf(['hour', 'minute']),
    inline: PropTypes.bool,
    displayMode: PropTypes.oneOf(['landscape', 'portrait']),
  };

  static defaultProps = {
    initiallyOpen: false,
    initialTimeMode: 'hour',
    icon: <FontIcon>access_time</FontIcon>,
    DateTimeFormat: DateTimeFormat,
    locales: window.navigator.userLanguage || window.navigator.language,
    okLabel: 'Ok',
    okPrimary: true,
    cancelLabel: 'Cancel',
    cancelPrimary: true,
  };

  componentWillUpdate(nextProps, nextState) {
    if(this.getValue() !== this.getValue(nextProps, nextState)) {
      this.setState(this.getTimeParts(this.getValue(nextProps, nextState), nextProps));
{'fraction_non_alphanumeric': 0.12120559741657697, 'fraction_numerical': 0.0, 'mean_word_length': 4.094298245614035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5434643', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1341, 'n_words': 298}