update end datetime when changing start datetime
reformat code