<commit_before>import React from 'react'
import Input from '../input'
import Switch from '../switch'
import defaultProps from '../../default_props.js'

export default class TimePickerPopup extends React.Component {
  static displayName = 'FriggingBootstrap.TimePickerPopup'

  static defaultProps = defaultProps

  static propTypes = {
    onTimeChange: React.PropTypes.func.isRequired,
    hours: React.PropTypes.string.isRequired,
    minutes: React.PropTypes.string.isRequired,
    amPm: React.PropTypes.string.isRequired,
  }

  constructor() {
    super()
    this.onMinuteChange = this.onMinuteChange.bind(this)
    this.onHourChange = this.onHourChange.bind(this)
    this.onAmPmChange = this.onAmPmChange.bind(this)
  }

  onHourChange(newHour) {
    const hours = newHour
    const minutes = this._getMinutesFromProps()
    const amPm = this._getAmPmFromProps()
    this.onPopupTimeChange(hours, minutes, amPm)
  }

  onMinuteChange(newMinute) {
    const hours = this._getHoursFromProps()
    const minutes = newMinute
    const amPm = this._getAmPmFromProps()
    this.onPopupTimeChange(hours, minutes, amPm)
  }

  onAmPmChange(isAm) {
    const hours = this._getHoursFromProps()
    const minutes = this._getMinutesFromProps()
    const amPm = isAm ? 'AM' : 'PM'

    this.onPopupTimeChange(hours, minutes, amPm)
  }

  // Sends a new time string to the <TimePicker>.
  //
  // The value we send must be a valid time parseable by TimeFormatter.
  //
  // Since we use <input type="number" step="..." />, this is
  // the final chance to normalize values like "3:-15" and "3:75".
  onPopupTimeChange(hours, minutes, amPm) {
    const normalizedHours = this.normalizeHours(hours)
    const normalizedMinutes = this.normalizeMinutes(minutes)

    const newTimeString = `${normalizedHours}:${normalizedMinutes} ${amPm}`
    this.props.onTimeChange(newTimeString)
  }

  normalizeHours(strHours) {
    const hours = parseInt(strHours, 10)
    if (hours <= 0) return 12
    if (hours >= 13) return 1
    return hours<commit_msg>TimePickerPopup: Handle synthetic onChange event<commit_after>import React from 'react'
import Input from '../input'
import Switch from '../switch'
import defaultProps from '../../default_props.js'

export default class TimePickerPopup extends React.Component {
  static displayName = 'FriggingBootstrap.TimePickerPopup'

  static defaultProps = defaultProps

  static propTypes = {
    onTimeChange: React.PropTypes.func.isRequired,
    hours: React.PropTypes.string.isRequired,
    minutes: React.PropTypes.string.isRequired,
    amPm: React.PropTypes.string.isRequired,
  }

  constructor() {
    super()
    this.onMinuteChange = this.onMinuteChange.bind(this)
    this.onHourChange = this.onHourChange.bind(this)
    this.onAmPmChange = this.onAmPmChange.bind(this)
  }

  onHourChange(e) {
    const newHour = e.target.value
    const hours = newHour
    const minutes = this._getMinutesFromProps()
    const amPm = this._getAmPmFromProps()
    this.onPopupTimeChange(hours, minutes, amPm)
  }

  onMinuteChange(e) {
    const newMinute = e.target.value
    const hours = this._getHoursFromProps()
    const minutes = newMinute
    const amPm = this._getAmPmFromProps()
    this.onPopupTimeChange(hours, minutes, amPm)
  }

  // note: Switch does not send a SyntheticEvent, it sends the boolean value
  onAmPmChange(isAm) {
    const hours = this._getHoursFromProps()
    const minutes = this._getMinutesFromProps()
    const amPm = isAm ? 'AM' : 'PM'

    this.onPopupTimeChange(hours, minutes, amPm)
  }

  // Sends a new time string to the <TimePicker>.
  //
  // The value we send must be a valid time parseable by TimeFormatter.
  //
  // Since we use <input type="number" step="..." />, this is
  // the final chance to normalize values like "3:-15" and "3:75".
  onPopupTimeChange(hours, minutes, amPm) {
    const normalizedHours = this.normalizeHours(hours)
    const normalizedMinutes = this.normalizeMinutes(minutes)

    const newTimeString = `${normalizedHours}:${normalizedMinutes} ${amPm}`
    this.props.onTimeChange(newTimeString)
  }

  normalizeHours(strHours) {
    const hours = parseInt(strHours, 10)
    if (hours <= 0) return 12
    if (hours >= 13) return 1
    return hours
{'fraction_non_alphanumeric': 0.10683962264150944, 'fraction_numerical': 0.006603773584905661, 'mean_word_length': 3.670704845814978, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5096791', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1372, 'n_words': 333}