<commit_before>/* The equivalent to jQuery.timeago for react.
 *
 * TimeAgo returns a span containing the amount of time (in English) that has
 * passed since `time`.
 *
 * Takes:
 *     time: an ISO 8601 timestamp
 *     refreshMillis: how often to update, in milliseconds
 *
 * Example:
 *
 *     return <a href={khanAcademy}><TimeAgo time={date} /></a>
 */

var React = require("react");
var SetIntervalMixin = require("./set-interval-mixin.jsx");
var moment = require("moment");

// TODO(joel) i18n
var TimeAgo = React.createClass({
    mixins: [SetIntervalMixin],
    render: function() {
        return <span>{moment(this.props.time).fromNow()}</span>;
    },
    componentDidMount: function() {
        var interval = this.props.time || 60000;
        // TODO(joel) why did I have to bind forceUpdate?
        this.setInterval(this.forceUpdate.bind(this), interval);
    }
});

module.exports = TimeAgo;<commit_msg>Use refreshMillis to set the interval in TimeAgo <commit_after>/* The equivalent to jQuery.timeago for react.
 *
 * TimeAgo returns a span containing the amount of time (in English) that has
 * passed since `time`.
 *
 * Takes:
 *     time: an ISO 8601 timestamp
 *     refreshMillis: how often to update, in milliseconds
 *
 * Example:
 *
 *     return <a href={khanAcademy}><TimeAgo time={date} /></a>
 */

var React = require("react");
var SetIntervalMixin = require("./set-interval-mixin.jsx");
var moment = require("moment");

// TODO(joel) i18n
var TimeAgo = React.createClass({
    mixins: [SetIntervalMixin],
    render: function() {
        return <span>{moment(this.props.time).fromNow()}</span>;
    },
    componentDidMount: function() {
        var interval = this.props.refreshMillis || 60000;
        // TODO(joel) why did I have to bind forceUpdate?
        this.setInterval(this.forceUpdate.bind(this), interval);
    }
});

module.exports = TimeAgo;
{'fraction_non_alphanumeric': 0.13869772366331393, 'fraction_numerical': 0.011646373742721016, 'mean_word_length': 3.3851508120649654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1014178', 'n_tokens_mistral': 602, 'n_tokens_neox': 582, 'n_words': 167}