Fixed wrong date for split working periods

When a working period was being split into two (due to time zone
difference), the time object representing the end date of the first
object was not referring to midnight of the correct date. This was
leading to the duration of the working period being negative, which led
to an infinite loop in the calculation of the due date. This is now
fixed, and checks are in place to make sure that any other potential
negative durations do not cause a hang and flash a warning to the user.