Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server class provides methods are designed to operate work with the SimpleSchedule objects. You can use them, for example, getting to get a schedule name,  determining to verify if the current time matches with the working time, and returning return the difference between the two time values.

SimpleSchedule(id,

timeZoneTitle

timezoneTitle)


Instantiates Use this cinstructor to instantiate a new SimpleSchedule object.


Parameter(s):

NameTypeMandatoryDefault Value
idStringYNN
timeZoneTitletimezoneTitleStringN'UTC'


Example:

Code Block
languagejs
themeEclipse
titlescheduleSimpleSchedule
linenumberstrue
const schedule = new SimpleSchedule('157165292607666710', 'UTC');


duration(startDateTime, endDateTime)


This method determines the number of seconds time difference in the schedule between two datetime SimpleDateTime values, based on the schedule time zone or, if not specified, the session the session time zone.


Note

Passed dateTime values The passed SimpleDateTime value should be in the schedule. For checking verification, use the isInSchedule(datetime) method.


Parameter(s):

NameTypeMandatoryDefault Value
startDateTimeSimpleDateTime objectYN
endDateTimeSimpleDateTimeYN


Return:

TypeDescription
SimpleDurationThe difference between the two time values.


Example:

Code Block
languagejs
titleduration
const startDatetime = new SimpleDateTime('20192022-1001-25 08:00:00');
const endDatetime = new SimpleDateTime('20192022-1001-29 08:00:00');
const schedule = new SimpleSchedule('157165292607666710161050499417811121'); // sys_schedule.sys_id
const duration = schedule.duration(startDatetime, endDatetime);
ss.info(duration.getValue());
load(sysId, timeZoneTitle
 // Info: 1970-01-02 08:00:00

getName()


This method

initializes a schedule by the sys_id.

Parameter(s):

NameTypeMandatoryDefault ValuesysIdStringYNtimeZoneTitleString (empty string by default)N''

returns the name of the defined schedule.


Return:

TypeDescription
VoidThis method does not return a value
StringThe schedule name.


Example:

Code Block
languagejs
titleloadgetName
const schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.loadgetName('157165292607666710'));
getname(
 // Info: 8x5 excluding Russian Holidays

isInSchedule(datetime)


This method

returns the name of the defined schedule.

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):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN


Return:

TypeDescription
StringThe schedule name
BooleanThis method returns 'true' if the specified datetime is in schedule; otherwise, it returns 'false'.


Example:

Code Block
languagejs
titlegetNameisInSchedule
const nowDatetime = new SimpleDateTime();
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.getNameisInSchedule(nowDatetime)); // Info: 8x5 excluding Russian Holidaysfalse

isValid()


The method checks if the specified SimpleSchedule object is valid.

Info

The object is considered as invalid when:

  1. The schedule passed does not exist.
  2. 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:

TypeDescription
BooleanThis method returns 'true' if the schedule is valid; otherwise, it returns 'false'.

Example:

Code Block
languagejs
titleisValid
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
ss.info(schedule.isValid()); // Info: true
isInSchedule

isWorkingTime(datetime)


This method checks whether the current schedule includes the given datetime or they do not match.

Info

Excluded schedule segments will also return false within checking by this method.

a provided date and time is a working time or not.


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN


Return:

TypeDescription
BooleanThis method returns
TRUE if the specified datetime is in schedule
'true' if provided date and time is a working time; otherwise, it returns
FALSE.

isValid()

The method checks if the specified schedule is valid.

'false'.


Code Block
languagejs
themeEclipse
titleisWorkingTime
linenumberstrue
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 method initializes a schedule specified with the sys_id.


Parameter(s):

NameTypeMandatoryDefault Value
sysIdStringYN
timezoneTitleString (empty string by default)N''


Return:

TypeDescription
Boolean
VoidThis method
returns TRUE if the schedule is valid; otherwise, it returns FALSE
does not return a value.


Example:

Code Block
languagejs
titleisInScheduleload
const datetimeschedule = new SimpleDateTimeSimpleSchedule();
const schedule = new SimpleScheduleschedule.load('157165292607666710');
ss.info(schedule.isInSchedule(datetime)); // Info: falsesys_schedule.sys_id

setTimeZone(

timeZoneTitle

timezoneTitle)


This method defines which time zone is to be applied to the current schedule.


Parameter(s):

NameTypeMandatoryDefault Value
timeZoneTitletimezoneTitleStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlesetTimeZone
const schedule = new SimpleSchedule('157165292607666710'); // sys_schedule.sys_id
schedule.setTimeZone('US/Central');

whenNext(datetime,

timeZoneTitle

timezoneTitle)


This method returns the number of seconds left until the next schedule item startselement starts.


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN
timeZoneTitletimezoneTitle

String

N''


Return:

TypeDescription
SimpleDurationThe SimpleDuration object.


Example:

Code Block
languagejs
themeEclipse
titlewhenNext
linenumberstrue
const startDatetime = new SimpleDateTime('2019-10-25 08:00:00');
const schedule = new SimpleSchedule('157165292607666710161050499417811121'); // 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 passes.

Note

Please note that finalWorkingSeconds parameter does not support negative values.


Parameter(s):

NameTypeMandatoryDefault Value
startDate

SimpleDateTime

YN
finalWorkingSecondsIntegerYN


Return:

TypeDescription
SimpleDateTime The SimpleDateTime objectobject or 'null'This method returns 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
languagejs
titlewhenWillExpire
const startDatetime = new SimpleDateTime('20192022-1001-2523 08:00:00'); // UTC datetime
const finalWorkingSeconds = 600 5 * 8 * 3600; // 10 minutesduration of 5 eight-hour days in seconds
const schedule = new SimpleSchedule('157165292607666710161050499417811121'); // schedule IDsys_schedule.sys_id
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 20192022-1001-2528 0818:1030:00


Table of Contents
absoluteUrltrue
classfixedPosition