UNPKG

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