Permalink
b8f0565 Jun 6, 2014
27 lines (21 sloc) 685 Bytes
title version signature
Normalize Units
2.3.0
moment.normalizeUnits(String);

Many of Moment's functions allow the caller to pass in aliases for unit enums. For example, all of the gets below are equivalent.

var m = moment();
m.get('y');
m.get('year');
m.get('years');

If you're extending the library, you may want access to Moment's facilities for that in order to better align your functionality with Moment's.

moment.normalizeUnits('y');      // 'year'
moment.normalizeUnits('Y');      // 'year'
moment.normalizeUnits('year');   // 'year'
moment.normalizeUnits('years');  // 'year'
moment.normalizeUnits('YeARS');  // 'year'