import toDate from '../toDate/index' ; import setMonth from '../setMonth/index' ; import toInteger from '../_lib/toInteger/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; import type { DateValues } from '../types' ; name category summary description param { Date | Number } date param values param { Number } values . year param { Number } values . month param { Number } values . date param { Number } values . hours param { Number } values . minutes param { Number } values . seconds param { Number } values . milliseconds returns { Date } throws throws example example export default function set ( dirtyDate , values ) { requiredArgs ( 2 , arguments ) ; if ( typeof values !== 'object' || values === null ) { throw new RangeError ( 'values parameter must be an object' ) ; } let date = toDate ( dirtyDate ) ; if ( isNaN ( date . getTime ( ) ) ) { return new Date ( NaN ) ; } if ( values . year != null ) { date . setFullYear ( values . year ) ; } if ( values . month != null ) { date = setMonth ( date , values . month ) ; } if ( values . date != null ) { date . setDate ( toInteger ( values . date ) ) ; } if ( values . hours != null ) { date . setHours ( toInteger ( values . hours ) ) ; } if ( values . minutes != null ) { date . setMinutes ( toInteger ( values . minutes ) ) ; } if ( values . seconds != null ) { date . setSeconds ( toInteger ( values . seconds ) ) ; } if ( values . milliseconds != null ) { date . setMilliseconds ( toInteger ( values . milliseconds ) ) ; } return date ; }