<commit_before>/**
 * Time unit conversion utility methods.
 *
 * @example <pre>  (5).minutes()
 *   300000
 *
 *   (5).minutes().inSeconds()
 *   300
 *
 *   (5).minutes().ago()
 *   Fri Oct 31 2008 12:54:31 GMT+0100 (MEZ)
 *
 *   (5).minutes().fromNow()
 *   Fri Oct 31 2008 13:04:34 GMT+0100 (MEZ)</pre>
 */

module.shared = true;

Object.defineProperty(Number.prototype, 'format', {
    value: function(fmt, locale) {
        var symbols;
        if (locale != null) {
            symbols = new java.text.DecimalFormatSymbols(locale);
        } else {
            symbols = new java.text.DecimalFormatSymbols();
        }
        var df = new java.text.DecimalFormat(fmt || "###,##0.##", symbols);
        return df.format(0 + this); // addition with 0 prevents exception
    }
});

Object.defineProperty(Number.prototype, 'millis', {
    value: function() {
        return this;
    }
});

Object.defineProperty(Number.prototype, 'seconds', {
    value: function() {
        return this * 1000;
    }
});

Object.defineProperty(Number.prototype, 'minutes', {
    value: function() {
        return this * 60000;
    }
});

Object.defineProperty(Number.prototype, 'hours', {
    value: function() {
        return this * 3600000;
    }
});

Object.defineProperty(Number.prototype, 'days', {
    value: function() {
        return this * 86400000;
    }
});

Object.defineProperty(Number.prototype, 'weeks', {
    value: function() {
        return this * 604800000;
    }
});

Object.defineProperty(Number.prototype, 'months', {
    value: function() {
        return this * 2592000000;
    }
});

Object.defineProperty(Number.prototype, 'years', {
    value: function() {
        return this * 31536000000;
    }
});


Object.defineProperty(Number.prototype, 'inMillis', {
    value: function() {
        return this;
    }
});

Object.defineProperty(Number.prototype, 'inSeconds', {
    value: function() {
        return this / 1000;
    }
});

Object.defineProperty(Number.prototype, 'inMinutes', {
    value: function() {
        return this / 60000;
    }
});

Object.defineProperty(Number.prototype, 'inHours', {
    value: function() {
        return this / 3600000;
    }
});

Object.defineProperty(Number.prototype, 'inDays', {
    value: function() {
        return this / 86400000;
    }
});

Object.defineProperty(Number.prototype, 'inWeeks', {
    value: function() {
        return this / 604800000;
    }
});

Object.defineProperty(Number.prototype, 'inMonths', {
    value: function() {
        return this / 2592000000;
    }
});

Object.defineProperty(Number.prototype, 'inYears', {
    value: function() {
        return this / 31536000000;
    }
});


Object.defineProperty(Number.prototype, 'ago', {
    value: function() {
        return new Date(Date.now() - this);
    }
});

Object.defineProperty(Number.prototype, 'fromNow', {
    value: function() {
        return new Date(Date.now() + this);
    }
});

Object.defineProperty(Number.prototype, 'before', {
    value: function(date) {
        return new Date(date.getTime() - this);
    }
});

Object.defineProperty(Number.prototype, 'after', {
    value: function(date) {
        return new Date(date.getTime() + this);
    }
});


Object.defineProperty(Number.prototype, 'times', {
    value: function(fun) {
        for (var i = 0; i < this; i++) {
            fun(i);
        }
    }
});<commit_msg>Remove date conversion function from core/number<commit_after>/**
 * @fileoverview Adds useful methods to the JS Number type.
 */

module.shared = true;

/**
 * Format a number using java.text.DecimalFormat.
 */
Object.defineProperty(Number.prototype, 'format', {
    value: function(fmt, locale) {
        var symbols;
        if (locale != null) {
            symbols = new java.text.DecimalFormatSymbols(locale);
        } else {
            symbols = new java.text.DecimalFormatSymbols();
        }
        var df = new java.text.DecimalFormat(fmt || "###,##0.##", symbols);
        return df.format(0 + this); // addition with 0 prevents exception
    }
});

/**
 * Invoke a function n times with n the value of this number.
 */
Object.defineProperty(Number.prototype, 'times', {
    value: function(fun) {
        for (var i = 0; i < this; i++) {
            fun(i);
        }
    }
});
{'fraction_non_alphanumeric': 0.15595043254617721, 'fraction_numerical': 0.03764320785597381, 'mean_word_length': 2.622353937341236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4855395', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1311, 'n_words': 292}