]> git.wh0rd.org Git - chrome-ext/clearhistory-advance-fork.git/blob - javascript/util.js
options: move unique functions in here
[chrome-ext/clearhistory-advance-fork.git] / javascript / util.js
1 // Copyright 2011 Google Inc. All Rights Reserved.
2
3 /**
4  * @fileoverview Some basic, useful utility functions.
5  */
6
7 /**
8  * Provides units for time, given in hours, as hours or days.
9  * @param {number} time The time, in hours.
10  * @return {Object} The time and units of time (pluralized and localized).
11  */
12 function getUnitsForTime(time) {
13   var units = 'hour';
14   if (time >= 24) {
15     units = 'day';
16     time = time / 24;
17   }
18   units = chrome.i18n.getMessage(units + (time === 1 ? '' : 's') + 'String');
19   return {
20     time: time,
21     units: units
22   };
23 }