UNPKG

774 BJavaScriptView Raw
1import { minutesInHour } from "./constants.mjs";
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 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
12 *
13 * @param hours - number of hours to be converted
14 *
15 * @returns The number of hours converted in minutes
16 *
17 * @example
18 * // Convert 2 hours to minutes:
19 * const result = hoursToMinutes(2)
20 * //=> 120
21 */
22export function hoursToMinutes(hours) {
23 return Math.trunc(hours * minutesInHour);
24}
25
26// Fallback for modularized imports:
27export default hoursToMinutes;