META-INF.resources.bower_components.globalize.src.relative-time.properties.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
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;
};
});