MediaWiki:Gadget-morebits.js: Difference between revisions

Content deleted Content added
Repo at 97b8143: Minor jsdoc fixes and cleanup
Repo at f27c7b2: Make unitMap available through Morebits.date.unitMap
Line 1,665:
return [match[5], month, match[3], match[1], match[2]];
}
};
 
/**
// * mapping timeMap units with getter/setter function names, for `add` and `subtract`
* methods.
*
* @memberof Morebits.date
* @type {object.<string, string>}
*/
Morebits.date.unitMap = {
seconds: 'Seconds',
minutes: 'Minutes',
hours: 'Hours',
days: 'Date',
months: 'Month',
years: 'FullYear'
};
 
Line 1,731 ⟶ 1,747:
*/
add: function(number, unit) {
unit = unit.toLowerCase(); // normalize
// mapping time units with getter/setter function names
var unitMap = {Morebits.date.unitMap;
seconds: 'Seconds',
minutes: 'Minutes',
hours: 'Hours',
days: 'Date',
months: 'Month',
years: 'FullYear'
};
var unitNorm = unitMap[unit] || unitMap[unit + 's']; // so that both singular and plural forms work
if (unitNorm) {