The CreatorCon Call for Content is officially open! Get started here.

Output of business days with holidays glideschedule

Mark Cummins
Tera Contributor

Hello, I'm trying to understand how business days work using the 8 - 5 weekdays excluding holidays schedule. I'm not getting the expected output from a simple test background script.  

 

var startDate = new GlideDateTime('2023-07-03 20:00:00');
// 9 buiness hours
var days = 1;
days = days * 9;
var dur = new GlideDuration(60 * 60 * 1000 * days);
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); // 8-5 workdays excluding holidays
var dueDate = schedule.add(startDate, dur);
gs.print(dueDate.getDate());
gs.print(dueDate.getTime());
gs.print(dueDate.getDate().getDisplayValue());
gs.print(dueDate.getTime().getDisplayValue());

 

It does not skip over July 4th, which is an excluded holiday in that glide schedule. Is there a reason why?

1 ACCEPTED SOLUTION

Shekhar Navhak1
Kilo Sage

Hi @Mark Cummins ,

 

I ran the same script and got correct result as below:

ShekharNavhak1_0-1688969297979.png

 

Can you please check the Holiday entry mentioned in schedule? is it repeated or not?

 

 

Please mark the answer correct/helpful based on Impact.
Regards, Shekhar

View solution in original post

3 REPLIES 3

Shekhar Navhak1
Kilo Sage

Hi @Mark Cummins ,

 

I ran the same script and got correct result as below:

ShekharNavhak1_0-1688969297979.png

 

Can you please check the Holiday entry mentioned in schedule? is it repeated or not?

 

 

Please mark the answer correct/helpful based on Impact.
Regards, Shekhar

Hi @Shekhar Navhak1 ,

 

GlideSchedule is returning values which is considering 24 hrs as 1 day.

If i want result as per my schedule considering 9 hrs as 1 day how that can be achieve.

 

Below is my code,

 

var startDate = new GlideDateTime('2024-12-18 10:01:06');
var endDate = new GlideDateTime('2024-12-30 14:22:10');
var schedule = new GlideSchedule();

schedule.load('1b499f9cf78e6d105ef541b84851e048'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue());
 
Schedule is from 8-5 and has 3 holidays in between giving me output as 2 01:21:04
 
Expected is : 5 4:21:00 as per schedule
 

Mark Cummins
Tera Contributor

Hi Shekhar, thank you for the help, the scheduled entry were not blank and only repeated until 2021. Now the output is correct.