fix a end time problem: end time generated may exceed parameter time