GlideSchedule

Midhun1
Giga Guru

I want to know how to use

GlideSchedule

The problem here is timezone (how to specify or load for a specific schedule)

var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', 'US/Pacific');

and

var startDate = new GlideDateTime('2014-10-25 08:00:00');

var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', 'UTC');

gs.info(glideSchedule.whenNext(startDate));

6 REPLIES 6

Hi Midhun,



Consider this scenario:


        You have to determine for a particular schedule, how much time is left for the next schedule for different time zones from a given start date.



So in this case, you would have to change the timezone for a schedule and then check the duration:


                  var schedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae');


                  schedule.setTimeZone('US/Pacific');


                 


                  var startDate = new GlideDateTime('2014-10-25 08:00:00');


                  gs.print("Next start date according to time zone - "+schedule.getTimeZone()+" - would be after :: "+schedule.whenNext(startDate));




                  schedule.setTimeZone('UTC');


                  gs.print("Next start date according to time zone : - "+schedule.getTimeZone()+" - would be after :: "+schedule.whenNext(startDate));



Result:


                  *** Script: Next start date according to time zone - US/Pacific - would be after :: 198000000


                  *** Script: Next start date according to time zone : - UTC - would be after :: 172800000



Note: There may be a different way of implementing this scenario. I have just used it to explain the method setTimeZone().



Thanks,


Shivangi


Midhun1
Giga Guru

Looping



Can you please explain the below API:



var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', 'US/Pacific');



and



This method   setTimeZone(String tz):


var schedule = new GlideSchedule();


schedule.setTimeZone('US/Pacific');