import { DurationInput , DateInput } from './types' ; import { addMonths } from './lib/dateUtils' ; import { parse } from './parse' ; example export const apply = ( date , duration ) : Date => { const parsedDate = new Date ( date ) ; const { years , months , weeks , days , hours , minutes , seconds , milliseconds , } = parse ( duration ) ; addMonths ( parsedDate , ( years * 12 ) + months ) ; parsedDate . setDate ( parsedDate . getDate ( ) + ( weeks * 7 ) + days ) ; parsedDate . setHours ( parsedDate . getHours ( ) + hours , parsedDate . getMinutes ( ) + minutes , parsedDate . getSeconds ( ) + seconds , parsedDate . getMilliseconds ( ) + milliseconds ) ; return parsedDate ; } ;