I have a customer that wanted to let a user schedule 4 BUSINESS DAYS out. I couldn't find a saner way to do this so here's my function.
- date helper.bizDays(int days)
- {
- iterator = helper.iterator();
- time = zoho.currentdate;
- for each n in iterator
- {
- if (input.days > 0)
- {
- time = time.addDay(1);
- if (time.getDayOfWeek() == 7)
- {
- time = time.addDay(2);
- }
- else if (time.getDayOfWeek() == 1)
- {
- time = time.addDay(1);
- }
- }
- input.days = (input.days - 1);
- }
- return time;
- }
I wanted to make note that I'm using an "iterator" function that I use all the time for a "while" loop replacement. Zoho doesn't let you do condition based loops because it doesn't want people creating infinite loops. (I think they said they were going to add a while expression because they had the 5k statement limit in place, but they haven't yet)
The iterator is just a list of 0's that can been "for each'd" over.
- list helper.iterator()
- {
- i = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- return i;
- }