Fix date and time calculation