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

Kalaiarasan Pus
Giga Sage

I believe the second parameter specifies the timezone and should be given as string. So I don't any issue with what you have done.


Midhun1
Giga Guru

Hi Kalaiarasan,



Thanks for the reply!!


But we tried to set but it is not getting updated in the schedule.


shivangip
Kilo Contributor

Hi Midhun,



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



This code will help you create a schedule object with the schedule and time zone that you have mentioned(US/Pacific). After this, when you execute different methods in the API for this object, they will give you the result according to the time zone that you selected.



Note: Updating the time zone of the schedule through this code will not update the time zone value that is set for the schedule in the Schedules(cmn_schedule) table.




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


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


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




This code will return the number of milliseconds until the start time of the next schedule item is reached as per the time zone you have specified in line#2.



Thanks,


Shivangi


Hi Shivangi,



Thanks for the response and i understood the below:



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


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


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



But still need some   more clarification regarding :




This method   setTimeZone(String tz):


var schedule = new GlideSchedule();


schedule.setTimeZone('US/Pacific');