UNPKG

806 BJavaScriptView Raw
1"use strict";
2exports.hoursToMilliseconds = hoursToMilliseconds;
3var _index = require("./constants.js");
4
5/**
6 * @name hoursToMilliseconds
7 * @category Conversion Helpers
8 * @summary Convert hours to milliseconds.
9 *
10 * @description
11 * Convert a number of hours to a full number of milliseconds.
12 *
13 * @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).
14 *
15 * @param hours - number of hours to be converted
16 *
17 * @returns The number of hours converted to milliseconds
18 *
19 * @example
20 * // Convert 2 hours to milliseconds:
21 * const result = hoursToMilliseconds(2)
22 * //=> 7200000
23 */
24function hoursToMilliseconds(hours) {
25 return Math.trunc(hours * _index.millisecondsInHour);
26}