• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with an ETA algorithm

[eluser]Bogdan Tanase[/eluser]
Hi guys,

I hope someone can give me a little hint on how should I implement the following feature:

I want to create an estimated time for completion feature for a production line.

The following data is provided:

- total number of units that need to be produced ($total_units)
- Start time(date) of production ($start_time)
- no of units per minute ($units_minute)

so far there's no problem. We simply divide the number of units with no of units per minute and we get the total no of minutes necessary for completion. Then we add that value to start time and we get the finish time.

However, we need to take into consideration rest periods (or breaks) and also the non-working time.

so, I defined the rest periods in a mysql table:

break_start_time | break_end_time

10:00 10:15
12:00 12:30
15:00 15:15
17:30 23:59 // non working hours
00:00 08:00 // non working hours

and if the calculated finish time overlaps a break period, I add the break time to the finish time.

All goes well until I hit midnight, because the time resets to 0:00... and here I'm stuck Sad

How would you do such a feature?


PS: ideally the function should take into consideration weekends, legal holidays, etc, but I thought I'd take it easy Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.