Cell A1 has the start Date and time
Cell B1 has the End date and time
Cell C1 has the person name: A or B or C
A's working hours is 8 am to 5 pm, B's working hours is 11 am to 8 pm, C's working hours is 5 pm to 2 am

In cell A2, i need to calculate the time difference between A1 and B1 (B1-A1) considering the person's name in cell C1 and their working hours.

Example:
A1= Start date and time: 3/30/2017 6 PM
B1= End date and time: 3/31/2017 1:30 PM
if C1 = person B
the time difference in A2 should be: 4:30 hours (since B's working hours is 11 am to 8 pm)
and vice versa..