]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/blame - javascript/util.js
convert to MV3
[chrome-ext/clearhistory-advance-fork.git] / javascript / util.js
CommitLineData
a5409a6b
MF
1// Copyright 2011 Google Inc. All Rights Reserved.
2
3/**
4 * @fileoverview Some basic, useful utility functions.
5 */
6
a5409a6b
MF
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 */
c930a5d6 12export function getUnitsForTime(time) {
a5409a6b
MF
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}