monthsToYears.cjs 678 B

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