yearsToMonths.cjs 562 B

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