All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.globalize.src.relative-time.format.js Maven / Gradle / Ivy

There is a newer version: 1.2.2.1-jre17
Show newest version
define([
    "../common/format-message"
], function (formatMessage) {

    /**
     * format( value, numberFormatter, pluralGenerator, properties )
     *
     * @value [Number] The number to format
     *
     * @numberFormatter [String] A numberFormatter from Globalize.numberFormatter
     *
     * @pluralGenerator [String] A pluralGenerator from Globalize.pluralGenerator
     *
     * @properties [Object] containing relative time plural message.
     *
     * Format relative time.
     */
    return function (value, numberFormatter, pluralGenerator, properties) {

        var relativeTime,
            message = properties["relative-type-" + value];

        if (message) {
            return message;
        }

        relativeTime = value <= 0 ? properties["relativeTime-type-past"]
            : properties["relativeTime-type-future"];

        value = Math.abs(value);

        message = relativeTime["relativeTimePattern-count-" + pluralGenerator(value)];
        return formatMessage(message, [numberFormatter(value)]);
    };

});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy