<commit_before>// @flow

import React, {Component, PropTypes} from 'react';
import moment from 'moment';
require('moment-duration-format');

const { number, oneOfType, string} = PropTypes;

/**
 * Displays a millisecond duration as text in moment-duration-format's "humanize()" format,
 * e.g. "a few seconds", "2 hours", etc.
 * Also displays tooltip with more precise duration in "mos, days, hours, mins, secs" format.
 * Tooltip text can be overridden via "hint" property.
 *
 * Properties:
 * "millis": number or string.
 * "hint": string to use for tooltip.
 */
export class TimeDuration extends Component {
    render() {
        const millis = !isNaN(this.props.millis) ?
            parseInt(this.props.millis) :
            this.props.millis;

        if (!isNaN(millis)) {
            const duration = moment.duration(millis).humanize();

            const hint = this.props.hint ?
                this.props.hint :
                moment.duration(millis).format("M [mos], d [days], h[h], m[m], s[s]");

            return (
                <span title={hint}>{duration}</span>
            );
        }

        return (<span>-</span>);
    }
}
<commit_msg>[UX-297] simplify parseInt logic<commit_after>// @flow

import React, {Component, PropTypes} from 'react';
import moment from 'moment';
require('moment-duration-format');

const { number, oneOfType, string} = PropTypes;

/**
 * Displays a millisecond duration as text in moment-duration-format's "humanize()" format,
 * e.g. "a few seconds", "2 hours", etc.
 * Also displays tooltip with more precise duration in "mos, days, hours, mins, secs" format.
 * Tooltip text can be overridden via "hint" property.
 *
 * Properties:
 * "millis": number or string.
 * "hint": string to use for tooltip.
 */
export class TimeDuration extends Component {
    render() {
        const millis = parseInt(this.props.millis);

        if (!isNaN(millis)) {
            const duration = moment.duration(millis).humanize();

            const hint = this.props.hint ?
                this.props.hint :
                moment.duration(millis).format("M [mos], d [days], h[h], m[m], s[s]");

            return (
                <span title={hint}>{duration}</span>
            );
        }

        return (<span>-</span>);
    }
}

{'fraction_non_alphanumeric': 0.1429197720298115, 'fraction_numerical': 0.0021920210434020165, 'mean_word_length': 2.5489891135303266, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, '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': '7229812', 'n_tokens_mistral': 689, 'n_tokens_neox': 663, 'n_words': 201}