UNPKG

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