Modified to allow calculation of night shifts
The following code incorporates prior comments and can handle night shifts which span over a single day (for instance: someone works from 2pm to 2am the next morning).
Another modification is that this function will return the result in minutes...