This server class provides methods for performing operations on SimpleSchedule objects, such as getting schedule name; determining methods are designed to work with the SimpleSchedule objects. You can use them, for example, to get a schedule name, to verify if the current time value is working time or not or setting time zone for the schedulematches with the working time, and return the difference between the two time values.
SimpleSchedule(id,
timeZonetimezoneTitle)
Instantiates Use this cinstructor to instantiate a new SimpleSchedule object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
id | IntegerString | YN | N |
timezonetimezoneTitle | String | N | 'UTC' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | scheduleSimpleSchedule |
---|
linenumbers | true |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710', 'UTC'); |
duration(
startDatestartDateTime,
endDateendDateTime)
This method determines elapsed the time in seconds difference in the schedule between two date-time SimpleDateTime values, using based on the schedule time zone or, if not specified, the session the session time zone.
Note |
---|
The passed SimpleDateTime value should be in the schedule. For verification, use the isInSchedule(datetime) method. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
startDatestartDateTime | SimpleDateTime object | Y | N |
endDateendDateTime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|
SimpleDuration | The difference between the two time values. |
Example:
Code Block |
---|
|
letconst startDatetime = new SimpleDateTime('20192022-1001-25 08:00:00');
letconst endDatetime = new SimpleDateTime('20192022-1001-29 08:00:00');
letconst schedule = new SimpleSchedule('157165292607666710161050499417811121');
let // sys_schedule.sys_id
const duration = schedule.duration(startDatetime, endDatetime);
ss.info(duration.getValue()); |
load(sysId, timeZone // Info: 1970-01-02 08:00:00 |
getName()
This method
initializes a schedule by the sys_id.Parameter(s):
Name | Type | Mandatory | Default Value |
---|
sysId | Integer | Y | N |
timeZone | String (empty string by default) | N | ''returns the name of the defined schedule.
Return:
Void | This method does not return a value
Example:
Code Block |
---|
language | js |
---|
title | loadgetName |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.loadgetName('157165292607666710')); |
getname( // Info: 8x5 excluding Russian Holidays |
isInSchedule(datetime)
This method
returns the schedule name.checks whether the current schedule includes the given datetime or they do not match.
Info |
---|
Excluded schedule segments will also return 'true' within checking by this method. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
datetime | SimpleDateTime | Y | N |
Return:
String | The schedule nameBoolean | This method returns 'true' if the specified datetime is in schedule; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
title | getName | isInSchedule |
---|
|
const nowDatetime = new SimpleDateTime();
constlet schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.getNameisInSchedule(nowDatetime)); // Info: 8x5 excluding Russian Holidaysfalse |
isValid()
This The method determines checks if the specified schedule is validSimpleSchedule object is valid.
Info |
---|
The object is considered as invalid when: - The schedule passed does not exist.
- The schedule does not contain schedule elements of the working type. The example type for elements of such schedule is Time Off or Excluded.
In both cases above, the isValid() method returns 'false'. |
Return:
Type | Description |
---|
Boolean | This method returns TRUE 'true' if the schedule is valid; otherwise, it returns FALSE'false'. |
Example:
Code Block |
---|
|
letconst schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isValid()); // Info: true |
isInScheduleisWorkingTime(
timedatetime)
This method determines if the given datetime is within the current schedulechecks whether a provided date and time is a working time or not.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
time
Return:
Type | Description |
---|
Boolean | This method returns |
TRUE if the specified datetime is in schedule'true' if provided date and time is a working time; otherwise, it returns |
FALSE. Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isWorkingTime |
---|
linenumbers | isInSchedule | true |
---|
|
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
const firstDatetimelet datetime = new SimpleDateTime('2020-12-15 05:59:59');
letconst schedulesecondDatetime = new SimpleScheduleSimpleDateTime('1571652926076667102020-12-15 06:00:00');
ss.info(schedule.isInScheduleisWorkingTime(datetimefirstDatetime)); // Info: false |
setTimeZone(timeZone)
ss.info(schedule.isWorkingTime(secondDatetime)); // Info: true |
load(sysId, timezoneTitle)
This method initializes a schedule specified with the sys_id.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
sysId | String | Y | N |
timezoneTitle | String (empty string by default) | N | '' |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
|
const schedule = new SimpleSchedule();
schedule.load('157165292607666710'); // sys_schedule.sys_id |
setTimeZone(timezoneTitle)
This method defines which time zone is to be applied to the current scheduleThis 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'); // sys_schedule.sys_id
schedule.setTimeZone('US/Central'); |
whenNext(
timedatetime,
timeZonetimezoneTitle)
This method determines how much time (in seconds) is returns the number of seconds left until the next schedule item startselement 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('157165292607666710161050499417811121'); // sys_schedule.sys_id
ss.info('Seconds Left: ' + schedule.whenNext(startDatetime).getDurationSeconds()); // Info: Seconds Left: 6052 |
whenWillExpire(
startDatestartDateTime, finalWorkingSeconds)
This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passes.
Note |
---|
Please note that finalWorkingSeconds parameter does not support negative values. |
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
startDate | | Y | N |
finalWorkingSeconds | Integer | Y | N |
Return:
Type | Description |
---|
SimpleDateTime |
The SimpleDateTime object
Note |
---|
If the SimpleSchedule class object is not valid (the isValid() method returns 'false' for this object), then the whenWillExpire() method returns 'null' for it. |
Example:
Code Block |
---|
language | js |
---|
title | whenWillExpire |
---|
|
const startDatetime = new SimpleDateTime('20192022-1001-2523 08:00:00'); // UTC datetime
const finalWorkingSeconds = 600 5 * 8 * 3600; // 10 minutes
let duration of 5 eight-hour days in seconds
const schedule = new SimpleSchedule('157165292607666710161050499417811121'); // schedules IDsys_schedule.sys_id
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); //2019-10-25 08:10 Info: 2022-01-28 18:30:00 |