hoursToMinutes.mjs 774 B

123456789101112131415161718192021222324252627
  1. import { minutesInHour } from "./constants.mjs";
  2. /**
  3. * @name hoursToMinutes
  4. * @category Conversion Helpers
  5. * @summary Convert hours to minutes.
  6. *
  7. * @description
  8. * Convert a number of hours to a full number of minutes.
  9. *
  10. * @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).
  11. *
  12. * @param hours - number of hours to be converted
  13. *
  14. * @returns The number of hours converted in minutes
  15. *
  16. * @example
  17. * // Convert 2 hours to minutes:
  18. * const result = hoursToMinutes(2)
  19. * //=> 120
  20. */
  21. export function hoursToMinutes(hours) {
  22. return Math.trunc(hours * minutesInHour);
  23. }
  24. // Fallback for modularized imports:
  25. export default hoursToMinutes;