Versions Compared

Key

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

This server class provides methods to operate SimpleSchedule objects, for example, getting 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):

NameTypeMandatoryDefault Value
idStringYN
timeZoneTitleStringN'UTC'


Example:

Code Block
languagejs
themeEclipse
titleschedule
linenumberstrue
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.


Note

Passed dateTime values should be in the schedule. For checking use isInSchedule(datetime) method.


Parameter(s):

NameTypeMandatoryDefault Value
startDateTimeSimpleDateTimeYN
endDateTimeSimpleDateTimeYN


Return:

TypeDescription
SimpleDurationThe difference between the two time values.


Example:

Code Block
languagejs
titleduration
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());
load



getname(

sysId, timeZoneTitle

)


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 datetime = new SimpleDateTime();
const schedule = new SimpleSchedule('157165292607666710');
ss.info(schedule.getNameisInSchedule(datetime)); // Info: 8x5 excluding Russian Holidaysfalse

isValid()


The method checks if the specified schedule is valid.


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');
ss.info(schedule.isValid()); // Info: true
isInSchedule

isWorkingTime(datetime)


This method checks whether the current schedule includes the given datetime or they do not matcha provided date and time is a working time or not.

Info

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


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
'false'.

isValid()

The method checks if the specified schedule is valid.

Return:

TypeDescriptionBooleanThis method returns TRUE if the schedule is valid; otherwise, it returns FALSE.


Code Block
languagejs
themeEclipse
titleisWorkingTime
linenumberstrue
const workingTime

Example:

Code Block
languagejs
titleisInSchedule
const datetime = new SimpleDateTime();
const schedule = new SimpleSchedule('157165292607666710'157165229904988595', 'Europe/Moscow');
ss.info(schedule.isInScheduleisWorkingTime(datetimeworkingTime)); // Info: false

load(sysId, timeZoneTitle)


This method initializes a schedule by the sys_id.


Parameter(s):

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


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleload
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):

NameTypeMandatoryDefault Value
timeZoneTitleStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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

whenNext(datetime, timeZoneTitle)


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


Parameter(s):

NameTypeMandatoryDefault Value
datetimeSimpleDateTimeYN
timeZoneTitle

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('157165292607666710');
ss.info(schedule.whenNext(startDatetime));

whenWillExpire(startDateTime, finalWorkingSeconds)


This method determines the time after working seconds value specified in the finalWorkingSeconds parameter passes.


Parameter(s):

NameTypeMandatoryDefault Value
startDate

SimpleDateTime

YN
finalWorkingSecondsIntegerYN


Return:

TypeDescription
SimpleDateTimeThe SimpleDateTime object


Example:


Code Block
languagejs
titlewhenWillExpire
const startDatetime = new SimpleDateTime('2019-10-25 08:00:00'); // UTC datetime
const finalWorkingSeconds = 600; // 10 minutes
const schedule = new SimpleSchedule('157165292607666710'); // schedule ID
ss.info(schedule.whenWillExpire(startDatetime, finalWorkingSeconds).getValue()); // Info: 2019-10-25 08:10:00


Table of Contents
absoluteUrltrue
classfixedPosition