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

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

The newest version!
define(function () {

    /**
     * properties( unit, cldr, options )
     *
     * @unit [String] eg. "day", "week", "month", etc.
     *
     * @cldr [Cldr instance].
     *
     * @options [Object]
     * - form: [String] eg. "short" or "narrow". Or falsy for default long form.
     *
     * Return relative time properties.
     */
    return function (unit, cldr, options) {

        var form = options.form,
            raw, properties, key, match;

        if (form) {
            unit = unit + "-" + form;
        }

        raw = cldr.main(["dates", "fields", unit]);
        properties = {
            "relativeTime-type-future": raw["relativeTime-type-future"],
            "relativeTime-type-past": raw["relativeTime-type-past"]
        };
        for (key in raw) {
            if (raw.hasOwnProperty(key)) {
                match = /relative-type-(-?[0-9]+)/.exec(key);
                if (match) {
                    properties[key] = raw[key];
                }
            }
        }

        return properties;
    };

});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy