hoursToSeconds.js 756 B

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