UNPKG

589 BJavaScriptView Raw
1import { minutesInHour } from "./constants.js";
2
3/**
4 * @name hoursToMinutes
5 * @category Conversion Helpers
6 * @summary Convert hours to minutes.
7 *
8 * @description
9 * Convert a number of hours to a full number of minutes.
10 *
11 * @param hours - number of hours to be converted
12 *
13 * @returns The number of hours converted in minutes
14 *
15 * @example
16 * // Convert 2 hours to minutes:
17 * const result = hoursToMinutes(2)
18 * //=> 120
19 */
20export function hoursToMinutes(hours) {
21 return Math.trunc(hours * minutesInHour);
22}
23
24// Fallback for modularized imports:
25export default hoursToMinutes;