Allowing working periods to end on midnight

Needed to allow for the special case of working periods ending on
midnight, i.e. the start of the next day. This is now implemented.