This server class provides methods for performing operations on SimpleSchedule objects, such as getting schedule name; determining if the current time value is working time or not or setting time zone for the schedule.
SimpleSchedule(id,
timeZonetimeZoneTitle)
Instantiates a new SimpleSchedule object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
id | IntegerString | Y | N |
timezonetimeZoneTitle | String | N | 'UTC' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | schedule |
---|
linenumbers | true |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710', 'UTC'); |
duration(
startDatestartDateTime,
endDateendDateTime)
This method determines elapsed time in seconds in the schedule between two date-time values, using schedule time zone or, if not specified, the session time zone.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
startDatestartDateTime | SimpleDateTime | Y | N |
endDateendDateTime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|
SimpleDuration | The difference between the two time values. |
Example:
Code Block |
---|
|
letconst startDatetime = new SimpleDateTime('2019-10-25 08:00:00');
letconst endDatetime = new SimpleDateTime('2019-10-29 08:00:00');
letconst schedule = new SimpleSchedule('157165292607666710');
letconst duration = schedule.duration(startDatetime, endDatetime);
ss.info(duration.getValue()); |
load(sysId,
timeZonetimeZoneTitle)
This method initializes a schedule by the sys_id.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
sysId |
IntegertimeZonetimeZoneTitle | String (empty string by default) | N | '' |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
|
letconst schedule = new SimpleSchedule();
schedule.load('157165292607666710'); |
getname()
This method returns the schedule name.
Return:
Type | Description |
---|
String | The schedule name. |
Example:
Code Block |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.getName()); // Info: 8x5 excluding Russian Holidays |
isValid()
This method determines if the specified schedule is valid.
Return:
Type | Description |
---|
Boolean | This method returns TRUE if the schedule is valid; otherwise, it returns FALSE. |
Example:
Code Block |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.isValid()); // Info: true |
isInSchedule(
timedatetime)
This method determines if the given datetime is within the current schedule.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
timedatetime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|
Boolean | This method returns TRUE if the specified datetime is in schedule; otherwise, it returns FALSE. |
Example:
Code Block |
---|
language | js |
---|
title | isInSchedule |
---|
|
letconst datetime = new SimpleDateTime();
letconst schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.isInSchedule(datetime)); // Info: false |
setTimeZone(
timeZonetimeZoneTitle)
This method sets a time zone.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
timeZone
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | setTimeZone |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710');
schedule.setTimeZone('US/Central'); |
whenNext(
timedatetime,
timeZonetimeZoneTitle)
This method determines how much time (in seconds) is left until next schedule item starts.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
timedatetime | SimpleDateTime | Y | N |
timeZonetimeZoneTitle | | N | '' |
Return:
Type | Description |
---|
SimpleDuration | The SimpleDuration object |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | whenNext |
---|
linenumbers | true |
---|
|
letconst startDatetime = new SimpleDateTime('2019-10-25 08:00:00');
letconst schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.whenNext(startDatetime)); |
whenWillExpire(
startDatestartDateTime, finalWorkingSeconds)
This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passes.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
startDate | | Y | N |
finalWorkingSeconds | Integer | Y | N |
Return:
Type | Description |
---|
SimpleDateTime | The SimpleDateTime object |
Example:
Code Block |
---|
language | js |
---|
title | whenWillExpire |
---|
|
const startDatetime = new SimpleDateTime('2019-10-25 08:00:00'); // UTC datetime
const finalWorkingSeconds = 600; // 10 minutes
letconst schedule = new SimpleSchedule('157165292607666710'); // schedulesschedule ID
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 2019-10-25 08:10:00 |