UNPKG

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