priorities.js (652B)
1import hasOwnProp from '../utils/has-own-prop'; 2 3var priorities = { 4 date: 9, 5 day: 11, 6 weekday: 11, 7 isoWeekday: 11, 8 dayOfYear: 4, 9 hour: 13, 10 millisecond: 16, 11 minute: 14, 12 month: 8, 13 quarter: 7, 14 second: 15, 15 weekYear: 1, 16 isoWeekYear: 1, 17 week: 5, 18 isoWeek: 5, 19 year: 1, 20}; 21 22export function getPrioritizedUnits(unitsObj) { 23 var units = [], 24 u; 25 for (u in unitsObj) { 26 if (hasOwnProp(unitsObj, u)) { 27 units.push({ unit: u, priority: priorities[u] }); 28 } 29 } 30 units.sort(function (a, b) { 31 return a.priority - b.priority; 32 }); 33 return units; 34}