import requiredArgs from '../_lib/requiredArgs/index' ; import type { Duration } from '../types' ; const daysInYear = 365.2425 ; name category summary description param { Duration } duration returns { number } throws example export default function milliseconds ( { years , months , weeks , days , hours , minutes , seconds , } ) { requiredArgs ( 1 , arguments ) ; let totalDays = 0 ; if ( years ) totalDays += years * daysInYear ; if ( months ) totalDays += months * ( daysInYear / 12 ) ; if ( weeks ) totalDays += weeks * 7 ; if ( days ) totalDays += days ; let totalSeconds = totalDays * 24 * 60 * 60 ; if ( hours ) totalSeconds += hours * 60 * 60 ; if ( minutes ) totalSeconds += minutes * 60 ; if ( seconds ) totalSeconds += seconds ; return Math . round ( totalSeconds * 1000 ) ; }