UNPKG

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