This server class provides methods to that operate with the SimpleSchedule objects, for . For example, getting you can get a schedule name, determining if verify that the current time matches with the working time, and returning return the difference between the two time values.
SimpleSchedule(id, timezoneTitle)
his Use this method instantiates to instantiate a new SimpleSchedule object.
Parameter(s):
ValueYN | N |
timezoneTitle | String | N | 'UTC' |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | scheduleSimpleSchedule |
---|
linenumbers | true |
---|
|
const schedule = new SimpleSchedule('157165292607666710', 'UTC'); |
duration(startDateTime, endDateTime)
This Use this method determines the number of seconds in the schedule between two Datetime to get the time difference between the startDatetime and endDatetime values, based on the schedule, its time zone or, if not specified, the session time zone of the session.
Note |
---|
Passed dateTime values The value passed in the datetime parameter should be in the schedule. To verify itthat, use the isInSchedule(datetime) method. |
Parameter(s):
Valuevalue |
---|
startDateTime | SimpleDateTime object | Y | N |
endDateTime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
SimpleDuration object |
The This method returns the difference between the two time values. |
Example:
Code Block |
---|
language | js |
---|
title | duration() |
---|
linenumbers | true |
---|
|
const startDatetime = new SimpleDateTime('2022-01-25 08:00:00');
const endDatetime = new SimpleDateTime('2022-01-29 08:00:00');
const schedule = new SimpleSchedule('161050499417811121'); // sys_schedule.sys_id
const duration = schedule.duration(startDatetime, endDatetime);
ss.info(duration.getValue()); // Info: 1970-01-02 08:00:00 |
getName()
This Use this method returns to get the name of the defined specified schedule.
Return:
A This method returns a schedule name. |
Example:
Code Block |
---|
language | js |
---|
title | getName() |
---|
linenumbers | true |
---|
|
const schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.getName()); // Info: 8x5 excluding Russian Holidays |
isInSchedule(datetime)
This method verifies whether Use this method to verify that the current schedule includes the given datetime or they do not matchdate and time.
Info |
---|
Excluded schedule segments also return 'true' within checking by this methodThis method returns true when verifying excluded schedule segments. |
Parameter(s):
Valuevalue |
---|
datetime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
Boolean | This method returns |
'' if if the specified datetime |
is value is in schedule; otherwise, it returns |
''Example:
Code Block |
---|
language | js |
---|
title | isInSchedule() |
---|
linenumbers | true |
---|
|
const nowDatetime = new SimpleDateTime();
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isInSchedule(nowDatetime)); // Info: false |
isValid()
The method verifies if Use this method to verify that the specified SimpleSchedule object schedule is valid.
Info |
---|
The object A schedule is considered as invalid when: - The schedule passed does not exist.
- The schedule does not contain the schedule elements of the . The example type for the elements of such schedule is Time Off , for example, Time off or Excluded.
In both cases above, the isValid() method returns 'false'. |
Return:
Type | Description |
---|
Boolean | This method returns |
''if the schedule is valid; otherwise, it returns |
''Example:
Code Block |
---|
language | js |
---|
title | isValid() |
---|
linenumbers | true |
---|
|
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isValid()); // Info: true |
isWorkingTime(datetime)
This method checks whether a Use this method to verify that the provided date and time is a working time or not.
Parameter(s):
Valuevalue |
---|
datetime | SimpleDateTime object | Y | N |
Return:
Type | Description |
---|
Boolean | This method returns 'true 'if the provided date and time is a working time; otherwise, it returns 'false'. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | isWorkingTime() |
---|
linenumbers | true |
---|
|
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
const firstDatetime = new SimpleDateTime('2020-12-15 05:59:59');
const secondDatetime = new SimpleDateTime('2020-12-15 06:00:00');
ss.info(schedule.isWorkingTime(firstDatetime)); // Info: false
ss.info(schedule.isWorkingTime(secondDatetime)); // Info: true |
load(sysId, timezoneTitle)
This Use this method initializes to initialize a schedule specified with the sys_id. ID according to the time zone.
Parameter(s):
Valuevalue |
---|
sysId | String | Y | N |
timezoneTitle | String |
(empty string by default) Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | load() |
---|
linenumbers | true |
---|
|
const schedule = new SimpleSchedule();
schedule.load('157165292607666710'); // sys_schedule.sys_id |
setTimeZone(timezoneTitle)
Use this method to define which set a time zone to apply to for the current schedule.
Parameter(s):
Valuevalue |
---|
timezoneTitle | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
title | setTimeZone() |
---|
|
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
schedule.setTimeZone('US/Central'); |
whenNext(datetime, timezoneTitle)
This Use this method returns the number of seconds left to get the time left, as a SimpleDuration object, until the next schedule element startselement begins.
Parameter(s):
Valuevalue |
---|
datetime | SimpleDateTime object | Y | N |
timezoneTitle | | N | '' |
Return:
Type | Description |
---|
SimpleDuration object |
The This method returns the SimpleDuration object. It returns null if the schedule is invalid. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | whenNext() |
---|
linenumbers | true |
---|
|
const startDatetime = new SimpleDateTime();
const schedule = new SimpleSchedule('161050499417811121'); // sys_schedule.sys_id
ss.info('Seconds Left: ' + schedule.whenNext(startDatetime).getDurationSeconds()); // Info: Seconds Left: 6052 |
whenWillExpire(startDateTime, finalWorkingSeconds)
This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passesUse this method to calculate the date and time when the time value set in the finalWorkingSeconds parameter in seconds finishes after the time set in the startDateTime. All calculations are done based on the specified schedule.
Note |
---|
Note that The finalWorkingSeconds parameter does not support negative values. |
Parameter(s):
Valuevalue |
---|
startDate | | Y | N |
finalWorkingSeconds | Integer | Y | N |
Return:
Type | Description |
---|
SimpleDateTime object |
or 'null'
Note |
---|
If the SimpleSchedule class object is not valid (the isValid() method returns 'false 'for this object), the whenWillExpire() method method returns 'null' for it. |
Example:
Code Block |
---|
language | js |
---|
title | whenWillExpire() |
---|
linenumbers | true |
---|
|
const startDatetime = new SimpleDateTime('2022-01-23 08:00:00');
const finalWorkingSeconds = 5 * 8 * 3600; // duration of 5 eight-hour days in seconds
const schedule = new SimpleSchedule('161050499417811121'); // sys_schedule.sys_id
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 2022-01-28 18:30:00 |