Thanks James, this is an excellent example!
I was looking for an example of workshift_work2abs but didn't find one, so I wrote a version that calculates the day of week from the unix epoch. HerramientasIT either of these methods should work. If you do use the workshift method you might need to define a new workshift if already using the regular workshift.
chg::zchg_check_start_date(...)
{
string string_method, string_alert;
date date_future;
int int_now, int_future, int_scheduled_start_date, int_dow, int_epoch_dow, int_secs_per_day;
string_method="chg::zchg_check_start_date";
logf(MILESTONE, "%s started", string_method);
int_now = now();
int_future = int_now + 259200;
date_future = (date)int_future;
int_epoch_dow = 3;
int_secs_per_day = 86400;
int_dow = ((int_future / int_secs_per_day) + int_epoch_dow) % 7;
if(int_dow == 6){
int_future += 86400*2;
date_future = (date)int_future;
}
else if(int_dow == 0){
int_future += 86400;
date_future = (date)int_future;
}
logf(MILESTONE, "Dow: %d", (int)int_dow);
logf(MILESTONE, "Date: %s", (string)date_future);
int_scheduled_start_date = (int)sched_start_date;
logf(MILESTONE, "Now: %d, future: %d", int_now, int_future);
logf(MILESTONE, "sched_start_date: %d", sched_start_date);
if (int_scheduled_start_date < int_future) {
set_error(1);
string_alert = format("The Scheduled Start Date must be at least 72 hours in the future and not fall on a Saturday or Sunday; please choose date/time after %s.", (string)date_future);
set_return_data(string_alert);
return;
}
logf(MILESTONE, "%s ended", string_method);
}