<commit_before>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import moment from 'moment'
import chrono from 'chrono-node'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker-cssmodules.css'

import styles from './DateRangeSelection.css'


class DateRangeSelection extends Component {
    constructor() {
        super()

        this.state = {
            startDateText: null,
            endDateText: null,
        }

        this.handleKeydown = this.handleKeydown.bind(this)
        this.submitDateChange = this.submitDateChange.bind(this)
    }

    componentDidMount() {
        this.refs.startDateDatePicker.refs.input.refs.input.addEventListener('keydown', e => this.handleKeydown(e, 'startDate'))
        this.refs.endDateDatePicker.refs.input.refs.input.addEventListener('keydown', e => this.handleKeydown(e, 'endDate'))
    }

    handleKeydown(event, type) {
        if (event.key === 'Enter') {
            event.stopImmediatePropagation()
            this.submitDateChange(type)
        }
    }

    submitDateChange(type) {
        if (type === 'startDate') {
            const date = moment(this.state.startDateText, 'DD-MM-YYYY')
            const nlpDate = chrono.parseDate(this.state.startDateText)

            const dateToChange = date.isValid()
                ? date.valueOf()
                : nlpDate && nlpDate.getTime()

            if (dateToChange !== this.props.startDate) this.props.onStartDateChange(dateToChange)
        } else if (type === 'endDate') {
            const date = moment(this.state.endDateText, 'DD-MM-YYYY')
            const nlpDate = chrono.parseDate(this.state.endDateText)

            const dateToChange = date.isValid()
                ? date.valueOf()
                : nlpDate && nlpDate.getTime()

            if (dateToChange !== this.props.endDate) this.props.onEndDateChange(dateToChange)
        }
    }
<commit_msg>Enable strict parsing for moment.<commit_after>import React, { Component } from 'react'
import PropTypes from 'prop-types'
import moment from 'moment'
import chrono from 'chrono-node'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker-cssmodules.css'

import styles from './DateRangeSelection.css'


class DateRangeSelection extends Component {
    constructor() {
        super()

        this.state = {
            startDateText: null,
            endDateText: null,
        }

        this.handleKeydown = this.handleKeydown.bind(this)
        this.submitDateChange = this.submitDateChange.bind(this)
    }

    componentDidMount() {
        this.refs.startDateDatePicker.refs.input.refs.input.addEventListener('keydown', e => this.handleKeydown(e, 'startDate'))
        this.refs.endDateDatePicker.refs.input.refs.input.addEventListener('keydown', e => this.handleKeydown(e, 'endDate'))
    }

    handleKeydown(event, type) {
        if (event.key === 'Enter') {
            event.stopImmediatePropagation()
            this.submitDateChange(type)
        }
    }

    submitDateChange(type) {
        if (type === 'startDate') {
            const date = moment(this.state.startDateText, 'DD-MM-YYYY', true)
            const nlpDate = chrono.parseDate(this.state.startDateText)

            const dateToChange = date.isValid()
                ? date.valueOf()
                : nlpDate && nlpDate.getTime()

            if (dateToChange !== this.props.startDate) this.props.onStartDateChange(dateToChange)
        } else if (type === 'endDate') {
            const date = moment(this.state.endDateText, 'DD-MM-YYYY', true)
            const nlpDate = chrono.parseDate(this.state.endDateText)

            const dateToChange = date.isValid()
                ? date.valueOf()
                : nlpDate && nlpDate.getTime()

            if (dateToChange !== this.props.endDate) this.props.onEndDateChange(dateToChange)
        }
    }

{'fraction_non_alphanumeric': 0.11709183673469388, 'fraction_numerical': 0.0, 'mean_word_length': 2.507155635062612, 'pattern_counts': {'":': 0, '<': 3, '<?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': '817185', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1118, 'n_words': 206}