yearsToQuarters.js 600 B

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