12345678910111213141516171819202122232425262728293031 |
- import { secondsInHour } from "./constants.js";
- /**
- * @name secondsToHours
- * @category Conversion Helpers
- * @summary Convert seconds to hours.
- *
- * @description
- * Convert a number of seconds to a full number of hours.
- *
- * @param seconds - The number of seconds to be converted
- *
- * @returns The number of seconds converted in hours
- *
- * @example
- * // Convert 7200 seconds into hours
- * const result = secondsToHours(7200)
- * //=> 2
- *
- * @example
- * // It uses floor rounding:
- * const result = secondsToHours(7199)
- * //=> 1
- */
- export function secondsToHours(seconds) {
- const hours = seconds / secondsInHour;
- return Math.trunc(hours);
- }
- // Fallback for modularized imports:
- export default secondsToHours;
|