I need to calculate due date / end date for SLAs. As input values I have the start date and a timespan (in minutes). This calculation needs to take into account business hours, weekends, and holidays.
I've seen a lot of examples where the input is start date and end date, but have been struggling finding anything similar to the above input values.
Is there an elegant solution to this problem? Is there a way to calculate due date without using a loop? I can't think of a way to do the calculation without doing something similar to the following terrible algorithm:
- Create a return variable "due date" and set it to input variable "start date"
- Create a control variable "used minutes" and set it to 0
- Create a loop with the condition "used minutes" <= "input timespan"
- Inside the loop, add a second to the "due date" return variable
- Inside the loop, check if the second is within hours of operation (checking business hours, weekends, and holidays). If so, increment control variable "used minutes" by 1.
- Upon exiting the loop, return variable "due date"
Aucun commentaire:
Enregistrer un commentaire