I'm working on a project to schedule a machine shop, basically I've got everything covered BUT date calculations, I've got a method called schedule (working on PHP here):
public function schedule($start_date, $duration_in_minutes)
Now my problem is, currently I'm calculating end time manually because time calculations have the following rules:
- During weekdays, work with business hours (7:00 AM to 5:00 PM)
- Work on Saturdays from 7:00 AM to 2:00 PM
- Ignore holidays (in Colombia we have A LOT of holidays)
I already have a lookup table for holidays, I also have a Java version of this algorithm that I wrote for a previous version of the project, but that one's also manual.
Is there any way to calculate an end time from a start time given duration?, my problem is that I have to consider the above rules, I'm looking for a (maybe?) math based solution, however I currently don't have the mind to devise such a solution myself.
I'll be happy to provide code samples if necessary.