You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 71 Next »
This server class provides methods to operate with the SimpleSchedule objects, for example, getting a schedule name, determining if the current time matches with working time, and returning the difference between two time values.
SimpleSchedule(id, timezoneTitle)
Instantiates a new SimpleSchedule object.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
id | String | Y | N |
timezoneTitle | String | N | 'UTC' |
Example:
const schedule = new SimpleSchedule('157165292607666710', 'UTC');
duration(startDateTime, endDateTime)
This method determines the number of seconds in the schedule between two datetime values, based on the schedule time zone or, if not specified, the session time zone.
Passed dateTime values should be in the schedule. For checking use isInSchedule(datetime) method.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
startDateTime | SimpleDateTime | Y | N |
endDateTime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|---|
SimpleDuration | The difference between the two time values. |
Example:
const startDatetime = new SimpleDateTime('2019-10-25 08:00:00'); const endDatetime = new SimpleDateTime('2019-10-29 08:00:00'); const schedule = new SimpleSchedule('157165292607666710'); const duration = schedule.duration(startDatetime, endDatetime); ss.info(duration.getValue());
getName()
This method returns the name of the defined schedule.
Return:
Type | Description |
---|---|
String | The schedule name. |
Example:
const schedule = new SimpleSchedule('157165292607666710'); ss.info(schedule.getName()); // Info: 8x5 excluding Russian Holidays
isInSchedule(datetime)
This method checks whether the current schedule includes the given datetime or they do not match.
Excluded schedule segments will also return 'true' within checking by this method.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
datetime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns TRUE if the specified datetime is in schedule; otherwise, it returns FALSE. |
Example:
const nowDatetime = new SimpleDateTime(); const schedule = new SimpleSchedule('157165292607666710'); ss.info(schedule.isInSchedule(nowDatetime)); // Info: false
isValid()
The method checks if the specified schedule is valid.
Return:
Type | Description |
---|---|
Boolean | This method returns TRUE if the schedule is valid; otherwise, it returns FALSE. |
Example:
const schedule = new SimpleSchedule('157165292607666710'); ss.info(schedule.isValid()); // Info: true
isWorkingTime(datetime)
This method checks whether a provided date and time is a working time or not.
Excluded schedule segments will also return 'true' within checking by this method.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
datetime | SimpleDateTime | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns 'true' if provided date and time is a working time; otherwise, it returns 'false'. |
const schedule = new SimpleSchedule('157165292607666710'); const firtsDatetime = new SimpleDateTime('2020-12-15 05:59:59'); const secondDatetime = new SimpleDateTime('2020-12-15 06:00:00'); ss.info(schedule.isWorkingTime(firtsDatetime)); // Info: false ss.info(schedule.isWorkingTime(secondDatetime)); // Info: true
load(sysId, timezoneTitle)
This method initializes a schedule by 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:
const schedule = new SimpleSchedule(); schedule.load('157165292607666710');
setTimeZone(timezoneTitle)
This method defines which time zone is to be applied to the current schedule.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
timezoneTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
const schedule = new SimpleSchedule('157165292607666710'); schedule.setTimeZone('US/Central');
whenNext(datetime, timezoneTitle)
This method returns the number of seconds left until the next schedule element starts.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
datetime | SimpleDateTime | Y | N |
timezoneTitle | String | N | '' |
Return:
Type | Description |
---|---|
SimpleDuration | The SimpleDuration object |
Example:
const startDatetime = new SimpleDateTime(); const schedule = new SimpleSchedule('157165292607666710'); ss.info('Seconds Left: ' + schedule.whenNext(startDatetime).getDurationSeconds());
whenWillExpire(startDateTime, finalWorkingSeconds)
This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passes.
Please note that finalWorkingSeconds parameter does not support negative values.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
startDate | SimpleDateTime | Y | N |
finalWorkingSeconds | Integer | Y | N |
Return:
Type | Description |
---|---|
SimpleDateTime | The SimpleDateTime object |
Example:
const startDatetime = new SimpleDateTime('2019-10-25 08:00:00'); const finalWorkingSeconds = 600; // 10 minutes const schedule = new SimpleSchedule('157165292607666710'); ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 2019-10-25 08:10:00
- No labels