monthsToQuarters.cjs 727 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. exports.monthsToQuarters = monthsToQuarters;
  3. var _index = require("./constants.cjs");
  4. /**
  5. * @name monthsToQuarters
  6. * @category Conversion Helpers
  7. * @summary Convert number of months to quarters.
  8. *
  9. * @description
  10. * Convert a number of months to a full number of quarters.
  11. *
  12. * @param months - The number of months to be converted.
  13. *
  14. * @returns The number of months converted in quarters
  15. *
  16. * @example
  17. * // Convert 6 months to quarters:
  18. * const result = monthsToQuarters(6)
  19. * //=> 2
  20. *
  21. * @example
  22. * // It uses floor rounding:
  23. * const result = monthsToQuarters(7)
  24. * //=> 2
  25. */
  26. function monthsToQuarters(months) {
  27. const quarters = months / _index.monthsInQuarter;
  28. return Math.trunc(quarters);
  29. }