UNPKG

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