Generalized setDuration with double input.