quartersToMonths.js 632 B

12345678910111213141516171819202122232425
  1. import { monthsInQuarter } from "./constants.js";
  2. /**
  3. * @name quartersToMonths
  4. * @category Conversion Helpers
  5. * @summary Convert number of quarters to months.
  6. *
  7. * @description
  8. * Convert a number of quarters to a full number of months.
  9. *
  10. * @param quarters - The number of quarters to be converted
  11. *
  12. * @returns The number of quarters converted in months
  13. *
  14. * @example
  15. * // Convert 2 quarters to months
  16. * const result = quartersToMonths(2)
  17. * //=> 6
  18. */
  19. export function quartersToMonths(quarters) {
  20. return Math.trunc(quarters * monthsInQuarter);
  21. }
  22. // Fallback for modularized imports:
  23. export default quartersToMonths;