A team responding to customers' requests may only be available during certain hours during the week. These open hours could be for example:
- Monday: 9am to 5pm
- Tuesday: 9am to 5pm
- Wednesday: 9am to 5pm
- Thursday: 9am to 5pm
- Friday: 9am to 5pm
- Saturday: 9am to 12am
- Sunday: closed
If a request is made Tuesday at 4h45pm and the team replies on Wednesday at 10am, we will consider the response time to be 1h15.
Imagine that you have a UI letting an administrator define open hours. What format should the API accept?
Write a function (in a language of you choosing): responseTime(time1, time2, openHours)
where:
time1
andtime2
are 2 UNIX timestamps.openHours
is the data structure you previously defined.- the returned value is the difference between
time1
andtime2
, excluding time where the team was not available.
For example, with the previous example, responseTime(<monday 8am>, <monday 10am>, oh)
would be only 1 hour.