index.js 683 B

123456789101112131415161718192021222324
  1. import requiredArgs from "../_lib/requiredArgs/index.js";
  2. import { secondsInHour } from "../constants/index.js";
  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 {number} hours - number of hours to be converted
  12. *
  13. * @returns {number} the number of hours converted in seconds
  14. * @throws {TypeError} 1 argument required
  15. *
  16. * @example
  17. * // Convert 2 hours to seconds:
  18. * const result = hoursToSeconds(2)
  19. * //=> 7200
  20. */
  21. export default function hoursToSeconds(hours) {
  22. requiredArgs(1, arguments);
  23. return Math.floor(hours * secondsInHour);
  24. }