Algorithm to figure out appointment times?
Posted
by
Rachel
on Programmers
See other posts from Programmers
or by Rachel
Published on 2012-07-10T16:10:14Z
Indexed on
2012/07/10
21:24 UTC
Read the original article
Hit count: 367
algorithms
I have a weird situation where a client would like a script that automatically sets up thousands of appointments over several days. The tricky part is the appointments are for a variety of US time zones, and I need to take the consumer's local time zone into account when generating appointment dates and times for each record.
Appointment Rules:
Appointments should be set from 8AM to 8PM Eastern Standard Time, with breaks from 12P-2P and 4P-6P. This leaves a total of 8 hours per day available for setting appointments.
Appointments should be scheduled 5 minutes apart. 8 hours of 5-minute intervals means 96 appointments per day.
There will be 5 users at a time handling appointments. 96 appointments per day multiplied by 5 users equals 480, so the maximum number of appointments that can be set per day is 480.
Now the tricky requirement: Appointments are restricted to 8am to 8pm in the consumer's local time zone. This means that the earliest time allowed for each appointment is different depending on the consumer's time zone:
- Eastern: 8A
- Central: 9A
- Mountain: 10A
- Pacific: 11A
- Alaska: 12P
- Hawaii or Undefined: 2P
- Arizona: 10A or 11A based on current Daylight Savings Time
Assuming a data set can be several thousand records, and each record will contain a timezone value, is there an algorithm I could use to determine a Date and Time for every record that matches the rules above?
© Programmers or respective owner