fix bug of calculating datetime