UNPKG

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