Date calculation algorithm

Posted by Julian Cuevas on Programmers See other posts from Programmers or by Julian Cuevas
Published on 2012-12-11T17:04:03Z Indexed on 2012/12/11 17:22 UTC
Read the original article Hit count: 287

Filed under:
|
|

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:

  1. During weekdays, work with business hours (7:00 AM to 5:00 PM)
  2. Work on Saturdays from 7:00 AM to 2:00 PM
  3. 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.

© Programmers or respective owner

Related posts about php

Related posts about math